Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Expose the set of tags to reverse and reverse complement as parameters. #673
Conversation
nh13
was assigned
by tfenne
Aug 1, 2016
eitanbanks
and 1 other
commented on an outdated diff
Aug 1, 2016
| /** | ||
| * Reverse-complement all known sequence and base quality attributes of the SAMRecord. | ||
| */ | ||
| public static void reverseComplement(final SAMRecord rec) { | ||
| + reverseComplement(rec, TAGS_TO_REVERSE_COMPLEMENT, TAGS_TO_REVERSE); | ||
| + } | ||
| + | ||
| + public static void reverseComplement(final SAMRecord rec, Collection<String> tagsToRevcomp, Collection<String> tagsToReverse) { |
|
|
eitanbanks
commented on the diff
Aug 1, 2016
| } | ||
| - for (final short stringTag : STRING_TAGS_TO_REVERSE) { | ||
| - final String value = (String)rec.getAttribute(stringTag); | ||
| - if (value != null) { | ||
| - rec.setAttribute(stringTag, StringUtil.reverseString(value)); | ||
| + | ||
| + // Deal with tags that needed to just be reversed | ||
| + if (tagsToReverse != null) { | ||
| + for (final String tag : tagsToReverse) { | ||
| + Object value = rec.getAttribute(tag); | ||
| + if (value != null) { | ||
| + if (value instanceof String) { | ||
| + value = StringUtil.reverseString((String) value); | ||
| + } | ||
| + else if (value.getClass().isArray()) { |
eitanbanks
Contributor
|
|
Comments made. @nh13 should feel free to comment himself (as the assigned reviewer) or just assign to me. |
|
@tfenne |
tfenne
was assigned
by nh13
Aug 1, 2016
yfarjoun
and 1 other
commented on an outdated diff
Aug 2, 2016
| /** | ||
| * @author alecw@broadinstitute.org | ||
| */ | ||
| public class SAMRecordUtil { | ||
| - | ||
| - /** List of String tags that must be reversed if present when a SAMRecord is reverseComplemented */ | ||
| - private static final short[] STRING_TAGS_TO_REVERSE = { | ||
| - SAMTagUtil.getSingleton().U2, | ||
| - SAMTagUtil.getSingleton().OQ | ||
| - }; | ||
| + private static List<String> TAGS_TO_REVERSE_COMPLEMENT = Arrays.asList(SAMTag.E2.name(), SAMTag.SQ.name()); | ||
| + private static List<String> TAGS_TO_REVERSE = Arrays.asList(SAMTag.OQ.name(), SAMTag.U2.name()); | ||
| /** | ||
| * Reverse-complement all known sequence and base quality attributes of the SAMRecord. |
|
|
yfarjoun
commented on the diff
Aug 2, 2016
| + | ||
| + // Deal with tags that needed to just be reversed | ||
| + if (tagsToReverse != null) { | ||
| + for (final String tag : tagsToReverse) { | ||
| + Object value = rec.getAttribute(tag); | ||
| + if (value != null) { | ||
| + if (value instanceof String) { | ||
| + value = StringUtil.reverseString((String) value); | ||
| + } | ||
| + else if (value.getClass().isArray()) { | ||
| + if (value instanceof byte[]) reverseArray((byte[]) value); | ||
| + else if (value instanceof short[]) reverseArray((short[]) value); | ||
| + else if (value instanceof int[]) reverseArray((int[]) value); | ||
| + else if (value instanceof float[]) reverseArray((float[]) value); | ||
| + else throw new UnsupportedOperationException("Reversing array attribute of type " + value.getClass().getComponentType() + " not supported."); | ||
| + } |
|
|
|
Looks like just the |
tfenne
merged commit ec2d3f9
into
master
Aug 2, 2016
tfenne
deleted the
tf_rc_samrecord_params branch
Aug 2, 2016
jamesemery
added a commit
to jamesemery/htsjdk
that referenced
this pull request
Sep 1, 2016
|
|
tfenne + jamesemery |
2da42f9
|
tfenne commentedAug 1, 2016
Description
Expose the set of tags to reverse and reverse complement as parameters, so that reads can be reverse complemented and all tags that are one-value-per-base in the read can be kept in sync.
Checklist