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

Separate Nucleotide and Gap/N Mutations in Hover infoPanel #552

Merged
merged 3 commits into from
May 7, 2018

Conversation

emmahodcroft
Copy link
Member

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:
infopanel_n_4

If you only have Gaps/Ns, this is all that's shown:
infopanel_n_2

Similarly, if only nucleotide (base-to-base) mutations, that's only shown:
infopanel_n_3

This is my first foray into javascript so there may be better/more standard ways to do some of this, please edit if so :)

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) => {
Copy link
Member

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.

Copy link
Member

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) === "-"
Copy link
Member

Choose a reason for hiding this comment

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

<br/><br/>
{infoLineJSX("Gap/N mutations:", mGap)}
{infoLineJSX("Nucleotide mutations:", m)}
<div height="5"/>
Copy link
Member

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.

@trvrb
Copy link
Member

trvrb commented May 7, 2018

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.

@trvrb trvrb merged commit 4a72792 into master May 7, 2018
@trvrb trvrb deleted the sort_N_infopanel branch May 7, 2018 15:38
@emmahodcroft
Copy link
Member Author

Thank you, Trevor, for the comments! Javascript is definitely different from the strict world of Java, so it's good to learn.
James did mention linters when we spoke about auspice last week, but I had completely forgotten about it until now. I will get one!

@jameshadfield
Copy link
Member

Thanks @emmahodcroft
👍 for the linter - it's super useful

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.

3 participants