//main function
// This function collects mismatch, InDel and GC contens 
// from sam files
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        string programname = argv[0];
        usage(programname);
        exit(EXIT_FAILURE);
    }
    printheader();
    if (strcmp(argv[1],"-") == 0)
    {
        cerr << "Taking file from stdin!" << endl;
        processStdin();
    }
    else
    {
        cerr << "Taking file from file: "<< argv[1] << "..." << endl;
        const char *filename = argv[1];
        processFile(filename);
    }
    return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
  XVisualInfo *vi;
  Colormap cmap;
  XSetWindowAttributes swa;
  Window win;
  GLXContext cx;
  XEvent event;
  fd_set readfds;
  struct timeval timeout;
  int xServerFD;
  int nselected;
    
  /* get a connection */
  xDisplay = XOpenDisplay(0);
  if (xDisplay == NULL) {
    fprintf(stderr, "can't open display\n");
    exit(1);
  }
    
  /* get an appropriate visual */
  vi = glXChooseVisual(xDisplay, DefaultScreen(xDisplay), attributeList);
  if (vi == NULL) {
    fprintf(stderr, "can't get visual\n");
    exit(1);
  }
    
  /* create a GLX context */
  cx = glXCreateContext(xDisplay, vi, 0, GL_FALSE);
  if (cx == NULL) {
    fprintf(stderr, "can't create GL context\n");
    exit(1);
  }
    
  /* create a color map */
  cmap = XCreateColormap(xDisplay, RootWindow(xDisplay, vi->screen), vi->visual, AllocNone);
    
  /* create a window */
  swa.colormap = cmap;
  swa.border_pixel = 0;
  swa.event_mask = StructureNotifyMask;

  windowWidth = 500;
  windowHeight = 500;
    
  win = XCreateWindow(xDisplay, RootWindow(xDisplay, vi->screen), 0, 0, windowWidth, windowHeight,
                      0, vi->depth, InputOutput, vi->visual,
                      CWBorderPixel|CWColormap|CWEventMask, &swa);

  XSelectInput(xDisplay, win, KeyPressMask | ExposureMask | StructureNotifyMask);
    
  XMapWindow(xDisplay, win);
  // wait for the window to be mapped
  XIfEvent(xDisplay, &event, WaitForNotify, (char*)win);
  /* connect the context to the window */
  glXMakeCurrent(xDisplay, win, cx);

  quad = gluNewQuadric();
  if (quad == NULL) {
    fprintf(stderr, "can't allocate quadric\n");
    exit(1);
  }

  resetEye();

  xServerFD = ConnectionNumber(xDisplay);
  XFlush(xDisplay);
  
  while (1) {
    while (processX()) {
    }
    if (needRepaint) {
      doPaint();
    }
    FD_ZERO(&readfds);
    if (!atEOF) {
      FD_SET(0, &readfds);
    }
    FD_SET(xServerFD, &readfds);
    timeout.tv_sec = 5;
    timeout.tv_usec = 0;
    nselected = select(xServerFD+1, &readfds, NULL, NULL, atEOF ? &timeout : NULL);
    if (nselected < 0) {
      perror("select");
      continue;
    }
    if (nselected == 0) {
      continue;
    }
    if (FD_ISSET(0, &readfds)) {
      processStdin();
    }
  }
}