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

Fix: reformat long seqs #806

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joko3ono
Copy link
Collaborator

@joko3ono joko3ono commented Oct 5, 2024

resolve wurmlab/sequenceserver-cloud#415

@joko3ono joko3ono requested a review from tadast October 5, 2024 00:00
Copy link
Collaborator

@tadast tadast left a comment

Choose a reason for hiding this comment

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

@joko3ono thanks for looking into this. Could you please add an explanation of what was the issue and how your change fixes the issue to the commit message, and also add some jest unit tests to demonstrate how it works + make sure we don't break it in future?

It's a bit hard to review the changes without context and learning what the bug is from scratch would be very time consuming as I'd have to come up with multiple test scenarios and execute them 😬

@djleite
Copy link

djleite commented Oct 15, 2024

things look almost ok

however, there needs to be correct rounding up of the final sequence length. See below that:

  • 3,999,920 bp should be 4 Mbp
  • 799,920 bp should be 800 Kbp

image
image

However...

If we want to show a greater level of precision then we can show to at least 1 decimal place for any value that has units kbp, Mbp and Gbp.

ie
divide these numbers by 1000 and round to the nearest decimal place

  • 19,299 bp = 19.3 kbp
  • 19,990 bp = 20.0 kbp

divide these numbers by 1000000 and round to the nearest decimal place

  • 199,929,999 bp = 199.9 Mbp
  • 199,990,000 bp = 200.0 Mbp

@tadast
Copy link
Collaborator

tadast commented Oct 15, 2024

@joko3ono also please make sure you add tests for the rounding so that it's not broken in future

@joko3ono joko3ono force-pushed the 415-fix-incorrect-length-of-sequence branch from e8d0b07 to 103b934 Compare October 26, 2024 19:47
@joko3ono joko3ono requested a review from tadast October 29, 2024 03:51
// threshold 0.95
// 2.95 -> 3
// 2.94 -> 2.9
const formatted = fractionalPart >= threshold ? integerPart + 1 : Math.floor(numericPart * 10) / 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this custom rounding logic threshold? Am I right in thinking that we could instead round up to 1 decimal place, then remove ".0" at the end if it's a whole number? I think it would achieve the same result with a much easier to understand and simpler code, or am I missing something?

@@ -0,0 +1,28 @@
// Import the necessary functions
import { tick_formatter, formatNumberUnits } from '../visualisation_helpers';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding the tests!

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