本文整理汇总了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;
}
示例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);
}
}
示例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
}