Esempio n. 1
1
 public Bed2Bar(String[] args) {
   try {
     processArgs(args);
     // load Window[]
     for (int i = 0; i < bedFiles.length; i++) {
       bedFile = bedFiles[i];
       System.out.println("Parsing " + bedFile.getName());
       bedLinesHash = Bed.parseBedFile(bedFile, true, false);
       if (bedLinesHash == null || bedLinesHash.size() == 0) {
         System.out.println("Problem parsing bed file, skipping!");
         continue;
       }
       barDirectory = IO.makeDirectory(bedFile, "");
       File bedOutFile =
           new File(Misc.removeExtension(bedFile.toString()) + "_" + threshold + "_Filt.bed");
       bedOut = new PrintWriter(new FileWriter(bedOutFile));
       makeStairStepBarFiles();
     }
     bedOut.close();
     System.out.println("\nDone!\n");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
  // constructor
  public Sgr2Bar(String[] args) {
    try {
      // check for args
      processArgs(args);

      System.out.println("Genome version -> " + genomeVersion);
      System.out.println("Strand -> " + strand);
      System.out.println("Stair Step? -> " + stairStep);
      System.out.println();

      // load tagValues
      if (stairStep) tagValues.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_STAIRSTEP);
      else tagValues.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_BAR);

      for (int x = 0; x < sgrFiles.length; x++) {
        System.out.println("\tLoading -> " + sgrFiles[x]);
        GrGraph[] grs = GrGraph.loadSgrFile(sgrFiles[x]);

        // make save directory
        String dirName;

        dirName = Misc.removeExtension(sgrFiles[x].getCanonicalPath());

        File dir = new File(dirName);
        dir.mkdir();
        // print bar files
        System.out.println("\tSaving...");
        for (int i = 0; i < grs.length; i++) {
          File barFile = new File(dir, grs[i].getChromosome() + ".bar");
          barParser.writeBarFile(
              barFile,
              grs[i].getChromosome(),
              genomeVersion,
              strand.charAt(0),
              grs[i].getBasePositions(),
              grs[i].getValues(),
              tagValues);
        }
      }
      System.out.println("\nDone!\n");
    } catch (IOException e) {
      e.printStackTrace();
      Misc.printErrAndExit("\nFailed to parse file!");
    }
  }