/** * @return read name of inner SAMRecord. */ public String getReadName() { return record.getReadName(); }
/** * Determines whether a SAMRecord matches this filter * * @param record the SAMRecord to evaluate * * @return true if the SAMRecord matches the filter, otherwise false */ @Override public boolean filterOut(final SAMRecord record) { return readNameFilterSet.contains(record.getReadName()) != includeReads; }
/** * @throws if numHits() == 0 */ public String getReadName() { return getRepresentativeRead().getReadName(); }
@Override public SAMRecord next() { final SAMRecord rec = underlyingIterator.next(); final String readName = rec.getReadName(); if (readName.endsWith(suffixToTrim)) { rec.setReadName(readName.substring(0, readName.length() - suffixToTrim.length())); } return rec; }
public String getPairedReadName() { final StringBuilder builder = new StringBuilder(64); builder.append(getReadName()); if (getReadPairedFlag()) { if (getFirstOfPairFlag()) { builder.append(" 1/2"); } else { builder.append(" 2/2"); } } return builder.toString(); }
public UnsupportedCigarOperatorException(final CigarOperator co, final SAMRecord read, final String message) { super(String.format( "Unsupported CIGAR operator %s in read %s at %s:%d. %s", co, read.getReadName(), read.getReferenceName(), read.getAlignmentStart(), message)); } }
private String assertTagExists(final SAMRecord record, final String tag) { String value = record.getStringAttribute(tag); if (value == null) { throw new PicardException("Record: " + record.getReadName() + " does have a value for tag: " + tag); } return value; }
private PhysicalLocationInt getSamRecordLocation(final SAMRecord rec) { final PhysicalLocationInt pos = new PhysicalLocationInt(); readNameParser.addLocationInformation(rec.getReadName(), pos); return pos; }
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; } }
private String assertTagExists(final SAMRecord record, final String tag) { String value = record.getStringAttribute(tag); if (value == null) { throw new PicardException("Record: " + record.getReadName() + " does have a value for tag: " + tag); } return value; }
@Override public String getReadName() { String result = super.getReadName(); if (mRestOfBinaryData != null && result == null) { result = decodeReadName(); super.setReadName(result); } return result; }
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 public Integer stratify(final SAMRecord sam) { try { final PhysicalLocation location = new PhysicalLocationInt(); opticalDuplicateFinder.addLocationInformation(sam.getReadName(), location); return (int) location.getTile(); } catch (final IllegalArgumentException ignored) { return null; } }
@Override public Integer stratify(final SAMRecord sam) { try { final PhysicalLocation location = new PhysicalLocationInt(); opticalDuplicateFinder.addLocationInformation(sam.getReadName(), location); return (int) location.getTile(); } catch (final IllegalArgumentException ignored) { return null; } }
/** * Report error if a tag value is a Long. */ private void validateTags(final SAMRecord record, final long recordNumber) { for (final SAMRecord.SAMTagAndValue tagAndValue : record.getAttributes()) { if (tagAndValue.value instanceof Long) { addError(new SAMValidationError(Type.TAG_VALUE_TOO_LARGE, "Numeric value too large for tag " + tagAndValue.tag, record.getReadName(), recordNumber)); } } }
/** * The record should already have the DS and MC tags computed */ public void addRecord(final SAMRecord record) { if (record.getReadPairedFlag() && !record.getMateUnmappedFlag() && null == record.getAttribute(SAMTag.MC.getBinaryTag())) { throw new SAMException("Mate Cigar tag (MC) not found in: " + record.getReadName()); } this.records.add(record); }
private Set<String> readNamesInRegion(final ActiveRegion region) { final Set<String> readNames = new LinkedHashSet<String>(region.getReads().size()); for ( final SAMRecord read : region.getReads() ) readNames.add(read.getReadName()); return readNames; }
protected static void assertPairedMates(final SAMRecord record1, final SAMRecord record2) { if (!(record1.getFirstOfPairFlag() && record2.getSecondOfPairFlag() || record2.getFirstOfPairFlag() && record1.getSecondOfPairFlag())) { throw new PicardException("Illegal mate state: " + record1.getReadName()); } }
protected static void assertPairedMates(final SAMRecord record1, final SAMRecord record2) { if (!(record1.getFirstOfPairFlag() && record2.getSecondOfPairFlag() || record2.getFirstOfPairFlag() && record1.getSecondOfPairFlag())) { throw new PicardException("Illegal mate state: " + record1.getReadName()); } }
private void testConvertedSAMRecord(final SAMRecord converted, final SAMRecord original) { Assert.assertEquals(converted.getReadName(), original.getReadName()); Assert.assertEquals(converted.getBaseQualities(), original.getBaseQualities()); Assert.assertEquals(converted.getReadBases(), original.getReadBases()); Assert.assertEquals(converted.getStringAttribute(SAMTag.CO.name()), original.getStringAttribute(SAMTag.CO.name())); Assert.assertTrue(converted.getReadUnmappedFlag()); } }