예제 #1
0
  public CRAMFileWriter makeCRAMWriter(
      final SAMFileHeader header, final File outputFile, final File referenceFasta) {

    final boolean createIndex = this.createIndex && IOUtil.isRegularPath(outputFile);
    if (this.createIndex && !createIndex) {
      System.err.println(
          "Cannot create index for CAM because output file is not a regular file: "
              + outputFile.getAbsolutePath());
    }

    try {

      OutputStream indexOS = null;
      if (createIndex) {
        File indexFile = new File(outputFile.getAbsolutePath() + ".bai");
        indexOS = new FileOutputStream(indexFile);
      }
      final CRAMFileWriter writer =
          new CRAMFileWriter(
              new FileOutputStream(outputFile),
              indexOS,
              new ReferenceSource(referenceFasta),
              header,
              null);
      writer.setPreserveReadNames(true);
      writer.setCaptureAllTags(true);
      return writer;
    } catch (final IOException ioe) {
      throw new RuntimeIOException("Error opening file: " + outputFile.getAbsolutePath());
    }
  }
예제 #2
0
  public CRAMFileWriter makeCRAMWriter(
      final SAMFileHeader header, final OutputStream stream, final File referenceFasta) {

    final CRAMFileWriter writer =
        new CRAMFileWriter(stream, new ReferenceSource(referenceFasta), header, null);
    writer.setPreserveReadNames(true);
    writer.setCaptureAllTags(true);
    return writer;
  }