Skip to content

Unmapped read validation causes validation errors in specifications-compliant records. #1584

@d-cameron

Description

@d-cameron

Description of the issue:

Validation of specifications-compliant unmapped records raises validation failures.

The SAM specifications state:
• Bit 0x4 is the only reliable place to tell whether the read is unmapped. If 0x4 is set, no assumptionscan be made about RNAME, POS, CIGAR, MAPQ, and bits 0x2, 0x100, and 0x800."

Your environment:

htsjdk 2.23.0

Steps to reproduce

	@Test
	public void htsjdk_mapq_unmapped_validation_violates_sam_specifications() {
		SAMRecord r = new SAMRecord(null);
		r.setReferenceName("chr");
		r.setAlignmentStart(1);
		r.setMappingQuality(1);
		r.setCigarString("1M");
		r.setReadUnmappedFlag(true);
		r.setSupplementaryAlignmentFlag(true);
		r.setSecondaryAlignment(true);
		r.setProperPairFlag(true);
		List<SAMValidationError> errors = r.isValid();
		assertEquals(0, errors.size());
	}

Expected behaviour

Test case should pass. Maybe a warning is more appropriate?

Actual behaviour

4 unnecessary validation failures are raised:

0 = {SAMValidationError@1269} "ERROR::INVALID_FLAG_PROPER_PAIR:Proper pair flag should not be set for unpaired read."
1 = {SAMValidationError@1270} "ERROR::INVALID_FLAG_NOT_PRIM_ALIGNMENT:Secondary alignment flag should not be set for unmapped read."
2 = {SAMValidationError@1271} "ERROR::INVALID_FLAG_SUPPLEMENTARY_ALIGNMENT:Supplementary alignment flag should not be set for unmapped read."
3 = {SAMValidationError@1272} "ERROR::INVALID_MAPPING_QUALITY:MAPQ should be 0 for unmapped read."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions