Examples of SAMFileWriterFactory


Examples of htsjdk.samtools.SAMFileWriterFactory

        builder.addPair("rrnaPair", sequenceIndex, 400, 500);

        builder.addFrag("ignoredFrag", builder.getHeader().getSequenceIndex(ignoredSequence), 1, false);

        final File samFile = File.createTempFile("tmp.collectRnaSeqMetrics.", ".sam");
        final SAMFileWriter samWriter = new SAMFileWriterFactory().makeSAMWriter(builder.getHeader(), false, samFile);
        for (final SAMRecord rec: builder.getRecords()) samWriter.addAlignment(rec);
        samWriter.close();

        // Create an interval list with one ribosomal interval.
        final Interval rRnaInterval = new Interval(sequence, 300, 520, true, "rRNA");
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

//    printRegionHeader();
   
    SAMFileReader reader = new SAMFileReader(new File(inputSam));
    reader.setValidationStringency(ValidationStringency.SILENT);

    SAMFileWriter output = new SAMFileWriterFactory().makeSAMOrBAMWriter(
        reader.getFileHeader(), true, new File(outputSam));

    int cnt = 0;
   
    for (SAMRecord read : reader) {
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

  //TODO: Move to utils package
  public void fix(String input, String output, String reference) throws IOException {
    SAMFileReader reader = new SAMFileReader(new File(input));
    reader.setValidationStringency(ValidationStringency.SILENT);
   
    SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(
        reader.getFileHeader(), true, new File(output));
   
    CompareToReference c2r = new CompareToReference();
    c2r.init(reference);
   
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

    String svContigFasta = tempDir + "/" + "sv_contigs.fasta";
    svContigWriter = new BufferedWriter(new FileWriter(svContigFasta, false));
   
    tempDirs = new String[inputSams.length];
   
    SAMFileWriterFactory writerFactory = new SAMFileWriterFactory();
//    writerFactory.setUseAsyncIo(true);
    writerFactory.setUseAsyncIo(false);
   
    writers = new SAMFileWriter[inputSams.length];
   
    for (int i=0; i<inputSams.length; i++) {
      // init temp dir
      String temp = tempDir + "/temp" + (i+1);
      mkdir(temp);
      tempDirs[i] = temp;

      // init BAM writer
      writers[i] = writerFactory.makeSAMOrBAMWriter(
          samHeaders[i], false, new File(outputFiles[i]));
    }
   
    // Start pre-processing reads on separate thread for each input file.
    // This happens in parallel with assembly, provided there are enough threads.
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

  }
  */
 
  private void copySam(String input, String output) {
   
    SAMFileWriterFactory writerFactory = new SAMFileWriterFactory();
   
    SAMFileReader reader = new SAMFileReader(new File(input));
    reader.setValidationStringency(ValidationStringency.SILENT);
   
    SAMFileWriter writer = writerFactory.makeSAMOrBAMWriter(
        reader.getFileHeader(), false, new File(output));
   
    for (SAMRecord read : reader) {
      writer.addAlignment(read);
    }
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

 
  private void discardMisalignedContigs(String inputSam, String outputSam) {
    SAMFileReader reader = new SAMFileReader(new File(inputSam));
    reader.setValidationStringency(ValidationStringency.SILENT);
   
    SAMFileWriter outputReadsBam = new SAMFileWriterFactory().makeSAMOrBAMWriter(
        samHeaders[0], true, new File(outputSam));

    for (SAMRecord contig : reader) {
      String[] fields = contig.getReadName().split("_");
     
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

    System.out.println("keepProbability: " + keepProbability);
   
    SAMFileReader reader = new SAMFileReader(new File(sam));
    reader.setValidationStringency(ValidationStringency.SILENT);
   
    SAMFileWriter downsampleOutput = new SAMFileWriterFactory().makeSAMOrBAMWriter(
        samHeaders[0], true, new File(downsampledSam));

    Random random = new Random(RANDOM_SEED);
    int downsampleCount = 0;
   
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

   
    samStringReader = new SamStringReader(header);
   
    candidatesSam = tempDir + "/candidates.bam";
   
    candidatesSamWriter = new SAMFileWriterFactory().makeSAMOrBAMWriter(
        header, false, new File(candidatesSam));
   
    this.minInsertLength = minInsertLen;
    this.maxInsertLength = maxInsertLen;
  }
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

    SAMFileReader reader = new SAMFileReader(new File("/home/lmose/dev/abra/1076/candidates.bam"));
    SAMFileHeader header = reader.getFileHeader();
    reader.close();
    header.setSortOrder(SortOrder.unsorted);
   
    SAMFileWriterFactory writerFactory = new SAMFileWriterFactory();
    writerFactory.setUseAsyncIo(false);
    SAMFileWriter writer = writerFactory.makeSAMOrBAMWriter(
        header, false, new File("/home/lmose/dev/abra/1076/test.bam"));

   
    BetaPairValidatingRealignmentWriter w = new BetaPairValidatingRealignmentWriter(null,
        writer, "foofi", 0, 200000);
View Full Code Here

Examples of net.sf.samtools.SAMFileWriterFactory

    SAMFileHeader header = reader.getFileHeader();
    reader.close();
       
    CompareToReference2 c2r = null;
   
    SAMFileWriterFactory writerFactory = new SAMFileWriterFactory();
//    writerFactory.setUseAsyncIo(true);
   
    header.setSortOrder(SortOrder.unsorted);
   
    SAMFileWriter writer = writerFactory.makeSAMOrBAMWriter(
        header, false, new File("/home/lmose/dev/abra/region_tracker/out.bam"));
   
    Sam2Fastq s2f = new Sam2Fastq();
   
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.