-
Notifications
You must be signed in to change notification settings - Fork 242
- implementing the spec change in #1238
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
Changes from 2 commits
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 |
|---|---|---|
|
|
@@ -57,10 +57,10 @@ public class SAMSequenceRecord extends AbstractSAMHeaderRecord implements Clonea | |
|
|
||
|
|
||
| /** | ||
| * This is not a valid sequence name, because it is reserved in the MRNM field of SAM text format | ||
| * This is not a valid sequence name, because it is reserved in the RNEXT field of SAM text format | ||
| * to mean "same reference as RNAME field." | ||
| */ | ||
| public static final String RESERVED_MRNM_SEQUENCE_NAME = "="; | ||
| public static final String RESERVED_RNEXT_SEQUENCE_NAME = "="; | ||
|
|
||
| /** | ||
| * The standard tags are stored in text header without type information, because the type of these tags is known. | ||
|
|
@@ -70,10 +70,12 @@ public class SAMSequenceRecord extends AbstractSAMHeaderRecord implements Clonea | |
| SPECIES_TAG)); | ||
|
|
||
| // Split on any whitespace | ||
| private static final Pattern SEQUENCE_NAME_SPLITTER = Pattern.compile("\\s"); | ||
| private static final Pattern SEQUENCE_NAME_SPLITTER = Pattern.compile("[\\s]"); | ||
|
Member
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. delete this if unused |
||
| // These are the chars matched by \\s. | ||
| private static final char[] WHITESPACE_CHARS = {' ', '\t', '\n', '\013', '\f', '\r'}; // \013 is vertical tab | ||
|
|
||
| private static Pattern LEGAL_RNAME_PATTERN = Pattern.compile("[0-9A-Za-z!#$%&+./:;?@^_|~-][0-9A-Za-z!#$%&*+./:;=?@^_|~-]*"); | ||
|
Member
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. make this final |
||
|
|
||
| /** | ||
| * @deprecated Use {@link #SAMSequenceRecord(String, int)} instead. | ||
| * sequenceLength is required for the object to be considered valid. | ||
|
|
@@ -85,8 +87,8 @@ public SAMSequenceRecord(final String name) { | |
|
|
||
| public SAMSequenceRecord(final String name, final int sequenceLength) { | ||
| if (name != null) { | ||
| if (SEQUENCE_NAME_SPLITTER.matcher(name).find()) { | ||
| throw new SAMException("Sequence name contains invalid character: " + name); | ||
| if (!LEGAL_RNAME_PATTERN.matcher(name).useAnchoringBounds(true).matches()) { | ||
|
Member
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. move this into the validate method
Member
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.
|
||
| throw new SAMException(String.format("Sequence name '%s' doesn't match regex: '%s' ", name, LEGAL_RNAME_PATTERN)); | ||
| } | ||
| validateSequenceName(name); | ||
| mSequenceName = name.intern(); | ||
|
|
@@ -204,8 +206,8 @@ public static String truncateSequenceName(final String sequenceName) { | |
| * Throw an exception if the sequence name is not valid. | ||
| */ | ||
| public static void validateSequenceName(final String name) { | ||
| if (RESERVED_MRNM_SEQUENCE_NAME.equals(name)) { | ||
| throw new SAMException("'" + RESERVED_MRNM_SEQUENCE_NAME + "' is not a valid sequence name"); | ||
| if (RESERVED_RNEXT_SEQUENCE_NAME.equals(name)) { | ||
| throw new SAMException("'" + RESERVED_RNEXT_SEQUENCE_NAME + "' is not a valid sequence name"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
deprecate this instead of just renaming it