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


Java SamReaderFactory.validationStringency方法代码示例

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


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

示例1: setSamSeqDictFromBam

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
private boolean setSamSeqDictFromBam(String bamfile) {

		/*  ------------------------------------------------------ */
		/* This chunk prepares SamReader from local bam            */
		SamReaderFactory srf=SamReaderFactory.make();
		srf.validationStringency(ValidationStringency.SILENT);
		SamReader samReader;
		samReader= srf.open(new File(bamfile));
		/*  ------------------------------------------------------ */
		
		SAMSequenceDictionary seqDict = samReader.getFileHeader().getSequenceDictionary();
		if(seqDict != null && !seqDict.isEmpty()){
			this.setSamSeqDictSource(new File(bamfile).getAbsolutePath());
			this.setSamSeqDict(seqDict);
			return true;
		}
		return false;
	}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:19,代码来源:GenomicCoords.java

示例2: getAlignedReadCount

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
public static long getAlignedReadCount(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));
		}
		/*  ------------------------------------------------------ */

		List<SAMSequenceRecord> sequences = samReader.getFileHeader().getSequenceDictionary().getSequences();
		long alnCount= 0;
		for(SAMSequenceRecord x : sequences){
			alnCount += samReader.indexing().getIndex().getMetaData(x.getSequenceIndex()).getAlignedRecordCount();
		}
		samReader.close();
		return alnCount;
    }
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:26,代码来源:Utils.java

示例3: bamHasIndex

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的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

示例4: readSAMHeaderFrom

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/** Does not close the stream. */
public static SAMFileHeader readSAMHeaderFrom(
	final InputStream in, final Configuration conf)
{
	final ValidationStringency
		stringency = getValidationStringency(conf);
	SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
			.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
			.setUseAsyncIo(false);
	if (stringency != null) {
		readerFactory.validationStringency(stringency);
	}

	final ReferenceSource refSource = getReferenceSource(conf);
	if (null != refSource) {
		readerFactory.referenceSource(refSource);
	}
	return readerFactory.open(SamInputResource.of(in)).getFileHeader();
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:20,代码来源:SAMHeaderReader.java

示例5: 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

示例6: countReadsInWindow

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/**
 * Count reads in interval using the given filters.
 * @param bam
 * @param gc
 * @param filters List of filters to apply
 * @return
 * @throws MalformedURLException 
 */
public static long countReadsInWindow(String bam, GenomicCoords gc, List<SamRecordFilter> filters) throws MalformedURLException {

	/*  ------------------------------------------------------ */
	/* 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 = srf.open(SamInputResource.of(new URL(bam)).index(new URL(bam + ".bai")));
	} else {
		samReader= srf.open(new File(bam));
	}
	/*  ------------------------------------------------------ */
	
	long cnt= 0;
	
	Iterator<SAMRecord> sam= samReader.query(gc.getChrom(), gc.getFrom(), gc.getTo(), false);
	AggregateFilter aggregateFilter= new AggregateFilter(filters);
	while(sam.hasNext()){
		SAMRecord rec= sam.next();
		if( !aggregateFilter.filterOut(rec) ){
			cnt++;
		}
	}
	try {
		samReader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return cnt;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:41,代码来源:Utils.java

示例7: getSamReader

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/** Prepare SamReader from local bam or URL bam */
public static SamReader getSamReader(String workFilename) throws MalformedURLException {
	UrlValidator urlValidator = new UrlValidator();
	SamReaderFactory srf=SamReaderFactory.make();
	srf.validationStringency(ValidationStringency.SILENT);
	SamReader samReader;
	if(urlValidator.isValid(workFilename)){
		samReader = srf.open(SamInputResource.of(new URL(workFilename)).index(new URL(workFilename + ".bai")));
	} else {
		samReader= srf.open(new File(workFilename));
	}
	return samReader;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:14,代码来源:Utils.java

示例8: sortAndIndexSamOrBam

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/** Sort and index input sam or bam.
 * @throws IOException 
 * */
public static void sortAndIndexSamOrBam(String inSamOrBam, String sortedBam, boolean deleteOnExit) 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(inSamOrBam)){
		samReader = SamReaderFactory.makeDefault().open(SamInputResource.of(new URL(inSamOrBam)));
	} else {
		samReader= srf.open(new File(inSamOrBam));
	}
	/*  ------------------------------------------------------ */
	
	samReader.getFileHeader().setSortOrder(SortOrder.coordinate);
	
	File out= new File(sortedBam);
	if(deleteOnExit){
		out.deleteOnExit();
		File idx= new File(out.getAbsolutePath().replaceAll("\\.bam$", "") + ".bai");
		idx.deleteOnExit();
	}
	
	SAMFileWriter outputSam= new SAMFileWriterFactory()
			.setCreateIndex(true)
			.makeSAMOrBAMWriter(samReader.getFileHeader(), false, out);

	for (final SAMRecord samRecord : samReader) {
		outputSam.addAlignment(samRecord);
       }
	samReader.close();
	outputSam.close();
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:38,代码来源:Utils.java

示例9: doWork

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
/**
 * Do the work after command line has been parsed.
 * RuntimeException may be thrown by this method, and are reported appropriately.
 *
 * @return program exit status.
 */
@Override
protected int doWork() {
    IOUtil.assertFileIsReadable(INPUT);
    IOUtil.assertFileIsWritable(OUTPUT);
    final SamReaderFactory factory = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE);
    if (VALIDATION_STRINGENCY == ValidationStringency.STRICT) {
        factory.validationStringency(ValidationStringency.LENIENT);
    }
    final SamReader reader = factory.open(INPUT);
    final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(reader.getFileHeader(), true, OUTPUT);
    final CloseableIterator<SAMRecord> it = reader.iterator();
    final ProgressLogger progress = new ProgressLogger(Log.getInstance(CleanSam.class));

    // If the read (or its mate) maps off the end of the alignment, clip it
    while (it.hasNext()) {
        final SAMRecord rec = it.next();

        // If the read (or its mate) maps off the end of the alignment, clip it
        AbstractAlignmentMerger.createNewCigarsIfMapsOffEndOfReference(rec);

        // check the read's mapping quality
        if (rec.getReadUnmappedFlag() && 0 != rec.getMappingQuality()) {
            rec.setMappingQuality(0);
        }

        writer.addAlignment(rec);
        progress.record(rec);
    }

    writer.close();
    it.close();
    CloserUtil.close(reader);
    return 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:41,代码来源:CleanSam.java

示例10: createSamReader

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
private SamReader createSamReader(SeekableStream in, SeekableStream inIndex,
		ValidationStringency stringency) {
	SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
			.setOption(SamReaderFactory.Option.CACHE_FILE_BASED_INDEXES, true)
			.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
			.setUseAsyncIo(false);
	if (stringency != null) {
		readerFactory.validationStringency(stringency);
	}
	SamInputResource resource = SamInputResource.of(in);
	if (inIndex != null) {
		resource.index(inIndex);
	}
	return readerFactory.open(resource);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:16,代码来源:BAMRecordReader.java

示例11: createSamReader

import htsjdk.samtools.SamReaderFactory; //导入方法依赖的package包/类
private SamReader createSamReader(InputStream in, ValidationStringency stringency) {
	SamReaderFactory readerFactory = SamReaderFactory.makeDefault()
			.setOption(SamReaderFactory.Option.EAGERLY_DECODE, false)
			.setUseAsyncIo(false);
	if (stringency != null) {
		readerFactory.validationStringency(stringency);
	}
	return readerFactory.open(SamInputResource.of(in));
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:10,代码来源:SAMRecordReader.java

示例12: 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

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