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


Java SamReaderFactory.makeDefault方法代码示例

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


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

示例1: open

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/**
 * A method that creates a SamReader object that's passed on to the HTSJDK.
 * Each time someone tries to open a SamReader on an URL,
 * HTSJDK checks if there's a custom reader factory and if it's there, this method is called.
 *
 * @param url target file URL
 * @return A SamReader object on a specified file URL
 */
@Override
public SamReader open(URL url) {
    PerformanceMonitor.start();
    AmazonS3URI amazonURI = new AmazonS3URI(url.toString());
    S3Client client = new S3Client();
    S3InputStreamFactory streamFactory = new S3InputStreamFactory(client);

    //download index file if is possible, and then start download .bam file
    final Optional<SeekableStream> indexStream;
    try {
        IndexLoader loader = new IndexLoader(client);
        indexStream = loader.loadIndex(amazonURI);
    } catch (IOException e) {
        throw new RuntimeIOException(e.getMessage() + " failed to download index", e);
    }

    SeekableStream stream = new S3SeekableStream(amazonURI, client, streamFactory);
    SamReaderFactory factory = SamReaderFactory.makeDefault();
    SamInputResource inputResource = SamInputResource.of(stream);

    indexStream.ifPresent(inputResource::index);

    return factory.open(inputResource);
}
 
开发者ID:epam,项目名称:htsjdk-s3-plugin,代码行数:33,代码来源:S3ReaderFactory.java

示例2: getDuplicateCountForBam

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
private static int getDuplicateCountForBam(final File bam, final File referenceFile) throws IOException {
    int duplicateCount = 0;
    final SamReaderFactory factory = SamReaderFactory.makeDefault();
    if(referenceFile != null) {
        factory.referenceSequence(referenceFile);
    }
    try ( final SamReader reader = factory.open(bam) ) {
        for ( SAMRecord read : reader ) {
            if ( read.getDuplicateReadFlag() ) {
                ++duplicateCount;
            }
        }
    }

    return duplicateCount;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:17,代码来源:UnmarkDuplicatesIntegrationTest.java

示例3: reOpen

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Override
public BamFile reOpen() throws IOException {
	final String url=this.getSource();
	final SamReaderFactory srf = SamReaderFactory.makeDefault();
	srf.validationStringency(ValidationStringency.LENIENT);
	final SamInputResource sir;
	if(IOUtil.isUrl(url))
		{
		sir = SamInputResource.of(new URL(url));
		if(!this.indexFile.isPresent()) throw new IOException("Boum");
		sir.index(this.indexFile.get());
		}
	else
		{
		sir = SamInputResource.of(new File(url));
		}
	
	final BamFile bf = new BamFile(url,srf.open(sir),this.indexFile);
	bf.delete_index_on_close=false;
	return bf;
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:22,代码来源:BamFile.java

示例4: testReadFilters

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Test(dataProvider = "readFilterTestData")
public void testReadFilters(
        final String input,
        final String reference,
        final String extOut,
        final List<String> inputArgs,
        final int expectedCount) throws IOException
{
    final File outFile = createTempFile("testReadFilter", extOut);

    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("-I"); args.add(new File(TEST_DATA_DIR, input).getAbsolutePath());
    args.add("-O"); args.add(outFile.getAbsolutePath());
    if ( reference != null ) {
        args.add("-R"); args.add(new File(TEST_DATA_DIR, reference).getAbsolutePath());
    }
    for (final String filter : inputArgs) {
        args.add(filter);
    }

    runCommandLine(args);


    SamReaderFactory factory = SamReaderFactory.makeDefault();
    if (reference != null) {
        factory = factory.referenceSequence(new File(TEST_DATA_DIR, reference));
    }
    int count = 0;
    try (final SamReader reader = factory.open(outFile)) {
        Iterator<SAMRecord> it = reader.iterator();
        while (it.hasNext()) {
            SAMRecord rec = it.next();
            count++;
        }
    }
    Assert.assertEquals(count, expectedCount);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:38,代码来源:PrintReadsIntegrationTest.java

示例5: testReadFilters

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Test(dataProviderClass = org.broadinstitute.hellbender.tools.PrintReadsIntegrationTest.class, dataProvider = "readFilterTestData", groups = "spark")
public void testReadFilters(
        final String input,
        final String reference,
        final String extOut,
        final List<String> inputArgs,
        final int expectedCount) throws IOException
{
    final File outFile = createTempFile("testReadFilter", extOut);

    final ArgumentsBuilder args = new ArgumentsBuilder();
    args.add("-I"); args.add(new File(TEST_DATA_DIR, input).getAbsolutePath());
    args.add("-O"); args.add(outFile.getAbsolutePath());
    if ( reference != null ) {
        args.add("-R"); args.add(new File(TEST_DATA_DIR, reference).getAbsolutePath());
    }
    for (final String filter : inputArgs) {
        args.add(filter);
    }

    runCommandLine(args);


    SamReaderFactory factory = SamReaderFactory.makeDefault();
    if (reference != null) {
        factory = factory.referenceSequence(new File(TEST_DATA_DIR, reference));
    }
    int count = 0;
    try (final SamReader reader = factory.open(outFile)) {
        Iterator<SAMRecord> it = reader.iterator();
        while (it.hasNext()) {
            SAMRecord rec = it.next();
            count++;
        }
    }
    Assert.assertEquals(count, expectedCount);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:38,代码来源:PrintReadsSparkIntegrationTest.java

示例6: ReadReaderFactory

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/** Creates a default factory. */
public ReadReaderFactory() {
    this.samFactory = SamReaderFactory.makeDefault();

}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:6,代码来源:ReadReaderFactory.java

示例7: exec

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
@Exec
public void exec() throws IOException, CommandArgumentException {
    if (filename == null) {
        throw new CommandArgumentException("You must specify an input BAM filename!");
    }
    SamReaderFactory readerFactory = SamReaderFactory.makeDefault();
    if (lenient) {
        readerFactory.validationStringency(ValidationStringency.LENIENT);
    } else if (silent) {
        readerFactory.validationStringency(ValidationStringency.SILENT);
    }

    SamReader reader = null;
    String name;
    FileChannel channel = null;
    if (filename.equals("-")) {
        reader = readerFactory.open(SamInputResource.of(System.in));
        name = "<stdin>";
    } else {
        File f = new File(filename);
        FileInputStream fis = new FileInputStream(f);
        channel = fis.getChannel();
        reader = readerFactory.open(SamInputResource.of(fis));
        name = f.getName();
    }

    Set<String> readNames = new HashSet<String>();

    Iterator<SAMRecord> it = ProgressUtils.getIterator(name, reader.iterator(), (channel == null)? null : new FileChannelStats(channel), new ProgressMessage<SAMRecord>() {
        long i = 0;
        @Override
        public String msg(SAMRecord current) {
            i++;
            return i+" "+current.getReadName();
        }}, new CloseableFinalizer<SAMRecord>());

    System.err.print("Reading file...");
    
    while (it.hasNext()) {
        readNames.add(it.next().getReadName());
    }

    System.err.println(" done");
    
    reader.close();
    List<String> readNameList = new ArrayList<String>(readNames);
    readNames.clear();
    
    for (int i=1; i<=numberOfSamplings; i++) {
        System.err.println("Generating list #"+i+"...");
        Random rdm = new Random();
        
        Set<String> keptReads = new HashSet<String>();
        int j=0;
        while (j<sampleSize) {
            int idx = rdm.nextInt(readNameList.size());
            if (!keptReads.contains(readNameList.get(idx))) {
                keptReads.add(readNameList.get(idx));
                j++;
            }
        }
        
        OutputStream os = new FileOutputStream(outputFilename+"."+i+".txt");
        for (String readName: keptReads) {
            os.write((readName+"\n").getBytes());
        }
        os.close();            
    }
}
 
开发者ID:compgen-io,项目名称:ngsutilsj,代码行数:70,代码来源:BamSampleReads.java

示例8: newInstance

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
public static BamFile newInstance(final File f) throws IOException {
IOUtil.assertFileIsReadable(f);
final SamReaderFactory srf = SamReaderFactory.makeDefault();
srf.validationStringency(ValidationStringency.LENIENT);
return new BamFile(f.getAbsolutePath(),srf.open(f),Optional.empty());
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:7,代码来源:BamFile.java


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