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

Modified sorting logic to sort no-node reads #440

Merged
merged 2 commits into from
May 31, 2024
Merged

Conversation

shreyasun
Copy link
Collaborator

Fixes #431

Copy link
Member

@adamnovak adamnovak left a comment

Choose a reason for hiding this comment

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

I think some of the code was reordered to add the comments and now it doesn't actually work. Also the comparison function's comment about what it does needs updating. I made some suggestions.

Comment on lines 881 to 893
function compareNoNodeReads(a, b) {
// Sort by order by segments
const segmentA = readA.path[a.pathIndex];
const segmentB = readB.path[b.pathIndex];
if (segmentA.order !== segmentB.order) {
return segmentA.order - segmentB.order;
}
// Sort by reads' source track
const readA = reads[a.readIndex];
const readB = reads[b.readIndex];
if (readA.sourceTrackID !== readB.sourceTrackID){
return readA.sourceTrackID - readB.sourceTrackID;
}
Copy link
Member

Choose a reason for hiding this comment

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

The tests are failing because the reads are not defined early enough.

Suggested change
function compareNoNodeReads(a, b) {
// Sort by order by segments
const segmentA = readA.path[a.pathIndex];
const segmentB = readB.path[b.pathIndex];
if (segmentA.order !== segmentB.order) {
return segmentA.order - segmentB.order;
}
// Sort by reads' source track
const readA = reads[a.readIndex];
const readB = reads[b.readIndex];
if (readA.sourceTrackID !== readB.sourceTrackID){
return readA.sourceTrackID - readB.sourceTrackID;
}
function compareNoNodeReads(a, b) {
// Get the reads for the segments
const readA = reads[a.readIndex];
const readB = reads[b.readIndex];
// Sort by order by segments
const segmentA = readA.path[a.pathIndex];
const segmentB = readB.path[b.pathIndex];
if (segmentA.order !== segmentB.order) {
return segmentA.order - segmentB.order;
}
// Sort by reads' source track
if (readA.sourceTrackID !== readB.sourceTrackID){
return readA.sourceTrackID - readB.sourceTrackID;
}

Comment on lines 733 to 735
console.log("elementsWithoutNode before sort:", elementsWithoutNode)
elementsWithoutNode.sort(compareNoNodeReads);
console.log("elementsWithoutNode:", elementsWithoutNode)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this logging in the final version.

Suggested change
console.log("elementsWithoutNode before sort:", elementsWithoutNode)
elementsWithoutNode.sort(compareNoNodeReads);
console.log("elementsWithoutNode:", elementsWithoutNode)
elementsWithoutNode.sort(compareNoNodeReads);

Comment on lines 879 to 880
// compare read segments which are outside of nodes
// by the y-coord of where they are coming from
Copy link
Member

Choose a reason for hiding this comment

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

This comment isn't true anymore and needs to be updated.

Suggested change
// compare read segments which are outside of nodes
// by the y-coord of where they are coming from
// Compare read segments which are outside of nodes, to sort them in a good horizontal
// and then vertical display order.

@adamnovak adamnovak merged commit 47f8f1d into master May 31, 2024
1 check passed
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.

Reads from different samples interleave oddly when skipping nodes
2 participants