private static String stratifyReadGroup(final SAMRecord sam) { return sam.getReadGroup().getReadGroupId(); } }
public boolean filterOut( final SAMRecord read ) { final SAMReadGroupRecord readGroup = read.getReadGroup(); return !( readGroup != null && readGroup.getReadGroupId().equals( READ_GROUP_TO_KEEP ) ); } }
public boolean filterOut( final SAMRecord read ) { final SAMReadGroupRecord readGroup = read.getReadGroup(); return !( readGroup != null && SAMPLES_TO_KEEP.contains(readGroup.getSample()) ); } }
/** * * @param read * @return sample Object with this ID, or null if this does not exist */ public Sample getSample(final SAMRecord read) { return getSample(read.getReadGroup()); }
void addAlignment(final SAMRecord rec) { final SAMFileWriter writer; if (outputByReadGroup) { writer = writerMap.get(rec.getReadGroup().getId()); } else { writer = singleWriter; } writer.addAlignment(rec); }
public boolean filterOut( final SAMRecord read ) { final SAMReadGroupRecord readGroup = read.getReadGroup(); return ( readGroup == null || readGroup.getLibrary() == null || !readGroup.getLibrary().equals( LIBRARY_TO_KEEP ) ); } }
void add(final SAMRecord rec) { final SortingCollection<SAMRecord> sorter; if (outputByReadGroup) { sorter = sorterMap.get(rec.getReadGroup().getId()); } else { sorter = singleSorter; } sorter.add(rec); }
void add(final SAMRecord rec) { final SortingCollection<SAMRecord> sorter; if (outputByReadGroup) { sorter = sorterMap.get(rec.getReadGroup().getId()); } else { sorter = singleSorter; } sorter.add(rec); }
@Override public void addAlignment(SAMRecord samRecord) { super.addAlignment(samRecord, sampleToWriterMap.get(samRecord.getReadGroup().getSample())); } }
void addAlignment(final SAMRecord rec) { final SAMFileWriter writer; if (outputByReadGroup) { writer = writerMap.get(rec.getReadGroup().getId()); } else { writer = singleWriter; } writer.addAlignment(rec); }
/** * Construct a argument of ARGTYPE using the given SAMRecord and ReferenceSequence then pass * this value to all collectors that should include this record */ public void acceptRecord(final SAMRecord record, final ReferenceSequence refSeq) { final ARGTYPE arg = makeArg(record, refSeq); for(final Distributor collector : outputOrderedDistributors) { collector.acceptRecord(arg, record.getReadGroup()); } }
private static SAMReadGroupRecord getReadGroup(SAMRecord r) { SAMReadGroupRecord rg = r.getReadGroup(); if ( rg == null ) { String msg = "Read "+r.getReadName()+" lacks read group information; Please associate all reads with read groups"; throw new UserException.MalformedBAM(r, msg); } return rg; } }
/** * Construct a argument of ARGTYPE using the given SAMRecord and ReferenceSequence then pass * this value to all collectors that should include this record */ public void acceptRecord(final SAMRecord record, final ReferenceSequence refSeq) { final ARGTYPE arg = makeArg(record, refSeq); for(final Distributor collector : outputOrderedDistributors) { collector.acceptRecord(arg, record.getReadGroup()); } }
public boolean filterOut(SAMRecord samRecord) { if ( blackListedLanes.size() == 0 ) return false; // no filters set, nothing to do Object pu_attr = samRecord.getAttribute("PU"); if ( pu_attr == null ) { // no platform unit in the record, go get from read group SAMReadGroupRecord rgr = samRecord.getReadGroup(); if ( rgr == null ) throw new UserException.MalformedBAM(samRecord, "Read " + samRecord.getReadName() +" has NO associated read group record"); pu_attr = rgr.getAttribute("PU") ; } if ( pu_attr == null ) return false; // could not get PU, forget about the filtering... return blackListedLanes.contains((String)pu_attr); }
@Override protected void handleAdditionalRecords(SAMRecord currentRecord, Map<SAMReadGroupRecord, List<FastqWriter>> tagWriters, SAMRecord read1, SAMRecord read2) { final List<FastqWriter> rgTagWriters = tagWriters.get(currentRecord.getReadGroup()); if (currentRecord.getReadPairedFlag()) { if (read1 != null && read2 !=null) { writeTagRecords(read1, 1, rgTagWriters); writeTagRecords(read2, 2, rgTagWriters); } } else { writeTagRecords(currentRecord, null, rgTagWriters); } }
@Override protected void handleAdditionalRecords(SAMRecord currentRecord, Map<SAMReadGroupRecord, List<FastqWriter>> tagWriters, SAMRecord read1, SAMRecord read2) { final List<FastqWriter> rgTagWriters = tagWriters.get(currentRecord.getReadGroup()); if (currentRecord.getReadPairedFlag()) { if (read1 != null && read2 !=null) { writeTagRecords(read1, 1, rgTagWriters); writeTagRecords(read2, 2, rgTagWriters); } } else { writeTagRecords(currentRecord, null, rgTagWriters); } }
private static boolean checkHasReadGroup(final SAMRecord read) { if ( read.getReadGroup() == null ) { // there are 2 possibilities: either the RG tag is missing or it is not defined in the header final String rgID = (String)read.getAttribute(SAMTagUtil.getSingleton().RG); if ( rgID == null ) throw new UserException.ReadMissingReadGroup(read); throw new UserException.ReadHasUndefinedReadGroup(read, rgID); } return true; }
private void assertGoodRead(final SAMRecord read, final ArtificialBAMBuilder bamBuilder) { Assert.assertEquals(read.getReadLength(), bamBuilder.getReadLength()); Assert.assertEquals(read.getReadBases().length, bamBuilder.getReadLength()); Assert.assertEquals(read.getBaseQualities().length, bamBuilder.getReadLength()); Assert.assertTrue(read.getAlignmentStart() >= bamBuilder.getAlignmentStart()); Assert.assertNotNull(read.getReadGroup()); } }
private void validateReadGroup(final SAMRecord record, final SAMFileHeader header) { final SAMReadGroupRecord rg = record.getReadGroup(); if (rg == null) { addError(new SAMValidationError(Type.RECORD_MISSING_READ_GROUP, "A record is missing a read group", record.getReadName())); } else if (header.getReadGroup(rg.getId()) == null) { addError(new SAMValidationError(Type.READ_GROUP_NOT_FOUND, "A record has a read group not found in the header: ", record.getReadName() + ", " + rg.getReadGroupId())); } }
private void validateReadGroup(final SAMRecord record, final SAMFileHeader header) { final SAMReadGroupRecord rg = record.getReadGroup(); if (rg == null) { addError(new SAMValidationError(Type.RECORD_MISSING_READ_GROUP, "A record is missing a read group", record.getReadName())); } else if (header.getReadGroup(rg.getId()) == null) { addError(new SAMValidationError(Type.READ_GROUP_NOT_FOUND, "A record has a read group not found in the header: ", record.getReadName() + ", " + rg.getReadGroupId())); } }