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

Updating SAMTag and SAMTagUtils #1208

Merged
merged 7 commits into from
Nov 14, 2018
Merged

Updating SAMTag and SAMTagUtils #1208

merged 7 commits into from
Nov 14, 2018

Conversation

lbergelson
Copy link
Member

Description

This PR does several things:

  1. It updates the list of tags in SAMTags and SAMTagUtils to include all the tags currently in the spec
  2. It deprecates tags that are listed as "for backwards compatibility only", this should hopefully signal to downstream users that they should no longer be generating these tags but may still support them for backwards compatibility.
  3. It makes all methods in SAMTagUtil static and makes the class final. This will break any existing subclasses. Searching github and google for "extends SAMTagUtil" results in 0 results so it's unlikely that anyone will be impacted negatively by this.
  4. Refactoring to make use of newly static SAMTagUtil methods.
  • 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)

Copy link
Contributor

@pshapiro4broad pshapiro4broad left a comment

Choose a reason for hiding this comment

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

Another approach would be to move the binary tag directly into the SAMTag enum. e.g.

public enum SAMTag {
    AM,
    ...
    U2,
    UQ;

    public final short binaryTag;

    SAMTag() {
        binaryTag = makeBinaryTag(this.name());
    }
}

You could also move makeStringTag(), makeBinaryTag() into SAMTag, and delete SAMTagUtil, or deprecate it and forward the methods and fields for now.

/**
* This constructor is public despite being a utility class for backwards compatibility reasons.
*/
public SAMTagUtil(){}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be deprecated too?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, good call

src/main/java/htsjdk/samtools/SAMTagUtil.java Outdated Show resolved Hide resolved
} else {
encodedTag = tagCodec.encode(tagUtil.makeStringTag(attribute.tag), attribute.value);
encodedTag = tagCodec.encode(SAMTagUtil.makeStringTag(attribute.tag), attribute.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that tagUtil is unused it should be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

did this, good catch

@lbergelson
Copy link
Member Author

@pshapiro4broad @magicDGS Thanks for the reviews.

@codecov-io
Copy link

codecov-io commented Nov 5, 2018

Codecov Report

Merging #1208 into master will increase coverage by 0.058%.
The diff coverage is 89.516%.

@@               Coverage Diff               @@
##              master     #1208       +/-   ##
===============================================
+ Coverage     68.978%   69.037%   +0.058%     
- Complexity      8073      8092       +19     
===============================================
  Files            539       539               
  Lines          32587     32658       +71     
  Branches        5510      5513        +3     
===============================================
+ Hits           22478     22546       +68     
- Misses          7903      7905        +2     
- Partials        2206      2207        +1
Impacted Files Coverage Δ Complexity Δ
...main/java/htsjdk/samtools/SAMRecordSetBuilder.java 89.431% <0%> (ø) 71 <0> (ø) ⬇️
...ain/java/htsjdk/samtools/cram/structure/Slice.java 44.545% <0%> (ø) 20 <0> (ø) ⬇️
...rc/main/java/htsjdk/samtools/SamFileValidator.java 84.954% <100%> (ø) 81 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/SAMUtils.java 59.343% <100%> (ø) 125 <0> (ø) ⬇️
...ain/java/htsjdk/samtools/SAMBinaryTagAndValue.java 84.884% <100%> (ø) 54 <0> (ø) ⬇️
...n/java/htsjdk/samtools/cram/structure/SliceIO.java 88.889% <100%> (ø) 15 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/BAMRecord.java 81.503% <100%> (ø) 51 <4> (ø) ⬇️
...n/java/htsjdk/samtools/cram/structure/ReadTag.java 70.563% <100%> (ø) 65 <0> (ø) ⬇️
...dk/samtools/SAMBinaryTagAndUnsignedArrayValue.java 69.231% <100%> (ø) 5 <0> (ø) ⬇️
...ng/huffman/codec/CanonicalHuffmanByteEncoding.java 43.75% <33.333%> (ø) 5 <0> (ø) ⬇️
... and 11 more

Copy link
Contributor

@pshapiro4broad pshapiro4broad left a comment

Choose a reason for hiding this comment

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

Looks good to me

src/main/java/htsjdk/samtools/SAMTag.java Show resolved Hide resolved
src/main/java/htsjdk/samtools/SAMTag.java Show resolved Hide resolved
lbergelson and others added 7 commits November 14, 2018 13:02
* adding new tags that were introduced in the spec
  * Cellular barcode tags s CB, CR, and CY added
  * Unique mollecular identifier tags BZ, MI, OX, QX, and RX added.

* deprecating tag constants that are for backward compatibility only
* Making methods in SAMTagUtil final and deprecating the use of the getSingleton() method.
* This is a breaking change to SAMTagUtil, it will break any subclasses, all other uses should be compatible
@lbergelson lbergelson merged commit 5b897e4 into master Nov 14, 2018
@lbergelson lbergelson deleted the lb_update_sam_tags branch November 14, 2018 18:44
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.

4 participants