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


Java SAMProgramRecord.getPreviousProgramGroupId方法代码示例

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


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

示例1: buildSAMProgramRecord

import htsjdk.samtools.SAMProgramRecord; //导入方法依赖的package包/类
public static SAMProgramRecord buildSAMProgramRecord(String prog, List<SAMProgramRecord> records) {
    String pgTemplate = "ngsutilsj:" + prog + "-";
    String pgID = pgTemplate;
    boolean found = true;
    int i = 0;
    
    SAMProgramRecord mostRecent = null;
    
    while (found) {
        found = false;
        i++;
        pgID = pgTemplate + i;
        if (records!=null) {
            for (SAMProgramRecord record: records) {
                if (mostRecent == null && (record.getPreviousProgramGroupId() == null || record.getPreviousProgramGroupId().equals(""))) {
                   mostRecent = record;
                }
                
                if (record.getId().equals(pgID)) {
                    found = true;
                }
            }
        }
    }

    SAMProgramRecord programRecord = new SAMProgramRecord(pgID);
    programRecord.setProgramName("ngsutilsj:"+prog);
    programRecord.setProgramVersion(NGSUtils.getVersion());
    programRecord.setCommandLine("ngsutilsj " + NGSUtils.getArgs());
    if (mostRecent!=null) {
        programRecord.setPreviousProgramGroupId(mostRecent.getId());
    }
    return programRecord;
}
 
开发者ID:compgen-io,项目名称:ngsutilsj,代码行数:35,代码来源:BamHeaderUtils.java

示例2: pgRecordChainingTest

import htsjdk.samtools.SAMProgramRecord; //导入方法依赖的package包/类
/**
 * Test that PG header records are created & chained appropriately (or not created), and that the PG record chains
 * are as expected.  MarkDuplicates is used both to merge and to mark dupes in this case.
 * @param suppressPg If true, do not create PG header record.
 * @param expectedPnVnByReadName For each read, info about the expect chain of PG records.
 */
@Test(dataProvider = "pgRecordChainingTest")
public void pgRecordChainingTest(final boolean suppressPg,
                                 final Map<String, List<ExpectedPnAndVn>> expectedPnVnByReadName) {
    final File outputDir = IOUtil.createTempDir(TEST_BASE_NAME + ".", ".tmp");
    outputDir.deleteOnExit();
    try {
        // Run MarkDuplicates, merging the 3 input files, and either enabling or suppressing PG header
        // record creation according to suppressPg.
        final MarkDuplicates markDuplicates = new MarkDuplicates();
        final ArrayList<String> args = new ArrayList<String>();
        for (int i = 1; i <= 3; ++i) {
            args.add("INPUT=" + new File(TEST_DATA_DIR, "merge" + i + ".sam").getAbsolutePath());
        }
        final File outputSam = new File(outputDir, TEST_BASE_NAME + ".sam");
        args.add("OUTPUT=" + outputSam.getAbsolutePath());
        args.add("METRICS_FILE=" + new File(outputDir, TEST_BASE_NAME + ".duplicate_metrics").getAbsolutePath());
        args.add("ADD_PG_TAG_TO_READS=true");
        if (suppressPg) args.add("PROGRAM_RECORD_ID=null");

        // I generally prefer to call doWork rather than invoking the argument parser, but it is necessary
        // in this case to initialize the command line.
        // Note that for the unit test, version won't come through because it is obtained through jar
        // manifest, and unit test doesn't run code from a jar.
        Assert.assertEquals(markDuplicates.instanceMain(args.toArray(new String[args.size()])), 0);

        // Read the MarkDuplicates output file, and get the PG ID for each read.  In this particular test,
        // the PG ID should be the same for both ends of a pair.
        final SamReader reader = SamReaderFactory.makeDefault().open(outputSam);

        final Map<String, String> pgIdForReadName = new HashMap<String, String>();
        for (final SAMRecord rec : reader) {
            final String existingPgId = pgIdForReadName.get(rec.getReadName());
            final String thisPgId = rec.getStringAttribute(SAMTag.PG.name());
            if (existingPgId != null) {
                Assert.assertEquals(thisPgId, existingPgId);
            } else {
                pgIdForReadName.put(rec.getReadName(), thisPgId);
            }
        }
        final SAMFileHeader header = reader.getFileHeader();
        CloserUtil.close(reader);

        // Confirm that for each read name, the chain of PG records contains exactly the number that is expected,
        // and that values in the PG chain are as expected.
        for (final Map.Entry<String, List<ExpectedPnAndVn>> entry : expectedPnVnByReadName.entrySet()) {
            final String readName = entry.getKey();
            final List<ExpectedPnAndVn> expectedList = entry.getValue();
            String pgId = pgIdForReadName.get(readName);
            for (final ExpectedPnAndVn expected : expectedList) {
                final SAMProgramRecord programRecord = header.getProgramRecord(pgId);
                if (expected.expectedPn != null) Assert.assertEquals(programRecord.getProgramName(), expected.expectedPn);
                if (expected.expectedVn != null) Assert.assertEquals(programRecord.getProgramVersion(), expected.expectedVn);
                pgId = programRecord.getPreviousProgramGroupId();
            }
            Assert.assertNull(pgId);
        }

    } finally {
        TestUtil.recursiveDelete(outputDir);
    }
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:68,代码来源:MarkDuplicatesTest.java

示例3: SAMXMLWriter

import htsjdk.samtools.SAMProgramRecord; //导入方法依赖的package包/类
public SAMXMLWriter(final XMLStreamWriter w,final SAMFileHeader header) throws XMLStreamException
{
this.w=w;
this.header=header;

      w.writeStartElement("sam");
      
      w.writeStartElement("header");
      w.writeAttribute("version",header.getVersion());
      w.writeAttribute("sort",header.getSortOrder().name());
      
 		if(header.getCreator()!=null) w.writeAttribute("creator", header.getCreator());
      
      final SAMSequenceDictionary dict = header.getSequenceDictionary();
      if(dict==null)
      	{
      	w.writeComment("no dictionary available");
      	}
      else
      	{
      	w.writeStartElement("dict");
      	w.writeAttribute("size", String.valueOf(dict.size()));
      	for(final SAMSequenceRecord ssr: dict.getSequences())
      		{
      		w.writeStartElement("contig");
      		w.writeAttribute("index", String.valueOf(ssr.getSequenceIndex()));
      		w.writeAttribute("name",ssr.getSequenceName());
      		writeText(w,"assembly", String.valueOf(ssr.getAssembly()));
      		writeText(w,"species", String.valueOf(ssr.getSpecies()));
      		writeText(w,"length", String.valueOf(ssr.getSequenceLength()));
      		writeText(w,"md5",ssr.getMd5());
      		w.writeEndElement();
      		}
      	w.writeEndElement();
      	}
      if(!header.getReadGroups().isEmpty()) {
       w.writeStartElement("read-groups");
       for(final SAMReadGroupRecord g: header.getReadGroups())
       	{
       	w.writeStartElement("read-group");
       	w.writeAttribute("id",g.getId());
       	writeText(w,"sample",g.getSample());
       	writeText(w,"description",g.getDescription());
       	writeText(w,"flow-order",g.getFlowOrder());
       	writeText(w,"key-sequence",g.getKeySequence());
       	writeText(w,"platform",g.getPlatform());
       	writeText(w,"platform-model",g.getPlatformModel());
       	writeText(w,"platform-unit",g.getPlatformUnit());
       	writeText(w,"program-group",g.getProgramGroup());
       	writeText(w,"library",g.getLibrary());
       	writeText(w,"center",g.getSequencingCenter());
       	writeText(w,"insert-size",g.getPredictedMedianInsertSize());
       	writeText(w,"run-date",g.getRunDate());
       	w.writeEndElement();
       	}
       w.writeEndElement();
       }
      if(!header.getProgramRecords().isEmpty()) {
       w.writeStartElement("program-records");
       for(final SAMProgramRecord sp:header.getProgramRecords())
       	{
       	w.writeStartElement("program-record");
       	w.writeAttribute("id",sp.getId());
       	if(sp.getPreviousProgramGroupId()!=null) w.writeAttribute("prev-group-id",sp.getPreviousProgramGroupId());
       	if(sp.getProgramName()!=null) w.writeAttribute("name",sp.getProgramName());
       	if(sp.getProgramVersion()!=null) w.writeAttribute("version",sp.getProgramVersion());
       	if(sp.getCommandLine()!=null)  w.writeCharacters(sp.getCommandLine());
       	w.writeEndElement();
       	}
       w.writeEndElement();
       }
      
      for(final String comm: header.getComments())
      	{
      	writeText(w,"comment",comm);
      	}
    
      
      w.writeEndElement();//header

}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:82,代码来源:Bam2Xml.java


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