本文整理汇总了Java中htsjdk.samtools.util.PeekableIterator类的典型用法代码示例。如果您正苦于以下问题:Java PeekableIterator类的具体用法?Java PeekableIterator怎么用?Java PeekableIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PeekableIterator类属于htsjdk.samtools.util包,在下文中一共展示了PeekableIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: iterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
public Iterator<LocusInfo> iterator() {
if (samIterator != null) {
throw new IllegalStateException("Cannot call iterator() more than once on SamLocusIterator");
}
CloseableIterator<SAMRecord> tempIterator;
if (intervals != null) {
tempIterator = new SamRecordIntervalIteratorFactory().makeSamRecordIntervalIterator(samReader, intervals, useIndex);
} else {
tempIterator = samReader.iterator();
}
if (samFilters != null) {
tempIterator = new FilteringIterator(tempIterator, new AggregateFilter(samFilters));
}
samIterator = new PeekableIterator<SAMRecord>(tempIterator);
return this;
}
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:17,代码来源:SamLocusIterator.java
示例2: splitByChromosome
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Override
protected void splitByChromosome(WigFile wigFile, Map<String, Chromosome> chromosomeMap) throws IOException {
List<BedGraphFeature> sectionList = new ArrayList<>();
for (Chromosome chromosome : chromosomeMap.values()) {
String realChrName = fetchRealChrName(wigFile.getIndex().getPath(), chromosome.getName());
try (PeekableIterator<BedGraphFeature> query = new PeekableIterator<>(
new BedGraphReader(wigFile.getPath(), wigFile.getIndex().getPath()).query(
realChrName, 1, chromosome.getSize() - 1))) {
int start = 0;
int stop = chromosome.getSize();
int bp = start;
while (bp < stop) {
int chunkStart = bp;
int chunkStop = Math.min(bp + WIG_DOWNSAMPLING_WINDOW - 1, stop);
float chunkScore = getScoreForBounds(query, chunkStart, chunkStop);
bp = chunkStop + 1;
sectionList.add(new BedGraphFeature(chromosome.getName(), chunkStart, chunkStop, chunkScore));
}
}
}
File downsampled = fileManager.writeToBedGraphFile(wigFile, sectionList);
File indexFile = new File(getDownsampledBedGraphIndex(downsampled.getPath()));
LOGGER.debug("Writing BED_GRAPH index at {}", indexFile.getAbsolutePath());
IntervalTreeIndex intervalTreeIndex = IndexFactory.createIntervalIndex(downsampled, new BedGraphCodec());
IndexFactory.writeIndex(intervalTreeIndex, indexFile); // Write it to a file
}
开发者ID:epam,项目名称:NGB,代码行数:27,代码来源:BedGraphProcessor.java
示例3: getScoreForBounds
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
private float getScoreForBounds(PeekableIterator<BedGraphFeature> query, int chunkStart, int chunkStop) {
float score = 0.0f;
while (query.hasNext()) {
BedGraphFeature bedGraphFeature = query.peek();
if (bedGraphFeature.getStart() < chunkStop && bedGraphFeature.getEnd() > chunkStart) {
score = score < bedGraphFeature.getValue() ? bedGraphFeature.getValue() : score;
}
if (chunkStop >= bedGraphFeature.getEnd()) {
//let's skip future because we already move forward
query.next();
} else {
// we should keep bedGraphFeature for next track block
break;
}
}
return score;
}
开发者ID:epam,项目名称:NGB,代码行数:19,代码来源:BedGraphProcessor.java
示例4: MultiHitAlignedReadIterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
*
* @param querynameOrderIterator
* @param primaryAlignmentSelectionStrategy Algorithm for selecting primary alignment when it is not clear from
* the input what should be primary.
*/
MultiHitAlignedReadIterator(final CloseableIterator<SAMRecord> querynameOrderIterator,
final PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy) {
this.primaryAlignmentSelectionStrategy = primaryAlignmentSelectionStrategy;
peekIterator = new PeekableIterator<SAMRecord>(new FilteringSamIterator(querynameOrderIterator,
new SamRecordFilter() {
// Filter unmapped reads.
public boolean filterOut(final SAMRecord record) {
return record.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(record.getCigar());
}
public boolean filterOut(final SAMRecord first, final SAMRecord second) {
return ((first.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(first.getCigar()))
&& (second.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(second.getCigar())));
}
}));
advance();
}
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:MultiHitAlignedReadIterator.java
示例5: getNextReadPair
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
* Get the next read pair (where both have the same read name).
* If we encounter an unpaired read, the second read in the pair will be set to null.
*
* @param iterator iterator of reads
* @return ReadPair object holding the reads, or null if there are no more reads in the iterator
*/
public static ReadPair getNextReadPair(final PeekableIterator<SAMRecord> iterator) {
final ReadPair readPair = new ReadPair();
readPair.read1 = getNextUsableRead(iterator, false);
if (readPair.read1 == null) {
return null;
}
final SAMRecord peekedNextRead = getNextUsableRead(iterator, true);
if (peekedNextRead != null && peekedNextRead.getReadName().equals(readPair.read1.getReadName())) {
readPair.read2 = getNextUsableRead(iterator, false);
}
return readPair;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:23,代码来源:QuerySortedReadPairIteratorUtil.java
示例6: getNextUsableRead
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
* Return the next usable read in the iterator
*
* @param iterator the iterator to pull from
* @param justPeek if true, just peek the next usable read rather than pulling it (note: it may remove unusable reads from the iterator)
* @return the next read or null if none are left
*/
private static SAMRecord getNextUsableRead(final PeekableIterator<SAMRecord> iterator, final boolean justPeek) {
while (iterator.hasNext()) {
// trash the next read if it fails PF, is secondary, or is supplementary
final SAMRecord nextRead = iterator.peek();
if (nextRead.getReadFailsVendorQualityCheckFlag() || nextRead.isSecondaryOrSupplementary()) {
iterator.next();
}
// otherwise, return it
else {
return justPeek ? nextRead : iterator.next();
}
}
// no good reads left
return null;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:QuerySortedReadPairIteratorUtil.java
示例7: testBasicPairedRead
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Test
public void testBasicPairedRead() {
SAMRecordSetBuilder builder = new SAMRecordSetBuilder(false, SAMFileHeader.SortOrder.queryname);
builder.setReadLength(READ_LENGTH);
builder.addPair("mapped_paired", 1, 1, 31);
PeekableIterator<SAMRecord> iterator = new PeekableIterator<SAMRecord>(builder.iterator());
QuerySortedReadPairIteratorUtil.ReadPair pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.read1);
Assert.assertNotNull(pair.read2);
Assert.assertEquals("mapped_paired", pair.read1.getReadName());
Assert.assertEquals("mapped_paired", pair.read2.getReadName());
pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNull(pair);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:18,代码来源:QuerySortedReadPairIteratorUtilTest.java
示例8: testBasicUnmappedReadPair
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Test
public void testBasicUnmappedReadPair() {
SAMRecordSetBuilder builder = new SAMRecordSetBuilder(false, SAMFileHeader.SortOrder.queryname);
builder.setReadLength(READ_LENGTH);
builder.addUnmappedPair("unmapped_paired");
PeekableIterator<SAMRecord> iterator = new PeekableIterator<SAMRecord>(builder.iterator());
QuerySortedReadPairIteratorUtil.ReadPair pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.read1);
Assert.assertNotNull(pair.read2);
Assert.assertEquals("unmapped_paired", pair.read1.getReadName());
Assert.assertEquals("unmapped_paired", pair.read2.getReadName());
pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNull(pair);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:18,代码来源:QuerySortedReadPairIteratorUtilTest.java
示例9: testBasicHalfmappedReadPair
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Test
public void testBasicHalfmappedReadPair() {
SAMRecordSetBuilder builder = new SAMRecordSetBuilder(false, SAMFileHeader.SortOrder.queryname);
builder.setReadLength(READ_LENGTH);
builder.addPair("halfmapped_paired", 1, 1, 31, false, true, "20M", "20M", true, false, 20);
PeekableIterator<SAMRecord> iterator = new PeekableIterator<SAMRecord>(builder.iterator());
QuerySortedReadPairIteratorUtil.ReadPair pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.read1);
Assert.assertNotNull(pair.read2);
Assert.assertEquals("halfmapped_paired", pair.read1.getReadName());
Assert.assertEquals("halfmapped_paired", pair.read2.getReadName());
pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNull(pair);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:18,代码来源:QuerySortedReadPairIteratorUtilTest.java
示例10: testFragmentNoReadPair
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Test
public void testFragmentNoReadPair() {
SAMRecordSetBuilder builder = new SAMRecordSetBuilder(false, SAMFileHeader.SortOrder.queryname);
builder.setReadLength(READ_LENGTH);
builder.addFrag("mapped_frag_a", 1, 1, false);
builder.addFrag("mapped_frag_b", 1, 1, false);
PeekableIterator<SAMRecord> iterator = new PeekableIterator<SAMRecord>(builder.iterator());
QuerySortedReadPairIteratorUtil.ReadPair pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.read1);
Assert.assertNull(pair.read2);
Assert.assertEquals("mapped_frag_a", pair.read1.getReadName());
pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.read1);
Assert.assertNull(pair.read2);
Assert.assertEquals("mapped_frag_b", pair.read1.getReadName());
pair = QuerySortedReadPairIteratorUtil.getNextReadPair(iterator);
Assert.assertNull(pair);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:24,代码来源:QuerySortedReadPairIteratorUtilTest.java
示例11: ReadStateManager
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
public ReadStateManager(final Iterator<GATKRead> source,
final List<String> samples,
final LIBSDownsamplingInfo info,
final boolean keepSubmittedReads,
final SAMFileHeader header) {
Utils.nonNull(source, "source");
Utils.nonNull(samples, "samples");
Utils.nonNull(info, "downsampling info");
Utils.nonNull(header, "header");
this.samples = samples;
this.iterator = new PeekableIterator<>(source);
this.keepSubmittedReads = keepSubmittedReads;
this.submittedReads = new LinkedList<>();
for (final String sample : samples) {
// because this is a linked hash map the order of iteration will be in sample order
readStatesBySample.put(sample, new PerSampleReadStateManager(info));
}
samplePartitioner = new SamplePartitioner(info, samples, header);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:ReadStateManager.java
示例12: AllLocusIterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
* @param interval The single interval over whose loci we'll be iterating
* @param nestedLocusIterator Provider of AlignmentContexts that may lie within the interval. Must return AlignmentContexts
* that are on the same contig as the provided interval.
*/
public AllLocusIterator(final SimpleInterval interval, final Iterator<AlignmentContext> nestedLocusIterator) {
Utils.nonNull(interval);
Utils.nonNull(nestedLocusIterator);
this.nestedLocusIterator = new PeekableIterator<>(nestedLocusIterator);
this.interval = interval;
this.currentPosition = interval.getStart();
// Sanity check:
if ( this.nestedLocusIterator.peek() != null && ! this.nestedLocusIterator.peek().getContig().equals(interval.getContig()) ) {
throw new IllegalArgumentException("Locus iterator must be over the same contig as the interval provided");
}
nextPileup = advance();
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:21,代码来源:AllLocusIterator.java
示例13: MultiHitAlignedReadIterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
*
* @param querynameOrderIterator
* @param primaryAlignmentSelectionStrategy Algorithm for selecting primary alignment when it is not clear from
* the input what should be primary.
*/
MultiHitAlignedReadIterator(final CloseableIterator<SAMRecord> querynameOrderIterator,
final PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy) {
this.primaryAlignmentSelectionStrategy = primaryAlignmentSelectionStrategy;
peekIterator = new PeekableIterator<>(new FilteringSamIterator(querynameOrderIterator,
new SamRecordFilter() {
// Filter unmapped reads.
@Override
public boolean filterOut(final SAMRecord record) {
return record.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(record.getCigar());
}
@Override
public boolean filterOut(final SAMRecord first, final SAMRecord second) {
return ((first.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(first.getCigar()))
&& (second.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(second.getCigar())));
}
}));
advance();
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:27,代码来源:MultiHitAlignedReadIterator.java
示例14: PeekVCF
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
PeekVCF(final String uri) throws IOException {
this.uri = uri;
if(StringUtil.isBlank(VCFMerge2.this.regionStr))
{
this.reader = new VCFFileReader(new File(uri),false);
this.header = this.reader.getFileHeader();
this.iter0 = this.reader.iterator();
}
else
{
this.reader = new VCFFileReader(new File(uri),true);
this.header = this.reader.getFileHeader();
final IntervalParser intervalParser=new IntervalParser(this.header.getSequenceDictionary());
intervalParser.setContigNameIsWholeContig(true);
final Interval rgn = intervalParser.parse(VCFMerge2.this.regionStr);
this.iter0 = this.reader.query(rgn.getContig(), rgn.getStart(), rgn.getEnd());
}
this.iter = new PeekableIterator<>(this.iter0);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:20,代码来源:VCFMerge2.java
示例15: MergingPileupElementIterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
public MergingPileupElementIterator(PerSamplePileupElementTracker<PE> tracker) {
perSampleIterators = new PriorityQueue<PeekableIterator<PE>>(Math.max(1,tracker.getSamples().size()),new PileupElementIteratorComparator());
for(final String sample: tracker.getSamples()) {
PileupElementTracker<PE> trackerPerSample = tracker.getElements(sample);
if(trackerPerSample.size() != 0)
perSampleIterators.add(new PeekableIterator<PE>(trackerPerSample.iterator()));
}
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:9,代码来源:MergingPileupElementIterator.java
示例16: next
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
public PE next() {
PeekableIterator<PE> currentIterator = perSampleIterators.remove();
PE current = currentIterator.next();
if(currentIterator.hasNext())
perSampleIterators.add(currentIterator);
return current;
}
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:8,代码来源:MergingPileupElementIterator.java
示例17: fillBlocksFromFile
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
private void fillBlocksFromFile(String bedGraphPath, String bedGraphIndexPath, Track<Wig> track,
String chromosomeName) throws IOException {
String realChrName = fetchRealChrName(bedGraphIndexPath, chromosomeName);
try (PeekableIterator<BedGraphFeature> bedGraphFeatureIterator = new PeekableIterator<>(
new BedGraphReader(bedGraphPath, bedGraphIndexPath)
.query(realChrName, track.getStartIndex(), track.getEndIndex())
)) {
for (Wig trackBlock : track.getBlocks()) {
float score = getScoreForBounds(
bedGraphFeatureIterator, track.getStartIndex(), trackBlock.getEndIndex()
);
trackBlock.setValue(score);
}
}
}
开发者ID:epam,项目名称:NGB,代码行数:16,代码来源:BedGraphProcessor.java
示例18: fetchByReadName
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
/**
* Generates a list by consuming from the iterator in order starting with the first available
* read and continuing while subsequent reads share the same read name. If there are no reads
* remaining returns an empty list.
*/
private List<SAMRecord> fetchByReadName(final PeekableIterator<SAMRecord> iterator) {
final List<SAMRecord> out = new ArrayList<>();
if (iterator.hasNext()) {
final SAMRecord first = iterator.next();
out.add(first);
while (iterator.hasNext() && iterator.peek().getReadName().equals(first.getReadName())) {
out.add(iterator.next());
}
}
return out;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:20,代码来源:RevertSam.java
示例19: PairedVariantSubContextIterator
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
public PairedVariantSubContextIterator(final Iterator<VariantContext> leftIterator, final String leftSample,
final Iterator<VariantContext> rightIterator, final String rightSample,
final SAMSequenceDictionary dict) {
this.leftIterator = new PeekableIterator<>(leftIterator);
this.leftSample = leftSample;
this.rightIterator = new PeekableIterator<>(rightIterator);
this.rightSample = rightSample;
this.comparator = new VariantContextComparator(dict);
}
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:PairedVariantSubContextIterator.java
示例20: advance
import htsjdk.samtools.util.PeekableIterator; //导入依赖的package包/类
@Override
protected T advance() {
T smallest= null;
int smallest_index=-1;
int i=0;
while(i< this.buffer.size())
{
final PeekableIterator<T> delegate = this.buffer.get(i);
if(!delegate.hasNext())
{
CloserUtil.close(delegate);
this.buffer.remove(i);
}
else
{
final T item = delegate.peek();
if(smallest==null || this.comparator.compare(item, smallest)<0)
{
smallest = item;
smallest_index = i;
}
i++;
}
}
if(smallest_index!=-1)
{
this.buffer.get(smallest_index).next();//consumme
if(lastForChecking!=null && this.comparator.compare(smallest, lastForChecking)<0)
{
throw new IllegalStateException("Data are not ordered... got "+ smallest_index+" after "+lastForChecking);
}
lastForChecking = smallest;
return smallest;
}
return null;
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:37,代码来源:MergingIterator.java
注:本文中的htsjdk.samtools.util.PeekableIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论