Package net.sf.samtools

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


  //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

    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

  }
  */
 
  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

 
  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

    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

   
    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

    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

    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

   
    ThreadManager threads = new ThreadManager(numThreads);
   
    Map<String, SAMFileWriter> outputWriterMap = new HashMap<String, SAMFileWriter>();
   
    SAMFileWriterFactory writerFactory = new SAMFileWriterFactory();
    writerFactory.setUseAsyncIo(false);
   
    // Farm each chromosome out to its own thread.
    for (SAMSequenceRecord chr : rdr.getFileHeader().getSequenceDictionary().getSequences()) {   
      SAMFileWriter writer = writerFactory.makeSAMOrBAMWriter(
          rdr.getFileHeader(), false, new File(outputDirectory + "/" + chr.getSequenceName() + ".bam"));
     
      outputWriterMap.put(chr.getSequenceName(), writer);
     
      BamSplitterThread thread = new BamSplitterThread(threads, filename, chr.getSequenceName(), writer);
View Full Code Here

TOP

Related Classes of net.sf.samtools.SAMFileWriterFactory

Copyright © 2018 www.massapicom. 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.