本文整理汇总了Java中htsjdk.samtools.SAMReadGroupRecord.setSample方法的典型用法代码示例。如果您正苦于以下问题:Java SAMReadGroupRecord.setSample方法的具体用法?Java SAMReadGroupRecord.setSample怎么用?Java SAMReadGroupRecord.setSample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMReadGroupRecord
的用法示例。
在下文中一共展示了SAMReadGroupRecord.setSample方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEnumeratedReadGroups
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
/**
* setup read groups for the specified read groups and sample names
*
* @param header the header to set
* @param readGroupIDs the read group ID tags
* @param sampleNames the sample names
* @return the adjusted SAMFileHeader
*/
public static SAMFileHeader createEnumeratedReadGroups(SAMFileHeader header, List<String> readGroupIDs, List<String> sampleNames) {
if (readGroupIDs.size() != sampleNames.size()) {
throw new ReviewedGATKException("read group count and sample name count must be the same");
}
List<SAMReadGroupRecord> readGroups = new ArrayList<SAMReadGroupRecord>();
int x = 0;
for (; x < readGroupIDs.size(); x++) {
SAMReadGroupRecord rec = new SAMReadGroupRecord(readGroupIDs.get(x));
rec.setSample(sampleNames.get(x));
readGroups.add(rec);
}
header.setReadGroups(readGroups);
return header;
}
示例2: createReadGroupRecord
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
protected SAMReadGroupRecord createReadGroupRecord(
String RGID, String RGLB, String RGPL,
String RGPU, String RGSM, String RGCN,
String RGDS, Iso8601Date RGDT, Integer RGPI) {
SAMReadGroupRecord rg = new SAMReadGroupRecord(RGID);
rg.setLibrary(RGLB);
rg.setPlatform(RGPL);
rg.setSample(RGSM);
rg.setPlatformUnit(RGPU);
if(RGCN != null)
rg.setSequencingCenter(RGCN);
if(RGDS != null)
rg.setDescription(RGDS);
if(RGDT != null)
rg.setRunDate(RGDT);
if(RGPI != null)
rg.setPredictedMedianInsertSize(RGPI);
return rg;
}
示例3: buildSamFileWriter
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
/**
* Build a SamFileWriter that will write its contents to the output file.
*
* @param output The file to which to write
* @param sampleAlias The sample alias set in the read group header
* @param libraryName The name of the library to which this read group belongs
* @param headerParameters Header parameters that will be added to the RG header for this SamFile
* @return A SAMFileWriter
*/
private SAMFileWriterWrapper buildSamFileWriter(final File output, final String sampleAlias,
final String libraryName, final Map<String, String> headerParameters,
final boolean presorted) {
IOUtil.assertFileIsWritable(output);
final SAMReadGroupRecord rg = new SAMReadGroupRecord(READ_GROUP_ID);
rg.setSample(sampleAlias);
if (libraryName != null) rg.setLibrary(libraryName);
for (final Map.Entry<String, String> tagNameToValue : headerParameters.entrySet()) {
if (tagNameToValue.getValue() != null) {
rg.setAttribute(tagNameToValue.getKey(), tagNameToValue.getValue());
}
}
final SAMFileHeader header = new SAMFileHeader();
header.setSortOrder(SAMFileHeader.SortOrder.queryname);
header.addReadGroup(rg);
return new SAMFileWriterWrapper(new SAMFileWriterFactory().makeSAMOrBAMWriter(header, presorted, output));
}
示例4: createSamFileHeader
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
/** Creates a simple header with the values provided on the command line. */
public SAMFileHeader createSamFileHeader() {
final SAMReadGroupRecord rgroup = new SAMReadGroupRecord(this.READ_GROUP_NAME);
rgroup.setSample(this.SAMPLE_NAME);
if (this.LIBRARY_NAME != null) rgroup.setLibrary(this.LIBRARY_NAME);
if (this.PLATFORM != null) rgroup.setPlatform(this.PLATFORM);
if (this.PLATFORM_UNIT != null) rgroup.setPlatformUnit(this.PLATFORM_UNIT);
if (this.SEQUENCING_CENTER != null) rgroup.setSequencingCenter(SEQUENCING_CENTER);
if (this.PREDICTED_INSERT_SIZE != null) rgroup.setPredictedMedianInsertSize(PREDICTED_INSERT_SIZE);
if (this.DESCRIPTION != null) rgroup.setDescription(this.DESCRIPTION);
if (this.RUN_DATE != null) rgroup.setRunDate(this.RUN_DATE);
if (this.PLATFORM_MODEL != null) rgroup.setPlatformModel(this.PLATFORM_MODEL);
if (this.PROGRAM_GROUP != null) rgroup.setProgramGroup(this.PROGRAM_GROUP);
final SAMFileHeader header = new SAMFileHeader();
header.addReadGroup(rgroup);
for (final String comment : COMMENT) {
header.addComment(comment);
}
header.setSortOrder(this.SORT_ORDER);
return header ;
}
示例5: HaplotypeBAMDestination
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的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"));
}
示例6: readsWithReadGroupData
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
@DataProvider(name = "ReadsWithReadGroupData")
public Object[][] readsWithReadGroupData() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(2, 1, 1000000);
final SAMReadGroupRecord readGroup = new SAMReadGroupRecord("FOO");
readGroup.setPlatform("FOOPLATFORM");
readGroup.setPlatformUnit("FOOPLATFORMUNIT");
readGroup.setLibrary("FOOLIBRARY");
readGroup.setSample("FOOSAMPLE");
header.addReadGroup(readGroup);
final GATKRead googleBackedRead = new GoogleGenomicsReadToGATKReadAdapter(ArtificialReadUtils.createArtificialGoogleGenomicsRead("google", "1", 5, new byte[]{'A', 'C', 'G', 'T'}, new byte[]{1, 2, 3, 4}, "4M"));
googleBackedRead.setReadGroup("FOO");
final GATKRead samBackedRead = new SAMRecordToGATKReadAdapter(ArtificialReadUtils.createArtificialSAMRecord(header, "sam", header.getSequenceIndex("1"), 5, new byte[]{'A', 'C', 'G', 'T'}, new byte[]{1, 2, 3, 4}, "4M"));
samBackedRead.setReadGroup("FOO");
return new Object[][] {
{ googleBackedRead, header, "FOO" },
{ samBackedRead, header, "FOO" }
};
}
示例7: testGetSamplesFromHeader
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
@Test
public void testGetSamplesFromHeader() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader(5, 1, 100);
final List<SAMReadGroupRecord> readGroups = new ArrayList<>();
for ( int i = 1; i <= 5; ++i ) {
SAMReadGroupRecord readGroup = new SAMReadGroupRecord("ReadGroup" + i);
readGroup.setSample("Sample" + i);
readGroups.add(readGroup);
}
header.setReadGroups(readGroups);
final Set<String> samples = ReadUtils.getSamplesFromHeader(header);
Assert.assertEquals(samples.size(), 5, "Wrong number of samples returned from ReadUtils.getSamplesFromHeader()");
for ( int i = 1; i <= 5; ++i ) {
Assert.assertTrue(samples.contains("Sample" + i), "Missing Sample" + i + " in samples returned from ReadUtils.getSamplesFromHeader()");
}
}
示例8: transfer
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
public static SAMReadGroupRecord transfer(ReadGroupInfo readGroupInfo) {
SAMReadGroupRecord record = new SAMReadGroupRecord(readGroupInfo.id());
record.setSample(readGroupInfo.sample());
record.setLibrary(readGroupInfo.lib());
record.setPlatform(readGroupInfo.platform());
record.setPlatformUnit(readGroupInfo.platformUnit());
return record;
}
示例9: createDefaultReadGroup
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
/**
* setup a default read group for a SAMFileHeader
*
* @param header the header to set
* @param readGroupID the read group ID tag
* @param sampleName the sample name
* @return the adjusted SAMFileHeader
*/
public static SAMFileHeader createDefaultReadGroup(SAMFileHeader header, String readGroupID, String sampleName) {
SAMReadGroupRecord rec = new SAMReadGroupRecord(readGroupID);
rec.setSample(sampleName);
List<SAMReadGroupRecord> readGroups = new ArrayList<SAMReadGroupRecord>();
readGroups.add(rec);
header.setReadGroups(readGroups);
return header;
}
示例10: setUp
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
@BeforeClass
public void setUp() {
header = ArtificialReadUtils.createArtificialSamHeader(1, 1, 1000);
rg = new SAMReadGroupRecord(RGID);
rg.setSample(sample);
header.addReadGroup(rg);
parser = new GenomeLocParser(header.getSequenceDictionary());
}
示例11: getReadGroupFromArguments
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
/**
* Gets a basic Read Group from the arguments.
*
* Note: the program group is set to {@link RTHelpConstants#PROGRAM_NAME}.
*
*/
public SAMReadGroupRecord getReadGroupFromArguments(final String id, final String sampleName) {
final SAMReadGroupRecord rg = new SAMReadGroupRecord(id);
rg.setProgramGroup(RTHelpConstants.PROGRAM_NAME);
rg.setSample(sampleName);
// the program group is the one in the project properties
rg.setProgramGroup(RTHelpConstants.PROGRAM_NAME);
if (readGroupLibrary != null) {
rg.setLibrary(readGroupLibrary);
}
if (readGroupPlatform != null) {
rg.setPlatform(readGroupPlatform.toString());
}
if (readGroupPlatformUnit != null) {
rg.setPlatformUnit(readGroupPlatformUnit);
}
if (readGroupSequencingCenter != null) {
rg.setSequencingCenter(readGroupSequencingCenter);
}
if (readGroupRunDate != null) {
rg.setRunDate(readGroupRunDate);
}
if (readGroupPredictedInsertSize != null) {
rg.setPredictedMedianInsertSize(readGroupPredictedInsertSize);
}
if (readGroupPlatformModel != null) {
rg.setPlatformModel(readGroupPlatformModel);
}
// return it
return rg;
}
示例12: testGetNoArgumentsReadGroup
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
@Test
public void testGetNoArgumentsReadGroup() throws Exception {
final SAMReadGroupRecord expected = new SAMReadGroupRecord("RGID");
expected.setProgramGroup("ReadTools");
expected.setSample("sampleName");
Assert.assertEquals(new ReadGroupArgumentCollection()
.getReadGroupFromArguments(expected.getReadGroupId(), expected.getSample()),
expected);
}
示例13: testGetReadGroupWithArguments
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
@Test
public void testGetReadGroupWithArguments() throws Exception {
// setting expected RG
final SAMReadGroupRecord expected = new SAMReadGroupRecord("RGID");
expected.setProgramGroup("ReadTools");
expected.setSample("sampleName");
// setting args
final ReadGroupArgumentCollection rgargs = new ReadGroupArgumentCollection();
// starting setting params
expected.setLibrary("LB");
rgargs.readGroupLibrary = "LB";
expected.setPlatform("ILLUMINA");
rgargs.readGroupPlatform = SAMReadGroupRecord.PlatformValue.ILLUMINA;
expected.setPlatformUnit("PU");
rgargs.readGroupPlatformUnit = expected.getPlatformUnit();
expected.setSequencingCenter("CN");
rgargs.readGroupSequencingCenter = expected.getSequencingCenter();
final Iso8601Date date = new Iso8601Date("2007-11-03");
expected.setRunDate(date);
rgargs.readGroupRunDate = date;
expected.setPredictedMedianInsertSize(100);
rgargs.readGroupPredictedInsertSize = expected.getPredictedMedianInsertSize();
expected.setPlatformModel("PM");
rgargs.readGroupPlatformModel = expected.getPlatformModel();
// testing
Assert.assertEquals(rgargs
.getReadGroupFromArguments(expected.getReadGroupId(), expected.getSample()),
expected);
}
示例14: setupTest1
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
public void setupTest1(final int ID, final String readGroupId, final SAMReadGroupRecord readGroupRecord, final String sample,
final String library, final SAMFileHeader header, final SAMRecordSetBuilder setBuilder)
throws IOException {
final String separator = ":";
final int contig1 = 0;
final int contig2 = 1;
readGroupRecord.setSample(sample);
readGroupRecord.setPlatform(platform);
readGroupRecord.setLibrary(library);
readGroupRecord.setPlatformUnit(readGroupId);
header.addReadGroup(readGroupRecord);
setBuilder.setReadGroup(readGroupRecord);
setBuilder.setUseNmFlag(true);
setBuilder.setHeader(header);
final int max = 800;
final int min = 1;
final Random rg = new Random(5);
//add records that align to chrM and O but not N
for (int i = 0; i < NUM_READS; i++) {
final int start = rg.nextInt(max) + min;
final String newReadName = READ_NAME + separator + ID + separator + i;
if (i != NUM_READS - 1) {
setBuilder.addPair(newReadName, contig1, start + ID, start + ID + LENGTH);
} else {
setBuilder.addPair(newReadName, contig2, start + ID, start + ID + LENGTH);
}
}
}
示例15: setupTest2
import htsjdk.samtools.SAMReadGroupRecord; //导入方法依赖的package包/类
public void setupTest2(final int ID, final String readGroupId, final SAMReadGroupRecord readGroupRecord, final String sample,
final String library, final SAMFileHeader header, final SAMRecordSetBuilder setBuilder)
throws IOException {
final String separator = ":";
final int contig1 = 0;
final int contig2 = 1;
final int contig3 = 2;
readGroupRecord.setSample(sample);
readGroupRecord.setPlatform(platform);
readGroupRecord.setLibrary(library);
readGroupRecord.setPlatformUnit(readGroupId);
setBuilder.setReadGroup(readGroupRecord);
setBuilder.setUseNmFlag(true);
setBuilder.setHeader(header);
final int max = 800;
final int min = 1;
final Random rg = new Random(5);
//add records that align to all 3 chr in reference file
for (int i = 0; i < NUM_READS; i++) {
final int start = rg.nextInt(max) + min;
final String newReadName = READ_NAME + separator + ID + separator + i;
if (i<=NUM_READS/3) {
setBuilder.addPair(newReadName, contig1, start + ID, start + ID + LENGTH);
} else if (i< (NUM_READS - (NUM_READS/3))) {
setBuilder.addPair(newReadName, contig2, start + ID, start + ID + LENGTH);
} else {
setBuilder.addPair(newReadName, contig3, start + ID, start + ID + LENGTH);
}
}
}