本文整理汇总了Java中net.sf.samtools.SAMReadGroupRecord类的典型用法代码示例。如果您正苦于以下问题:Java SAMReadGroupRecord类的具体用法?Java SAMReadGroupRecord怎么用?Java SAMReadGroupRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SAMReadGroupRecord类属于net.sf.samtools包,在下文中一共展示了SAMReadGroupRecord类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeGenomeSAMFileHeader
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
/**
* create a header object complete with a HD and SQ lines
*
* @param seqinfo
* @return
*/
private SAMFileHeader makeGenomeSAMFileHeader(File genome, String readgroup) throws IOException {
// get sequence information from the genome fai file
File genomefai = new File(genome.getAbsoluteFile() + ".fai");
BufferedReader faireader = BufferedReaderMaker.makeBufferedReader(genomefai);
String s;
SAMFileHeader header = new SAMFileHeader();
header.setTextHeader("@HD VN:1.0 SO:unsorted");
while ((s = faireader.readLine()) != null) {
String[] ssplit = s.split("\t");
header.addSequence(new SAMSequenceRecord(ssplit[0], Integer.parseInt(ssplit[1])));
}
// add a read group line to the header with the string readgroup specifying the
// the actual RG name, the sample, and library
SAMReadGroupRecord rgr = new SAMReadGroupRecord(readgroup);
rgr.setPlatform("ILLUMINA");
rgr.setLibrary(readgroup);
rgr.setSample(readgroup);
header.addReadGroup(new SAMReadGroupRecord(readgroup, rgr));
return header;
}
示例2: apply
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
@Override
public String apply(File f) {
if (!detectable(f)) {
throw new IllegalArgumentException("Cannot detect sample name for file: " + f.getPath());
}
final SAMFileReader in = new SAMFileReader(f);
try {
final SAMFileHeader header = in.getFileHeader();
final List<SAMReadGroupRecord> rgs = header.getReadGroups();
assertFalse(rgs.isEmpty(), "Cannot determine sample name: missing read group information for file: " + f.getPath());
assertFalse(rgs.size() > 1, "Cannot determine sample name: more than one read group detected for file: " + f.getPath());
final String sample = rgs.get(0).getSample();
assertFalse(sample == null, "Cannot determine sample name: missing sample name in read group for file: " + f.getPath());
return sample;
} finally {
in.close();
}
}
示例3: extractSampleNamesFromBAM
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
public static List<String> extractSampleNamesFromBAM(File f){
final List<String> ret = new ArrayList<String>();
final SAMFileReader in = new SAMFileReader(f);
final List<SAMReadGroupRecord> rgs = in.getFileHeader().getReadGroups();
if(rgs==null){
throw new MissingReadGroupException(f);
}
for(SAMReadGroupRecord rg: rgs){
ret.add(rg.getSample());
}
return ret;
}
示例4: createRG
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
private SAMReadGroupRecord createRG(String id, String sample) {
SAMReadGroupRecord ret = new SAMReadGroupRecord(id);
if (sample != null) {
ret.setSample(sample);
}
return ret;
}
示例5: MultiBAMHelper
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
public MultiBAMHelper(GenomeAnalysisEngine engine, boolean require_clean) {
sample_set = new HashMap<String, String>();
Evidence = new HashMap<String, PileupEvidence>();
for (SAMReaderID rid : engine.getReadsDataSource().getReaderIDs()) {
total_inputs++;
Tags tags = rid.getTags();
if (tags.getPositionalTags().isEmpty())
throw new UserException.BadInput("This module requires that input BAMs are tagged (ie. -I:dna_normal normal.bam -I:dna_tumor tumor.bam): " +
engine.getSourceFileForReaderID(rid));
for (String tag : tags.getPositionalTags()) {
for (SAMReadGroupRecord rg : engine.getSAMFileHeader(rid).getReadGroups()) {
String existing_tag = sample_set.get(rg.getSample());
if (existing_tag != null && !existing_tag.equals(tag)) {
throw new UserException.BadInput(String.format("Sample '%s' is being assigned to tag '%s', but has already been assigned to tag '%s'. This is often a result of tumor/normal BAMs using the same sample IDs in their @RG tags. \n", rg.getSample(), tag, existing_tag));
}
sample_set.put(rg.getSample(), tag);
Evidence.put(tag, new PileupEvidence());
if (tag.startsWith("rna")) {
rna_tags++;
}
}
}
}
this.require_clean = require_clean;
}
示例6: createBAM
import net.sf.samtools.SAMReadGroupRecord; //导入依赖的package包/类
private void createBAM(File f, List<SAMReadGroupRecord> rgs) {
final SAMFileHeader samHeader = new SAMFileHeader();
samHeader.setReadGroups(rgs);
final SAMFileWriter samWriter = new SAMFileWriterFactory().makeSAMWriter(samHeader, false, f);
samWriter.close();
}