the life in the magical kingdom of fully spec-conforming SAM files would be so... magical. For now, however, there are plenty of ways to end up with inconsistent SAM records. For instance, a SAM file with missing header will result in SAM records with ref. name set, but getReferenceIndex() returning null. This, in turn, was tripping isReadUnmapped(). The method is now fixed, so that it suffices to have *either* reference name *or* reference index set for the read to be considered mapped (the flag is still checked)

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1612 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
asivache 2009-09-14 16:04:19 +00:00
parent e03fccb223
commit a009592662
1 changed files with 11 additions and 3 deletions

View File

@ -268,8 +268,16 @@ public class AlignmentUtils {
*/
public static boolean isReadUnmapped(final SAMRecord r) {
if ( r.getReadUnmappedFlag() ) return true;
if ( r.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX ||
r.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START ) return true;
return false;
// our life would be so much easier if all sam files followed the specs. In reality,
// sam files (including those generated by maq or bwa) miss headers alltogether. When
// reading such a SAM file, reference name is set, but since there is no sequence dictionary,
// null is always returned for referenceIndex. Let's be paranoid here, and make sure that
// we do not call the read "unmapped" when it has only reference name set with ref. index missing
// or vice versa.
if ( ( r.getReferenceIndex() != null && r.getReferenceIndex() != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX
|| r.getReferenceName() != null && r.getReferenceName() != SAMRecord.NO_ALIGNMENT_REFERENCE_NAME )
&& r.getAlignmentStart() != SAMRecord.NO_ALIGNMENT_START ) return false ;
return true;
}
}