-
Notifications
You must be signed in to change notification settings - Fork 244
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
Sam record pair identification depends on required SAM fields #994
Changes from 2 commits
ba91430
272634a
7843453
3c01a88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package htsjdk.samtools; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
public class SAMRecordTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately it looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, done here. |
||
|
||
@Test | ||
public void testRecordsArePairIfTheyLinkEachOtherInMateFields() { | ||
final SAMRecord first = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
first.setAlignmentStart(42); | ||
first.setReferenceName("chrm1"); | ||
final SAMRecord second = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
second.setAlignmentStart(142); | ||
second.setReferenceName("chrm2"); | ||
|
||
first.setMateAlignmentStart(second.getAlignmentStart()); | ||
first.setMateReferenceName(second.getReferenceName()); | ||
second.setMateAlignmentStart(first.getAlignmentStart()); | ||
second.setMateReferenceName(first.getReferenceName()); | ||
|
||
Assert.assertTrue(first.isPair(second)); | ||
Assert.assertTrue(second.isPair(first)); | ||
} | ||
|
||
@Test | ||
public void testRecordsArePairIfTheyHaveNoMateFields() { | ||
final SAMRecord first = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
first.setAlignmentStart(42); | ||
first.setReferenceName("chrm1"); | ||
final SAMRecord second = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
second.setAlignmentStart(142); | ||
second.setReferenceName("chrm2"); | ||
|
||
Assert.assertFalse(first.isPair(second)); | ||
Assert.assertFalse(second.isPair(first)); | ||
} | ||
|
||
@Test | ||
public void testRecordsArePairIdentificationDoesNotThrowNpe() { | ||
final SAMRecord first = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
|
||
Assert.assertFalse(first.isPair(null)); | ||
} | ||
|
||
@Test | ||
public void testRecordsArePairIdentificationDoesNotThrowNpeIfFieldsAreUndefined() { | ||
final SAMRecord first = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
final SAMRecord second = new SAMRecord(new SAMFileHeader(new SAMSequenceDictionary())); | ||
|
||
Assert.assertFalse(first.isPair(second)); | ||
Assert.assertFalse(second.isPair(first)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about this function, a mate is another record with the same query name...why are you checking everything else, and not the QNAME? I'm sure there's a reason, but it should be explained in the javadoc as it is not obvious at all!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the remark, I think it does matter in
SamRecord
and I fixed it, but if we implement it inHitsForInsert
it doesn't matter because it deals records with the sameQNAME
only. Here is the logic that produces HitsForInsert.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to move this to
SamPairUtil
, because there are already a lot of methods inSAMRecord
that may be better to be used within an utility class. Eventually, reads would be accessed by an interface (e.g., #985) and thus this methods may live in an utility class that is implementation-independent.