/** @{inheritDoc} */
  @Override
  public SAMRecordIterator query(
      final String sequence, final int start, final int end, final boolean contained) {
    GenomeLoc region = genomeLocParser.createGenomeLoc(sequence, start, end);
    List<SAMRecord> coveredSubset = new ArrayList<SAMRecord>();

    for (SAMRecord read : reads) {
      GenomeLoc readPosition = genomeLocParser.createGenomeLoc(read);
      if (contained && region.containsP(readPosition)) coveredSubset.add(read);
      else if (!contained && readPosition.overlapsP(region)) coveredSubset.add(read);
    }

    final Iterator<SAMRecord> iterator = coveredSubset.iterator();
    return new SAMRecordIterator() {
      public boolean hasNext() {
        return iterator.hasNext();
      }

      public SAMRecord next() {
        return iterator.next();
      }

      public void close() {}

      public void remove() {
        iterator.remove();
      }

      public SAMRecordIterator assertSorted(SAMFileHeader.SortOrder sortOrder) {
        return this;
      }
    };
  }
Пример #2
0
 @BeforeTest
 public void before() {
   // Create GenomeLoc
   IndexedFastaSequenceFile fasta =
       CachingIndexedFastaSequenceFile.checkAndCreate(
           new File(privateTestDir + "iupacFASTA.fasta"));
   GenomeLocParser genomeLocParser = new GenomeLocParser(fasta);
   chr1 = fasta.getSequenceDictionary().getSequence(0).getSequenceName();
   genomeLoc = genomeLocParser.createGenomeLoc(chr1, 5, 10);
 }
Пример #3
0
 /**
  * Updating the location of this CalledBaseState by the new stop location
  *
  * @param newStop
  */
 public void update(GenomeLoc newStop) {
   loc = genomeLocParser.createGenomeLoc(loc.getContig(), loc.getStart(), newStop.getStop());
 }
 @BeforeClass
 public void beforeClass() {
   header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000);
   genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
   loc = genomeLocParser.createGenomeLoc("chr1", 1);
 }