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

more changes to SAMTagUtil #1227

Merged
merged 4 commits into from
Nov 16, 2018
Merged

Conversation

lbergelson
Copy link
Member

  • reverting the change from constants to static variables, deprecating
    the constants instead

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)

* reverting the change from constants to static variables, deprecating
the constants instead
Copy link
Contributor

@droazen droazen left a comment

Choose a reason for hiding this comment

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

Back to @lbergelson with minor comments.

/** @deprecated reserved tag for backwards compatibility only */

Copy link
Contributor

Choose a reason for hiding this comment

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

Stray whitespace separating this comment from the thing it's commenting on

Copy link
Member Author

Choose a reason for hiding this comment

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

gone

@@ -27,10 +27,12 @@

/**
* Facility for converting between String and short representation of a SAM tag. short representation
* is used by SAM JDK internally and is much more efficient. Callers are encouraged to obtain the short
* is used by Htsjdk internally and is much more efficient. Callers are encouraged to obtain the short
Copy link
Contributor

Choose a reason for hiding this comment

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

Htsjdk -> HTSJDK?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* value for a tag of interest once, and then use the SAMRecord attribute API that takes shorts rather than
* Strings.
*
* Tags that are defined by the SAM spec are included in the enum {@link SAMTag} along with their precomputed short tag.
*
* @author [email protected]
*/
public final class SAMTagUtil {
Copy link
Contributor

@droazen droazen Nov 14, 2018

Choose a reason for hiding this comment

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

You should perhaps consider deprecating this entire class, and moving the 2 non-deprecated methods to a different location (like the SAMTag enum)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@codecov-io
Copy link

codecov-io commented Nov 14, 2018

Codecov Report

Merging #1227 into master will decrease coverage by 0.198%.
The diff coverage is 26.316%.

@@               Coverage Diff               @@
##              master     #1227       +/-   ##
===============================================
- Coverage     69.031%   68.832%   -0.198%     
+ Complexity      8077      8074        -3     
===============================================
  Files            539       539               
  Lines          32616     32617        +1     
  Branches        5510      5510               
===============================================
- Hits           22515     22451       -64     
- Misses          7894      7959       +65     
  Partials        2207      2207
Impacted Files Coverage Δ Complexity Δ
...c/main/java/htsjdk/samtools/sra/SRALazyRecord.java 71.591% <0%> (ø) 130 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/SAMTagUtil.java 0% <0%> (-98.649%) 0 <0> (-5)
...ain/java/htsjdk/samtools/cram/structure/Slice.java 44.545% <0%> (ø) 20 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/SAMTag.java 97.368% <100%> (+0.353%) 5 <2> (+2) ⬆️
...n/java/htsjdk/samtools/cram/structure/SliceIO.java 88.889% <100%> (ø) 15 <0> (ø) ⬇️
...ain/java/htsjdk/samtools/SAMBinaryTagAndValue.java 84.884% <100%> (ø) 54 <0> (ø) ⬇️
...n/java/htsjdk/samtools/cram/structure/ReadTag.java 70.563% <100%> (ø) 65 <0> (ø) ⬇️
...dk/samtools/SAMBinaryTagAndUnsignedArrayValue.java 69.231% <100%> (ø) 5 <0> (ø) ⬇️
...va/htsjdk/samtools/cram/digest/ContentDigests.java 50.467% <50%> (ø) 9 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/SAMTextWriter.java 66.292% <50%> (ø) 12 <0> (ø) ⬇️
... and 3 more

@lbergelson
Copy link
Member Author

@cmnbroad Could you take a look at this? I just deprecated the SamTagUtil entirely and moved all the functionality to SAMTag so that we wouldn't have this weird split between them.

@lbergelson lbergelson assigned cmnbroad and unassigned droazen Nov 15, 2018
@@ -140,8 +179,10 @@ public static SAMTagUtil getSingleton() {
*
* @param tag 2-character String representation of a tag name.
* @return Tag name packed as 2 ASCII bytes in a short.
* @deprecated u
Copy link
Collaborator

Choose a reason for hiding this comment

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

Forgot to finish the message....

Copy link
Member Author

Choose a reason for hiding this comment

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

woops, good catch

Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

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

One unfinished deprecation message that should be completed otherwise LGTM once tests pass.

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, just the usual collection of minor comments.

private final short shortValue = SAMTag.makeBinaryTag(this.name());;
// Cache of already-converted tags. Should speed up SAM text generation.
// Not synchronized because race condition is not a problem.
private static final String[] stringTags = new String[Short.MAX_VALUE];
Copy link
Contributor

Choose a reason for hiding this comment

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

static fields should be uppercase

Suggested change
private static final String[] stringTags = new String[Short.MAX_VALUE];
private static final String[] STRING_TAGS = new String[Short.MAX_VALUE];

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't really a constant though. My thought is that things that are constant are final, but this is a static cache that's updated with new values. It seems more confusing to make it caps since people assume those are immutable.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. I usually use all caps for any statics, since it's important to know what things are static, but I can see that all caps is typically used for constants only.

src/main/java/htsjdk/samtools/SAMTag.java Outdated Show resolved Hide resolved
}
return ret;
@Deprecated
public String makeStringTag(final short tag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be static

Suggested change
public String makeStringTag(final short tag) {
public static String makeStringTag(final short tag) {

Unless it needs to be non-static for backward compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping it non-static for backwards compatibility. I was changing them to be static but I realized that would cause confusing breaks in binary compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

This pr is basically me fixing some breaks in compatibility that I had though would be harmless but on further inspection seemd problematic.

*/
public static short makeBinaryTag(final String tag) {
@Deprecated
public short makeBinaryTag(final String tag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be static

Suggested change
public short makeBinaryTag(final String tag) {
public static short makeBinaryTag(final String tag) {

@lbergelson lbergelson dismissed droazen’s stale review November 16, 2018 15:36

These comments were addressed.

@lbergelson
Copy link
Member Author

@pshapiro4broad @cmnbroad Thank you for the reviews!

@lbergelson lbergelson merged commit 698a4c3 into master Nov 16, 2018
@lbergelson lbergelson deleted the lb_more_mucking_with_samtagutils branch November 16, 2018 15:53
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