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


Java SAMProgramRecord类代码示例

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


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

示例1: testGetProgramRecord

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
@Test
public void testGetProgramRecord() {
    final ReadToolsProgram program = new TestProgram();
    final String programName = "ReadTools TestProgram";

    // test the program record for an empty header
    final SAMFileHeader header = new SAMFileHeader();
    SAMProgramRecord pg0 = program.getProgramRecord(header);
    Assert.assertEquals(pg0.getId(), programName);
    Assert.assertEquals(pg0.getProgramName(), programName);

    // test adding more program records
    for (int i = 1; i < 5; i++) {
        header.addProgramRecord(pg0);
        pg0 = program.getProgramRecord(header);
        Assert.assertEquals(pg0.getId(), programName + "." + i);
        Assert.assertEquals(pg0.getProgramName(), programName);
    }
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:20,代码来源:ReadToolsProgramUnitTest.java

示例2: getOutputWriterData

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
@DataProvider(name = "outputWriterProvider")
public Object[][] getOutputWriterData() {
    final File testDir = createTestTempDir(this.getClass().getSimpleName());
    final SAMProgramRecord record = new SAMProgramRecord("test");
    record.setCommandLine("command line");
    return new Object[][] {
            // TODO: test cram
            // {new File(testDir, "example.empty.cram"), null},
            // {new File(testDir, "example.cram"), record},
            // test bam
            {new File(testDir, "example.empty.bam"), null, false},
            {new File(testDir, "example.empty2.bam"), null, true},
            {new File(testDir, "example.bam"), record, false},
            {new File(testDir, "example2.bam"), record, true},
            // test sam
            {new File(testDir, "example.empty.sam"), null, false},
            {new File(testDir, "example.empty2.sam"), null, true},
            {new File(testDir, "example.sam"), record, false},
            {new File(testDir, "example2.sam"), record, true},
    };
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:22,代码来源:RTOutputBamArgumentCollectionUnitTest.java

示例3: testWritingHeader

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
@Test(dataProvider = "outputWriterProvider")
public void testWritingHeader(final File outputFile, final SAMProgramRecord record,
        final boolean addProgramGroup) throws Exception {
    Assert.assertFalse(outputFile.exists(),
            "broken test: test output file exists " + outputFile);
    final RTOutputBamArgumentCollection args = new RTOutputBamArgumentCollection();
    args.outputName = outputFile.getAbsolutePath();
    args.addOutputSAMProgramRecord = addProgramGroup;
    final GATKReadWriter writer =
            args.outputWriter(new SAMFileHeader(), (record == null) ? null : () -> record, true,
                    null
            );
    writer.close();
    Assert.assertTrue(outputFile.exists(), "not output written");
    final SAMFileHeader writtenHeader =
            SamReaderFactory.makeDefault().getFileHeader(outputFile);
    final SAMFileHeader expectedHeader = new SAMFileHeader();
    expectedHeader.setSortOrder(SAMFileHeader.SortOrder.unsorted);
    if (addProgramGroup && record != null) {
        expectedHeader.addProgramRecord(record);
    }
    Assert.assertEquals(writtenHeader, expectedHeader);
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:24,代码来源:RTOutputBamArgumentCollectionUnitTest.java

示例4: compareProgramRecord

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private boolean compareProgramRecord(final SAMProgramRecord programRecord1, final SAMProgramRecord programRecord2) {
    if (programRecord1 == null && programRecord2 == null) {
        return true;
    }
    if (programRecord1 == null) {
        reportDifference("null", programRecord2.getProgramGroupId(), "Program Record");
        return false;
    }
    if (programRecord2 == null) {
        reportDifference(programRecord1.getProgramGroupId(), "null", "Program Record");
        return false;
    }
    boolean ret = compareValues(programRecord1.getProgramGroupId(), programRecord2.getProgramGroupId(),
            "Program Name");
    final String[] attributes = {"VN", "CL"};
    for (final String attribute : attributes) {
        ret = compareValues(programRecord1.getAttribute(attribute), programRecord2.getAttribute(attribute),
                attribute + " Program Record attribute") && ret;
    }
    return ret;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:22,代码来源:CompareSAMs.java

示例5: compareProgramRecords

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private boolean compareProgramRecords(final SAMFileHeader h1, final SAMFileHeader h2) throws Exception {
  final List<SAMProgramRecord> l1 = h1.getProgramRecords();
  final List<SAMProgramRecord> l2 = h2.getProgramRecords();
  if (!compareValues(l1.size(), l2.size(), "Number of program records")) {
      return false;
  }
  boolean ret = true;
  for (SAMProgramRecord pr1 : l1) {
    for (SAMProgramRecord pr2 : l2) {
      if (pr1.getId().equals(pr2.getId())) {
        ret = compareProgramRecord(pr1, pr2) && ret;
      }
    }
  }

  return ret;
}
 
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:18,代码来源:BAMDiff.java

示例6: compareProgramRecord

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private boolean compareProgramRecord(final SAMProgramRecord programRecord1, final SAMProgramRecord programRecord2) throws Exception {
  if (programRecord1 == null && programRecord2 == null) {
      return true;
  }
  if (programRecord1 == null) {
      reportDifference("null", programRecord2.getProgramGroupId(), "Program Record");
      return false;
  }
  if (programRecord2 == null) {
      reportDifference(programRecord1.getProgramGroupId(), "null", "Program Record");
      return false;
  }
  boolean ret = compareValues(programRecord1.getProgramGroupId(), programRecord2.getProgramGroupId(),
          "Program Name");
  final String[] attributes = {"VN", "CL"};
  for (final String attribute : attributes) {
      ret = compareValues(programRecord1.getAttribute(attribute), programRecord2.getAttribute(attribute),
              attribute + " Program Record attribute") && ret;
  }
  return ret;
}
 
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:22,代码来源:BAMDiff.java

示例7: HaplotypeBAMDestination

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
/**
 * Create a new HaplotypeBAMDestination
 *
 * @param sourceHeader SAMFileHeader used to seed the output SAMFileHeader for this destination.
 * @param haplotypeReadGroupID read group ID used when writing haplotypes as reads
 */
protected HaplotypeBAMDestination(SAMFileHeader sourceHeader, final String haplotypeReadGroupID) {
    Utils.nonNull(sourceHeader, "sourceHeader cannot be null");
    Utils.nonNull(haplotypeReadGroupID, "haplotypeReadGroupID cannot be null");
    this.haplotypeReadGroupID = haplotypeReadGroupID;

    bamOutputHeader = new SAMFileHeader();
    bamOutputHeader.setSequenceDictionary(sourceHeader.getSequenceDictionary());
    bamOutputHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);

    final List<SAMReadGroupRecord> readGroups = new ArrayList<>();
    readGroups.addAll(sourceHeader.getReadGroups()); // include the original read groups

    // plus an artificial read group for the haplotypes
    final SAMReadGroupRecord rgRec = new SAMReadGroupRecord(getHaplotypeReadGroupID());
    rgRec.setSample(haplotypeSampleTag);
    rgRec.setSequencingCenter("BI");
    readGroups.add(rgRec);
    bamOutputHeader.setReadGroups(readGroups);

    bamOutputHeader.addProgramRecord(new SAMProgramRecord("HalpotypeBAMWriter"));
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:28,代码来源:HaplotypeBAMDestination.java

示例8: mergeHeaders

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private static SAMFileHeader mergeHeaders(List<RecordSource> sources) {
	SAMFileHeader header = new SAMFileHeader();
	for (RecordSource source : sources) {
		SAMFileHeader h = source.reader.getFileHeader();

		for (SAMSequenceRecord seq : h.getSequenceDictionary().getSequences()) {
			if (header.getSequenceDictionary().getSequence(seq.getSequenceName()) == null)
				header.addSequence(seq);
		}

		for (SAMProgramRecord pro : h.getProgramRecords()) {
			if (header.getProgramRecord(pro.getProgramGroupId()) == null)
				header.addProgramRecord(pro);
		}

		for (String comment : h.getComments())
			header.addComment(comment);

		for (SAMReadGroupRecord rg : h.getReadGroups()) {
			if (header.getReadGroup(rg.getReadGroupId()) == null)
				header.addReadGroup(rg);
		}
	}

	return header;
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:27,代码来源:Merge.java

示例9: fillHeader

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private void fillHeader(XMLEventReader r,SAMProgramRecord prog) throws XMLStreamException,JAXBException
{
while(r.hasNext())
	{
	XMLEvent evt=r.peek();

	if(!(evt.isStartElement()))
		{
		r.next();
		continue;
		}
	StartElement E=evt.asStartElement();
	String name=E.getName().getLocalPart();
	if(name.equals("BlastOutput_iterations")) break;
	r.next();
	if(name.equals("BlastOutput_program"))
		{
		prog.setProgramName(r.getElementText());
		}
	else if(name.equals("BlastOutput_version"))
		{
		prog.setProgramVersion(r.getElementText().replace(' ', '_'));
		}
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:26,代码来源:BlastToSam.java

示例10: createProgramRecordPane

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
private Tab createProgramRecordPane(final SAMFileHeader header)
{
final TableView<SAMProgramRecord> table=new TableView<>(header==null?
		FXCollections.observableArrayList():
		FXCollections.observableArrayList(header.getProgramRecords())
		);
table.getColumns().add(makeColumn("ID", G->G.getId()));
table.getColumns().add(makeColumn("PG-ID", G->G.getProgramGroupId()));
table.getColumns().add(makeColumn("Prev-PG-ID", G->G.getPreviousProgramGroupId()));
table.getColumns().add(makeColumn("Version", G->G.getProgramVersion()));
table.getColumns().add(makeColumn("Command", G->G.getCommandLine()));
   
final Tab tab=new Tab("PG", table);
tab.setClosable(false);
table.setPlaceholder(new Label("No Program-Group."));
return tab;
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:18,代码来源:BamStage.java

示例11: setupWriter

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
/**
 * Creates a program record for the program, adds it to the list of program records (@PG tags) in the bam file and sets
 * up the writer with the header and presorted status.
 *
 * @param originalHeader      original header
 * @param programRecord       the program record for this program
 */
public static SAMFileHeader setupWriter(final SAMFileHeader originalHeader, final SAMProgramRecord programRecord) {
    final SAMFileHeader header = originalHeader.clone();
    final List<SAMProgramRecord> oldRecords = header.getProgramRecords();
    final List<SAMProgramRecord> newRecords = new ArrayList<SAMProgramRecord>(oldRecords.size()+1);
    for ( SAMProgramRecord record : oldRecords )
        if ( (programRecord != null && !record.getId().startsWith(programRecord.getId())))
            newRecords.add(record);

    if (programRecord != null) {
        newRecords.add(programRecord);
        header.setProgramRecords(newRecords);
    }
    return header;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:22,代码来源:Utils.java

示例12: createProgramGroupID

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
/**
 * Returns the program group ID that will be used in the SAM writer.
 * Starts with {@link #getToolName} and looks for the first available ID by appending
 * consecutive integers.
 */
private final String createProgramGroupID(final SAMFileHeader header) {
    final String toolName = getToolName();

    String pgID = toolName;
    SAMProgramRecord record = header.getProgramRecord(pgID);
    int count = 1;
    while (record != null) {
        pgID = toolName + "." + String.valueOf(count++);
        record = header.getProgramRecord(pgID);
    }
    return pgID;
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:18,代码来源:ReadToolsProgram.java

示例13: updateHeader

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
/**
 * Updates the header with the program record if {@link #addOutputSAMProgramRecord} is
 * {@code true} and the supplier is not {@code null}.
 */
@Override
protected final void updateHeader(final SAMFileHeader header,
        final Supplier<SAMProgramRecord> programRecord) {
    if (addOutputSAMProgramRecord && programRecord != null) {
        header.addProgramRecord(programRecord.get());
    }
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:12,代码来源:RTAbstractOutputBamArgumentCollection.java

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

示例15: suffixAddSAMProgramRecord

import htsjdk.samtools.SAMProgramRecord; //导入依赖的package包/类
public static SAMProgramRecord suffixAddSAMProgramRecord(SAMProgramRecord existing, String suffix) {
    SAMProgramRecord pg = new SAMProgramRecord(existing.getId()+suffix);
    for (Entry<String, String> k: existing.getAttributes()) {
        if (k.getKey().equals(SAMProgramRecord.PREVIOUS_PROGRAM_GROUP_ID_TAG)) {
            pg.setAttribute(k.getKey(), k.getValue()+suffix);
        } else {
            pg.setAttribute(k.getKey(), k.getValue());
        }
    }
    return pg;
}
 
开发者ID:compgen-io,项目名称:ngsutilsj,代码行数:12,代码来源:BamHeaderUtils.java


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