• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BAMRecordCodec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中htsjdk.samtools.BAMRecordCodec的典型用法代码示例。如果您正苦于以下问题:Java BAMRecordCodec类的具体用法?Java BAMRecordCodec怎么用?Java BAMRecordCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: RevertSamSorter

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
RevertSamSorter(
        final boolean outputByReadGroup,
        final Map<String, SAMFileHeader> headerMap,
        final SAMFileHeader singleOutHeader,
        final int maxRecordsInRam) {

    this.outputByReadGroup = outputByReadGroup;
    if (outputByReadGroup) {
        for (final Map.Entry<String, SAMFileHeader> entry : headerMap.entrySet()) {
            final String readGroupId = entry.getKey();
            final SAMFileHeader outHeader = entry.getValue();
            final SortingCollection<SAMRecord> sorter = SortingCollection.newInstance(SAMRecord.class, new BAMRecordCodec(outHeader), new SAMRecordQueryNameComparator(), maxRecordsInRam);
            sorterMap.put(readGroupId, sorter);
        }
        singleSorter = null;
    } else {
        singleSorter = SortingCollection.newInstance(SAMRecord.class, new BAMRecordCodec(singleOutHeader), new SAMRecordQueryNameComparator(), maxRecordsInRam);
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:20,代码来源:RevertSam.java


示例2: write

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
@Override 
public void write(DataOutput out) throws IOException {
	// In theory, it shouldn't matter whether we give a header to
	// BAMRecordCodec or not, since the representation of an alignment in BAM
	// doesn't depend on the header data at all. Only its interpretation
	// does, and a simple read/write codec shouldn't really have anything to
	// say about that. (But in practice, it already does matter for decode(),
	// which is why LazyBAMRecordFactory exists.)
	final BAMRecordCodec codec = new BAMRecordCodec(record.getHeader());
	codec.setOutputStream(new DataOutputWrapper(out));
	codec.encode(record);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:13,代码来源:SamRecordWritable.java


示例3: init

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
private void init(
		OutputStream output, SAMFileHeader header, boolean writeHeader)
	throws IOException
{
	origOutput = output;

	compressedOut = new BlockCompressedOutputStream(origOutput, null);

	binaryCodec = new BinaryCodec(compressedOut);
	recordCodec = new BAMRecordCodec(header);
	recordCodec.setOutputStream(compressedOut);

	if (writeHeader)
		this.writeHeader(header);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:16,代码来源:BAMRecordWriter.java


示例4: BAMSplitGuesser

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
public BAMSplitGuesser(
		SeekableStream ss, InputStream headerStream, Configuration conf)
	throws IOException
{
	inFile = ss;

	header = SAMHeaderReader.readSAMHeaderFrom(headerStream, conf);
	referenceSequenceCount = header.getSequenceDictionary().size();

	bamCodec = new BAMRecordCodec(null, new LazyBAMRecordFactory());
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:12,代码来源:BAMSplitGuesser.java


示例5: write

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
@Override public void write(DataOutput out) throws IOException {
	// In theory, it shouldn't matter whether we give a header to
	// BAMRecordCodec or not, since the representation of an alignment in BAM
	// doesn't depend on the header data at all. Only its interpretation
	// does, and a simple read/write codec shouldn't really have anything to
	// say about that. (But in practice, it already does matter for decode(),
	// which is why LazyBAMRecordFactory exists.)
	final BAMRecordCodec codec = new BAMRecordCodec(record.getHeader());
	codec.setOutputStream(new DataOutputWrapper(out));
	codec.encode(record);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:12,代码来源:SAMRecordWritable.java


示例6: CramToBam_OBA_Function

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
CramToBam_OBA_Function(CramHeader header, ReferenceSource referenceSource) {
	this.header = header;
	parser = new ContainerParser(header.getSamFileHeader());
	f = new Cram2SamRecordFactory(header.getSamFileHeader());
	codec = new BAMRecordCodec(header.getSamFileHeader());
	n = new CramNormalizer(header.getSamFileHeader(), referenceSource);
	log.info("converter created");
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:9,代码来源:CramToBam_OBA_Function.java


示例7: toSAMRecord

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
private List<SAMRecord> toSAMRecord(BAMRecordView view, SAMFileHeader samHeader) {
	BAMRecordCodec bc = new BAMRecordCodec(samHeader);
	bc.setInputStream(new ByteArrayInputStream(view.buf, 0, view.start));
	List<SAMRecord> records = new ArrayList<SAMRecord>();
	SAMRecord record;
	while ((record = bc.decode()) != null) {
		records.add(record);
	}
	return records;
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:11,代码来源:BAMRecordViewTest.java


示例8: test1

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
@Test
public void test1() {
	BAMRecordView view = new BAMRecordView(new byte[1024]);
	view.setReadName("readName");
	view.setFlags(4);
	view.setRefID(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX);
	view.setAlignmentStart(SAMRecord.NO_ALIGNMENT_START);
	view.setMappingScore(SAMRecord.NO_MAPPING_QUALITY);
	view.setCigar(new Cigar());
	view.setMateRefID(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX);
	view.setMateAlStart(SAMRecord.NO_ALIGNMENT_START);
	view.setInsertSize(0);
	view.setBases("A".getBytes());
	view.setQualityScores(new byte[] { 0 });
	view.addTag(SAMTagUtil.getSingleton().AM, new byte[] { 'c', 0 }, 0, 1);
	view.finish();

	SAMFileHeader samHeader = new SAMFileHeader();

	BAMRecordCodec bc = new BAMRecordCodec(samHeader);
	bc.setInputStream(new ByteArrayInputStream(view.buf));
	SAMRecord record = bc.decode();
	assertThat(record.getReadName(), is("readName"));
	assertThat(record.getFlags(), is(4));
	assertThat(record.getReferenceIndex(), is(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX));
	assertThat(record.getAlignmentStart(), is(SAMRecord.NO_ALIGNMENT_START));
	assertThat(record.getMappingQuality(), is(SAMRecord.NO_MAPPING_QUALITY));
	assertThat(record.getCigar().getCigarElements().size(), is(0));
	assertThat(record.getMateReferenceIndex(), is(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX));
	assertThat(record.getMateAlignmentStart(), is(SAMRecord.NO_ALIGNMENT_START));
	assertThat(record.getInferredInsertSize(), is(0));
	assertThat(record.getReadString(), is("A"));
	assertThat(record.getBaseQualityString(), is("!"));

	Object amTag = record.getAttribute("AM");
	assertTrue(amTag instanceof Byte);
	Byte amValue = (Byte) amTag;
	assertThat(amValue, equalTo((byte) 0));
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:40,代码来源:BAMRecordViewTest.java


示例9: initialize

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
@Override
public void initialize(InputSplit spl, TaskAttemptContext ctx) throws IOException {
	// This method should only be called once (see Hadoop API). However,
	// there seems to be disagreement between implementations that call
	// initialize() and Hadoop-BAM's own code that relies on
	// {@link BAMInputFormat} to call initialize() when the reader is
	// created. Therefore we add this check for the time being.
	if (isInitialized)
		close();
	isInitialized = true;

	final Configuration conf = ContextUtil.getConfiguration(ctx);

	final FileVirtualSplit split = (FileVirtualSplit) spl;
	final Path file = split.getPath();
	final FileSystem fs = file.getFileSystem(conf);

	this.stringency = SAMHeaderReader.getValidationStringency(conf);

	final FSDataInputStream in = fs.open(file);

	codec = new BAMRecordCodec(SAMHeaderReader.readSAMHeaderFrom(in, conf));

	in.seek(0);
	bci = new BlockCompressedInputStream(
			new WrapSeekable<FSDataInputStream>(in, fs.getFileStatus(file).getLen(), file));

	final long virtualStart = split.getStartVirtualOffset();

	fileStart = virtualStart >>> 16;
	virtualEnd = split.getEndVirtualOffset();

	bci.seek(virtualStart);
	codec.setInputStream(bci);

	if (GaeaBamInputFormat.DEBUG_BAM_SPLITTER) {
		final long recordStart = virtualStart & 0xffff;
		System.err.println(
				"XXX inizialized BAMRecordReader byte offset: " + fileStart + " record offset: " + recordStart);
	}
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:42,代码来源:GaeaBamRecordReader.java


示例10: SortingSAMRecordCollection

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
private SortingSAMRecordCollection(SAMRecord[] recordArray, SAMFileHeader header, java.util.Comparator<SAMRecord> comparator, int maxRecordsInRAM, String tempDir) {
	reads = SortingCollection2.newInstance(recordArray, SAMRecord.class, new BAMRecordCodec(header), comparator, maxRecordsInRAM, new File(tempDir));
}
 
开发者ID:mozack,项目名称:abra2,代码行数:4,代码来源:SortingSAMRecordCollection.java


示例11: Codec

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
Codec(final int numRecords, final BAMRecordCodec bamCodec) {
    this.numRecords = numRecords;
    this.bamCodec = bamCodec;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:5,代码来源:IlluminaBasecallsToSam.java


示例12: RandSamRecordCodec

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
RandSamRecordCodec(SAMFileHeader header)
{
this.header=header;
this.bamRecordCodec=new BAMRecordCodec(this.header);
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:6,代码来源:Biostar145820.java


示例13: doWork

import htsjdk.samtools.BAMRecordCodec; //导入依赖的package包/类
@Override
public int doWork(List<String> args) {
	SamReader in=null;
	SAMFileWriter out=null;
	SAMRecordIterator iter=null;
	CloseableIterator<SAMRecord> iter2=null;
	SortingCollection<SAMRecord> sorter=null;
	try
		{
		in  = openSamReader(oneFileOrNull(args));
		final SAMFileHeader header= in.getFileHeader();
		
		final BAMRecordCodec bamRecordCodec=new BAMRecordCodec(header);
		final RefNameComparator refNameComparator=new RefNameComparator();
		sorter =SortingCollection.newInstance(
				SAMRecord.class,
				bamRecordCodec,
				refNameComparator,
				this.writingSortingCollection.getMaxRecordsInRam(),
				this.writingSortingCollection.getTmpPaths()
				);
		sorter.setDestructiveIteration(true);
		
		final SAMSequenceDictionaryProgress progress=new SAMSequenceDictionaryProgress(header);
		iter = in.iterator();
		while(iter.hasNext())
			{
			sorter.add( progress.watch(iter.next()));
			}
		in.close();in=null;
		sorter.doneAdding();
		
		final SAMFileHeader header2=header.clone();
		header2.addComment(getProgramName()+" "+getVersion()+" "+getProgramCommandLine());
		header2.setSortOrder(SortOrder.unsorted);
		out = this.writingBamArgs.openSAMFileWriter(outputFile,header2, true);
		iter2 = sorter.iterator();
		while(iter2.hasNext())
			{
			out.addAlignment(iter2.next());
			}
		out.close();out=null;
		sorter.cleanup();
		progress.finish();
		LOG.info("done");
		return RETURN_OK;
		}
	catch(Exception err)
		{
		LOG.error(err);
		return -1;
		}
	finally
		{
		CloserUtil.close(iter2);
		CloserUtil.close(iter);
		CloserUtil.close(out);
		CloserUtil.close(in);
		}
	}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:61,代码来源:SortSamRefName.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HIT类代码示例发布时间:2022-05-22
下一篇:
Java InjectableLanguage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap