[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAMUtils:getOtherCanonicalAlignments extract 'SA' tag and return a list of supplementary alignments #685

Merged
merged 5 commits into from
Aug 25, 2016

Conversation

lindenb
Copy link
Contributor
@lindenb lindenb commented Aug 16, 2016

Description

I've added a new function getOtherCanonicalAlignments in SAMUtils. This function is used to extract the 'SA' tag of a SAMRecord as a List<SAMRecord>of supplementary alignements.

    /**
     * Extract a List of 'other canonical alignments' from a SAM record. Those alignments are stored as a string in the 'SA' tag as defined
     * in the SAM specification.
     * Each record in the List is a non-paired read.
     * The name, sequence and qualities are copied from the original record
     * The SAM flag is set to <code>SUPPLEMENTARY_ALIGNMENT (+ READ_REVERSE_STRAND )</code>
     * @param record must be non null and must have a non-null associated header.
     * @return a list of 'other canonical alignments' SAMRecords. The list is empty if the 'SA' attribute is missing.
     */
public static List<SAMRecord> getOtherCanonicalAlignments(final SAMRecord record)
  • testOtherCanonicalAlignments was added to SAMUtilsTest ( create one read with SA flag, check the values of the supplementary alignments)

PS: The SA tag is defined in the spec as

Other canonical alignments in a chimeric alignment, formatted as a semicolon-delimited list: (rname,pos,strand,CIGAR,mapQ,NM;)+. Each element in the list represents a part of the chimeric alignment.

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 68.827% when pulling 1a8c36a on lindenb:sam_xa into c8202f2 on samtools:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 68.833% when pulling 1a8c36a on lindenb:sam_xa into c8202f2 on samtools:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 68.827% when pulling 1a8c36a on lindenb:sam_xa into c8202f2 on samtools:master.

@droazen
Copy link
Contributor
droazen commented Aug 16, 2016

@jamesemery could you please review?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 68.835% when pulling de3873f on lindenb:sam_xa into c8202f2 on samtools:master.

(commaStrs[2].equals("+") ? 0 : SAMFlag.READ_REVERSE_STRAND.flag) );
otherRec.setCigar( TextCigarCodec.decode( commaStrs[3] ) );
otherRec.setMappingQuality( Integer.parseInt(commaStrs[4]) );
otherRec.setAttribute( SAMTagUtil.getSingleton().NM , Integer.parseInt(commaStrs[5]) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these .parseInt() calls open the possibility of breaking on bad input and exposing a stack trace to the user. Perhaps you should emit a SAMException if any of these fields don't parse correctly?

@lindenb
Copy link
Contributor Author
lindenb commented Aug 17, 2016

Thank you for the review and back to you @jamesemery

  • I've considered the mate
  • surrounded parseInt with try catch
  • considered the first suppl alignment if the read is supplementary
  • moved the Pattern out of the function.
  • updated the test

NB: I'll be away from github for a few days.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 68.841% when pulling 899227b on lindenb:sam_xa into c8202f2 on samtools:master.

@jamesemery
Copy link
Contributor

@droazen These changes look good to me

@lbergelson lbergelson merged commit c3d5a88 into samtools:master Aug 25, 2016
@lbergelson
Copy link
Member

Thanks @lindenb and @jamesemery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants