-
Notifications
You must be signed in to change notification settings - Fork 162
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
Separate Nucleotide and Gap/N Mutations in Hover infoPanel #552
Conversation
let ngaps = d.muts.filter(mut => {return mut.slice(-1) == "N" || mut.slice(-1) == "-" | ||
|| mut.slice(0) == "N" || mut.slice(0) == "-";}) | ||
// gather muts with N/- | ||
const ngaps = d.muts.filter((mut) => { |
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.
Arrow functions are clearer with parenthesis surrounding argument.
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.
If variable is never reassigned, use const
instead of let
.
|| mut.slice(0) == "N" || mut.slice(0) == "-";}) | ||
// gather muts with N/- | ||
const ngaps = d.muts.filter((mut) => { | ||
return mut.slice(-1) === "N" || mut.slice(-1) === "-" |
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.
String comparisons should always be done with ===
or !==
: https://stackoverflow.com/questions/3586775/what-is-the-correct-way-to-check-for-string-equality-in-javascript
<br/><br/> | ||
{infoLineJSX("Gap/N mutations:", mGap)} | ||
{infoLineJSX("Nucleotide mutations:", m)} | ||
<div height="5"/> |
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.
A div
will give you more control over spacing.
This is really great @emmahodcroft. I appreciate the screenshots as well. I just made a few small stylistic tweaks. I use a "linter" to identify non-standard JavaScript and would not have noticed most of these otherwise. The linter behavior is specified here: https://github.com/nextstrain/auspice/blob/master/.eslintrc. To get it to work for me I just needed to enable a plugin in Atom (https://atom.io/packages/linter). The linter really helps me when coding JavaScript, notices typos, etc... I think this is good to go however. Thanks so much for the contribution. |
Thank you, Trevor, for the comments! Javascript is definitely different from the strict world of Java, so it's good to learn. |
Thanks @emmahodcroft |
This separates nucleotide mutations into two groups, so that 'N's and '-'s do not prevent the user from seeing base-to-base changes.
Example with both types of mutations:
If you only have Gaps/Ns, this is all that's shown:
Similarly, if only nucleotide (base-to-base) mutations, that's only shown:
This is my first foray into javascript so there may be better/more standard ways to do some of this, please edit if so :)