示例#1
0
  /**
   * Compute coverage or density of an alignment or feature file.
   *
   * @param ifile Alignment or feature file
   * @param ofile Output file
   * @param genomeId Genome id (e.g. hg18) or full path to a .genome file (e.g.
   *     /xchip/igv/scer2.genome)
   * @param maxZoomValue Maximum zoom level to precompute. Default value is 7
   * @param windowFunctions
   * @param windowSizeValue
   * @param extFactorValue
   * @param trackLine
   * @param queryString
   * @param minMapQuality
   * @param countFlags
   * @throws IOException
   */
  public void doCount(
      String ifile,
      String ofile,
      String genomeId,
      int maxZoomValue,
      Collection<WindowFunction> windowFunctions,
      int windowSizeValue,
      int extFactorValue,
      String trackLine,
      String queryString,
      int minMapQuality,
      int countFlags)
      throws IOException {

    System.out.println("Computing coverage.  File = " + ifile);
    System.out.println("Max zoom = " + maxZoomValue);
    System.out.println("Window size = " + windowSizeValue);
    System.out.print("Window functions: ");
    for (WindowFunction wf : windowFunctions) {
      System.out.print(wf.toString() + " ");
    }
    System.out.println();
    System.out.println("Ext factor = " + extFactorValue);

    Genome genome = loadGenome(genomeId, false);
    if (genome == null) {
      throw new PreprocessingException("Genome could not be loaded: " + genomeId);
    }

    // Multiple files allowed for count command (a tdf and a wig)
    File tdfFile = null;
    File wigFile = null;
    String[] files = ofile.split(",");
    if (files[0].endsWith("wig")) {
      wigFile = new File(files[0]);
    } else {
      tdfFile = new File(files[0]);
    }
    if (files.length > 1) {
      if (files[1].endsWith("wig")) {
        wigFile = new File(files[1]);
      } else if (files[1].endsWith("tdf")) {
        tdfFile = new File(files[1]);
      }
    }

    if (tdfFile != null && !tdfFile.getName().endsWith(".tdf")) {
      tdfFile = new File(tdfFile.getAbsolutePath() + ".tdf");
    }

    Preprocessor p = new Preprocessor(tdfFile, genome, windowFunctions, -1, null);
    // p.count(ifile, windowSizeValue, extFactorValue, maxZoomValue, wigFile, coverageOpt,
    // trackLine);
    p.count(
        ifile,
        windowSizeValue,
        extFactorValue,
        maxZoomValue,
        wigFile,
        trackLine,
        queryString,
        minMapQuality,
        countFlags);

    p.finish();

    System.out.flush();
  }