本文整理汇总了Java中htsjdk.tribble.CloseableTribbleIterator类的典型用法代码示例。如果您正苦于以下问题:Java CloseableTribbleIterator类的具体用法?Java CloseableTribbleIterator怎么用?Java CloseableTribbleIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloseableTribbleIterator类属于htsjdk.tribble包,在下文中一共展示了CloseableTribbleIterator类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkFileSorted
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
public static <F extends Feature, S> int checkFileSorted(File ofile, final FeatureCodec<F, S> codec)
throws IOException {
int numlines = 0;
AbstractFeatureReader<F, S> reader =
AbstractFeatureReader.getFeatureReader(ofile.getAbsolutePath(), codec, false);
CloseableTribbleIterator<F> iterator = reader.iterator();
final Map<String, Feature> visitedChromos = new HashMap<>(40);
Feature lastFeature = null;
while (iterator.hasNext()) {
Feature currentFeature = iterator.next();
numlines++;
checkSorted(ofile, lastFeature, currentFeature, visitedChromos);
lastFeature = currentFeature;
}
return numlines;
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:22,代码来源:SortTest.java
示例2: query
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
public Iterator<Feature> query(String chr, int start, int end) throws IOException {
// Tribble iterators must be closed, so we need to copy the features and insure closure before exiting.
CloseableTribbleIterator<Feature> iter = null;
try {
iter = wrappedReader.query(chr, start, end);
List<Feature> featureList = new ArrayList<Feature>();
while (iter.hasNext()) {
Feature f = iter.next();
if (f.getStart() > end) {
break;
} else if (f.getEnd() < start) {
continue;
} else {
featureList.add(f);
}
}
return featureList.iterator();
} finally {
if(iter != null) iter.close();
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:TribbleReaderWrapper.java
示例3: queryRaw
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
protected Iterator<Feature> queryRaw(String chr, int start, int end) throws IOException {
// Tribble iterators must be closed, so we need to copy the features and insure closure before exiting.
CloseableTribbleIterator<Feature> iter = null;
try {
iter = tribbleFeatureReader.query(chr, start, end);
List<Feature> featureList = new ArrayList<Feature>();
while (iter.hasNext()) {
Feature f = iter.next();
if (f.getStart() > end) {
break;
} else if (f.getEnd() < start) {
continue;
} else {
featureList.add(f);
}
}
return featureList.iterator();
} finally {
if (iter != null) iter.close();
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:CachingFeatureReader.java
示例4: query
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
public CloseableTribbleIterator query(String chr, int start, int end) throws IOException {
int dasStart = start + 1;
int dasEnd = end;
if (isValid && !chr.equals("All")) {
WaitCursorManager.CursorToken token = WaitCursorManager.showWaitCursor();
try {
groupFeatureCache.clear();
List<Feature> features = readFeatures(chr, dasStart, dasEnd);
if (features.size() < 1) {
return EMPTY__ITERATOR;
}
return new WrappedIterator(features.iterator());
} finally {
groupFeatureCache.clear();
WaitCursorManager.removeWaitCursor(token);
}
}
return EMPTY__ITERATOR;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:22,代码来源:DASFeatureSource.java
示例5: query
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
public CloseableTribbleIterator<T> query(String chr, int start, int end) throws IOException {
if (closed) {
throw new IOException("Reader already closed");
}
return new CachedFeatureIterator<T>(cachedFeatures.stream()
.filter(f -> f.getContig().equals(chr) &&
(f.getStart() <= end && f.getEnd() >= start))
.collect(Collectors.toList()));
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:12,代码来源:CachedFeatureReader.java
示例6: iterator
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
public CloseableTribbleIterator<T> iterator() throws IOException {
if (closed) {
throw new IOException("Reader already closed");
}
return new CachedFeatureIterator<>(cachedFeatures);
}
开发者ID:react-dev26,项目名称:NGB-master,代码行数:9,代码来源:CachedFeatureReader.java
示例7: query
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
public CloseableTribbleIterator<VariantContext> query(final String chr, final int start, final int end) {
final SimpleInterval queryInterval = new SimpleInterval(chr, start, end);
if( !interval.equals(queryInterval)){
throw new GATKException("Cannot call query with different interval, expected:" + this.interval + " queried with: " + queryInterval);
}
if( query != null ){
final CloseableTribbleIterator<VariantContext> tmp = query;
query = null;
return tmp;
} else {
throw new GATKException("Cannot call query twice on this wrapper.");
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:15,代码来源:GenomicsDBImport.java
示例8: getExonForVariant
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
private static GencodeGtfExonFeature getExonForVariant( final CloseableTribbleIterator<GencodeGtfFeature> gtfFeatureIterator,
final SimpleInterval variantLocation ) {
final Optional<GencodeGtfExonFeature> exonOption = gtfFeatureIterator.stream()
.map( f -> ((GencodeGtfGeneFeature) f))
.flatMap(g -> g.getTranscripts().stream())
.flatMap(t -> t.getExons().stream())
.filter( x -> x.overlaps(variantLocation) )
.findFirst();
return exonOption.orElseThrow( () -> new GATKException("Could not get an exon associated with this variant's interval: " + variantLocation.toString()) );
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:13,代码来源:GencodeFuncotationFactoryUnitTest.java
示例9: testRenamingSamples
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Test(dataProvider = "getRenameCombinations")
public void testRenamingSamples(final Map<String, String> renamingMap, final int threads, final int batchSize) throws IOException {
final LinkedHashMap<String, String> sampleMap = new LinkedHashMap<>(renamingMap);
sampleMap.replaceAll( (newSampleName, originalSampleName)-> createInputVCF(originalSampleName).getAbsolutePath());
final File sampleMapFile = getSampleMapFile(sampleMap);
final String workspace = createTempDir("workspace").getAbsolutePath();
Files.delete(Paths.get(workspace));
final ArgumentsBuilder args = new ArgumentsBuilder()
.addArgument(GenomicsDBImport.SAMPLE_NAME_MAP_LONG_NAME, sampleMapFile.getAbsolutePath())
.addArgument(GenomicsDBImport.WORKSPACE_ARG_LONG_NAME, new File(workspace).getAbsolutePath())
.addArgument(GenomicsDBImport.VCF_INITIALIZER_THREADS_LONG_NAME, String.valueOf(threads))
.addArgument(GenomicsDBImport.BATCHSIZE_ARG_LONG_NAME, String.valueOf(batchSize))
.addArgument("L", IntervalUtils.locatableToString(INTERVAL));
runCommandLine(args);
final Set<String> expectedSampleNames = sampleMap.keySet();
try(final GenomicsDBFeatureReader<VariantContext, PositionalBufferedStream> reader = getGenomicsDBFeatureReader(workspace, b37_reference_20_21)) {
final CloseableTribbleIterator<VariantContext> iterator = reader.iterator();
Assert.assertTrue(iterator.hasNext(), "expected to see a variant");
Assert.assertTrue(expectedSampleNames.size() > 0);
Assert.assertEquals(expectedSampleNames.size(), renamingMap.size());
iterator.forEachRemaining(vc -> {
Assert.assertEquals(vc.getSampleNames(), expectedSampleNames);
expectedSampleNames.forEach( sample -> {
Assert.assertEquals(vc.getGenotype(sample).getAnyAttribute(SAMPLE_NAME_KEY), renamingMap.get(sample));
Assert.assertEquals(vc.getGenotype(sample).getAnyAttribute(ANOTHER_ATTRIBUTE_KEY), 10); //check another attribute just to make sure we're not mangling things
});
});
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:34,代码来源:GenomicsDBImportIntegrationTest.java
示例10: LongISLNDReadAlignmentMap
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
public LongISLNDReadAlignmentMap(final Collection<String> readAlignmentMapFiles) throws IOException {
for (final String readAlignmentMapFileName : readAlignmentMapFiles) {
log.info("Reading in read map from " + readAlignmentMapFileName);
final AbstractFeatureReader<BEDFeature, LineIterator> featureReader = AbstractFeatureReader.getFeatureReader(readAlignmentMapFileName, new BEDCodec(), false);
try {
final CloseableTribbleIterator<BEDFeature> featureIterator = featureReader.iterator();
while (featureIterator.hasNext()) {
final BEDFeature feature = featureIterator.next();
readAlignmentMap.put(feature.getName(), new LongISLNDReadMapRecord(feature).toReadMapRecord());
}
} finally {
featureReader.close();
}
}
}
开发者ID:bioinform,项目名称:varsim,代码行数:16,代码来源:LongISLNDReadAlignmentMap.java
示例11: iterator
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
public CloseableTribbleIterator iterator() throws IOException {
return null;
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:4,代码来源:DASFeatureSource.java
示例12: doWork
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
IOUtil.assertFileIsReadable(SEQUENCE_DICTIONARY);
IOUtil.assertFileIsWritable(OUTPUT);
try {
// create a new header that we will assign the dictionary provided by the SAMSequenceDictionaryExtractor to.
final SAMFileHeader header = new SAMFileHeader();
final SAMSequenceDictionary samSequenceDictionary = SAMSequenceDictionaryExtractor.extractDictionary(SEQUENCE_DICTIONARY.toPath());
header.setSequenceDictionary(samSequenceDictionary);
// set the sort order to be sorted by coordinate, which is actually done below
// by getting the .uniqued() intervals list before we write out the file
header.setSortOrder(SAMFileHeader.SortOrder.coordinate);
final IntervalList intervalList = new IntervalList(header);
/**
* NB: BED is zero-based, but a BEDCodec by default (since it is returns tribble Features) has an offset of one,
* so it returns 1-based starts. Ugh. Set to zero.
*/
final FeatureReader<BEDFeature> bedReader = AbstractFeatureReader.getFeatureReader(INPUT.getAbsolutePath(), new BEDCodec(BEDCodec.StartOffset.ZERO), false);
final CloseableTribbleIterator<BEDFeature> iterator = bedReader.iterator();
final ProgressLogger progressLogger = new ProgressLogger(LOG, (int) 1e6);
while (iterator.hasNext()) {
final BEDFeature bedFeature = iterator.next();
final String sequenceName = bedFeature.getContig();
/**
* NB: BED is zero-based, so we need to add one here to make it one-based. Please observe we set the start
* offset to zero when creating the BEDCodec.
*/
final int start = bedFeature.getStart() + 1;
/**
* NB: BED is 0-based OPEN (which, for the end is equivalent to 1-based closed).
*/
final int end = bedFeature.getEnd();
// NB: do not use an empty name within an interval
String name = bedFeature.getName();
if (name.isEmpty()) name = null;
final SAMSequenceRecord sequenceRecord = header.getSequenceDictionary().getSequence(sequenceName);
// Do some validation
if (null == sequenceRecord) {
throw new PicardException(String.format("Sequence '%s' was not found in the sequence dictionary", sequenceName));
} else if (start < 1) {
throw new PicardException(String.format("Start on sequence '%s' was less than one: %d", sequenceName, start));
} else if (sequenceRecord.getSequenceLength() < start) {
throw new PicardException(String.format("Start on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), start));
} else if (end < 1) {
throw new PicardException(String.format("End on sequence '%s' was less than one: %d", sequenceName, end));
} else if (sequenceRecord.getSequenceLength() < end) {
throw new PicardException(String.format("End on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), end));
} else if (end < start - 1) {
throw new PicardException(String.format("On sequence '%s', end < start-1: %d <= %d", sequenceName, end, start));
}
final boolean isNegativeStrand = bedFeature.getStrand() == Strand.NEGATIVE;
final Interval interval = new Interval(sequenceName, start, end, isNegativeStrand, name);
intervalList.add(interval);
progressLogger.record(sequenceName, start);
}
CloserUtil.close(bedReader);
// Sort and write the output
IntervalList out = intervalList;
if (SORT) out = out.sorted();
if (UNIQUE) out = out.uniqued();
out.write(OUTPUT);
} catch (final IOException e) {
throw new RuntimeException(e);
}
return 0;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:77,代码来源:BedToIntervalList.java
示例13: iterator
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Override
public CloseableTribbleIterator<VariantContext> iterator() {
throw new UnsupportedOperationException("iterator() not supported, this should not have been called and indicates an issue with GenomicsDB integration");
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:5,代码来源:GenomicsDBImport.java
示例14: testMuc16SnpCreateFuncotations
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Test (dataProvider = "provideMuc16SnpDataForGetVariantClassificationWithOutOfCdsData")
void testMuc16SnpCreateFuncotations(final int chromosomeNumber,
final int start,
final int end,
final GencodeFuncotation.VariantType expectedVariantType,
final String ref,
final String alt,
final GencodeFuncotation.VariantClassification expectedVariantClassification) {
final String contig = "chr" + Integer.toString(chromosomeNumber);
final SimpleInterval variantInterval = new SimpleInterval( contig, start, end );
final Allele refAllele = Allele.create(ref, true);
final Allele altAllele = Allele.create(alt);
final VariantContextBuilder variantContextBuilder = new VariantContextBuilder(
FuncotatorTestConstants.HG19_CHR19_REFERENCE_FILE_NAME,
contig,
start,
end,
Arrays.asList(refAllele, altAllele)
);
final VariantContext variantContext = variantContextBuilder.make();
// Get our gene feature iterator:
final CloseableTribbleIterator<GencodeGtfFeature> gtfFeatureIterator;
try {
gtfFeatureIterator = muc16FeatureReader.query(contig, start, end);
}
catch (final IOException ex) {
throw new GATKException("Could not finish the test!", ex);
}
// Get the gene.
// We know the first gene is the right one - the gene in question is the MUC16 gene:
final GencodeGtfGeneFeature gene = (GencodeGtfGeneFeature) gtfFeatureIterator.next();
final ReferenceContext referenceContext = new ReferenceContext(refDataSourceHg19Ch19, variantInterval );
// TODO: Make this an input argument:
final Set<String> requestedTranscriptIds = getValidTranscriptsForGene("MUC16");
// Create a factory for our funcotations:
try (final GencodeFuncotationFactory funcotationFactory = new GencodeFuncotationFactory(new File(FuncotatorTestConstants.MUC16_GENCODE_TRANSCRIPT_FASTA_FILE).toPath(), "VERSION", requestedTranscriptIds)) {
// Generate our funcotations:
final List<Feature> featureList = new ArrayList<>();
featureList.add( gene );
final List<Funcotation> funcotations = funcotationFactory.createFuncotations(variantContext, referenceContext, featureList);
// Make sure we get what we expected:
Assert.assertEquals(funcotations.size(), 1);
final GencodeFuncotation funcotation = (GencodeFuncotation)funcotations.get(0);
Assert.assertEquals(funcotation.getVariantClassification(), expectedVariantClassification);
Assert.assertEquals(funcotation.getVariantType(), expectedVariantType);
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:59,代码来源:GencodeFuncotationFactoryUnitTest.java
示例15: createNonBasicFuncotations
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
@Test(dataProvider = "provideForCreateNonBasicFuncotations")
void createNonBasicFuncotations(final int start, final int end) {
final String contig = "chr19";
final SimpleInterval variantInterval = new SimpleInterval( contig, start, end );
final Allele refAllele = Allele.create("C", true);
final Allele altAllele = Allele.create("G", false);
final VariantContextBuilder variantContextBuilder = new VariantContextBuilder(
FuncotatorTestConstants.HG19_CHR19_REFERENCE_FILE_NAME,
contig,
start,
end,
Arrays.asList(refAllele, altAllele)
);
final VariantContext variantContext = variantContextBuilder.make();
// Get our gene feature iterator:
final CloseableTribbleIterator<GencodeGtfFeature> gtfFeatureIterator;
try {
gtfFeatureIterator = muc16NonBasicFeatureReader.query(contig, start, end);
}
catch (final IOException ex) {
throw new GATKException("Could not finish the test!", ex);
}
// Get the gene.
// We know the first gene is the right one - the gene in question is the MUC16 gene:
final GencodeGtfGeneFeature gene = (GencodeGtfGeneFeature) gtfFeatureIterator.next();
final ReferenceContext referenceContext = new ReferenceContext(refDataSourceHg19Ch19, variantInterval );
// Create a factory for our funcotations:
try (final GencodeFuncotationFactory funcotationFactory = new GencodeFuncotationFactory(new File(FuncotatorTestConstants.MUC16_GENCODE_TRANSCRIPT_FASTA_FILE).toPath(), "VERSION")) {
// Generate our funcotations:
final List<Feature> featureList = new ArrayList<>();
featureList.add( gene );
final List<Funcotation> funcotations = funcotationFactory.createFuncotations(variantContext, referenceContext, featureList);
// Make sure we get what we expected:
Assert.assertEquals(funcotations.size(), 0);
}
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:46,代码来源:GencodeFuncotationFactoryUnitTest.java
示例16: iterator
import htsjdk.tribble.CloseableTribbleIterator; //导入依赖的package包/类
public CloseableTribbleIterator<VariantContext> iterator(String chrom,int start,int end)
throws IOException
{
if(this.reader==null) throw new IllegalStateException("Reader==null");
return this.reader.query(chrom, start, end);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:7,代码来源:TribbleVcfFileReader.java
注:本文中的htsjdk.tribble.CloseableTribbleIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论