当前位置: 首页>>代码示例>>Java>>正文


Java SamReader.hasIndex方法代码示例

本文整理汇总了Java中htsjdk.samtools.SamReader.hasIndex方法的典型用法代码示例。如果您正苦于以下问题:Java SamReader.hasIndex方法的具体用法?Java SamReader.hasIndex怎么用?Java SamReader.hasIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.samtools.SamReader的用法示例。


在下文中一共展示了SamReader.hasIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bamHasIndex

import htsjdk.samtools.SamReader; //导入方法依赖的package包/类
public static boolean bamHasIndex(String bam) throws IOException{

		/*  ------------------------------------------------------ */
		/* This chunk prepares SamReader from local bam or URL bam */
		UrlValidator urlValidator = new UrlValidator();
		SamReaderFactory srf=SamReaderFactory.make();
		srf.validationStringency(ValidationStringency.SILENT);
		SamReader samReader;
		if(urlValidator.isValid(bam)){
			samReader = SamReaderFactory.makeDefault().open(
					SamInputResource.of(new URL(bam)).index(new URL(bam + ".bai"))
			);
		} else {
			samReader= srf.open(new File(bam));
		}
		/*  ------------------------------------------------------ */

		// SamReaderFactory srf=SamReaderFactory.make();
		// srf.validationStringency(ValidationStringency.SILENT);
		// SamReader samReader = srf.open(new File(bam));
		boolean hasIndex= samReader.hasIndex();
		samReader.close();
		return hasIndex;
		
	}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:26,代码来源:Utils.java

示例2: openFile

import htsjdk.samtools.SamReader; //导入方法依赖的package包/类
void openFile() throws IOException {
  LOG.info("Processing shard " + shard);
  final SamReader reader = BAMIO.openBAM(storageClient, shard.file,
      options.getStringency());
  iterator = null;
  if (reader.hasIndex() && reader.indexing() != null) {
    if (filter == Filter.UNMAPPED_ONLY) {
      LOG.info("Processing unmapped");
      iterator = reader.queryUnmapped();
    } else if (shard.span != null) {
      LOG.info("Processing span for " + shard.contig);
      iterator = reader.indexing().iterator(shard.span);
    } else if (shard.contig.referenceName != null && !shard.contig.referenceName.isEmpty()) {
      LOG.info("Processing all bases for " + shard.contig);
      iterator = reader.query(shard.contig.referenceName, (int) shard.contig.start,
          (int) shard.contig.end, false);
    }
  }
  if (iterator == null) {
    LOG.info("Processing all reads");
    iterator = reader.iterator();
  }
}
 
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:24,代码来源:Reader.java

示例3: doWork

import htsjdk.samtools.SamReader; //导入方法依赖的package包/类
protected int doWork() {
    IOUtil.assertFileIsReadable(INPUT);
    IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE);
    IOUtil.assertFileIsWritable(OUTPUT);

    final SamReader in = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(INPUT);

    final ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE);
    final SAMSequenceDictionary refDict = reference.getSequenceDictionary();

    if (refDict == null) {
        log.error("No reference sequence dictionary found. Aborting.  You can create a sequence dictionary for the reference fasta using CreateSequenceDictionary.jar.");
        CloserUtil.close(in);
        return 1;
    }

    printDictionary("SAM/BAM file", in.getFileHeader().getSequenceDictionary());
    printDictionary("Reference", refDict);
    final Map<Integer, Integer> newOrder = buildSequenceDictionaryMap(refDict, in.getFileHeader().getSequenceDictionary());

    // has to be after we create the newOrder
    final SAMFileHeader outHeader = in.getFileHeader().clone();
    outHeader.setSequenceDictionary(refDict);

    log.info("Writing reads...");
    if (in.hasIndex()) {
        try( final SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outHeader, true, OUTPUT)) {

            // write the reads in contig order
            for (final SAMSequenceRecord contig : refDict.getSequences()) {
                final SAMRecordIterator it = in.query(contig.getSequenceName(), 0, 0, false);
                writeReads(out, it, newOrder, contig.getSequenceName());
            }
            // don't forget the unmapped reads
            writeReads(out, in.queryUnmapped(), newOrder, "unmapped");
        }
    } else {
        try (final SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outHeader, false, OUTPUT)) {
            writeReads(out, in.iterator(), newOrder, "All reads");
        }
    }

    // cleanup
    CloserUtil.close(in);
    return 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:47,代码来源:ReorderSam.java

示例4: SamLocusIterator

import htsjdk.samtools.SamReader; //导入方法依赖的package包/类
/**
 * Prepare to iterate through the given SAM records, skipping non-primary alignments.  Do not use
 * BAM index even if available.
 *
 * @param intervalList Either the list of desired intervals, or null.  Note that if an intervalList is
 *                     passed in that is not coordinate sorted, it will eventually be coordinated sorted by this class.
 */
public SamLocusIterator(final SamReader samReader, final IntervalList intervalList) {
    this(samReader, intervalList, samReader.hasIndex());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:11,代码来源:SamLocusIterator.java


注:本文中的htsjdk.samtools.SamReader.hasIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。