-
Notifications
You must be signed in to change notification settings - Fork 20
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
Added sankey plot using taxonomy report #96
Open
snjlee58
wants to merge
9
commits into
soedinglab:master
Choose a base branch
from
snjlee58:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,555
−12
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96abd34
added taxonomyreport data to hits results
snjlee58 adbd9c0
Added svg canvas for rendering sankey
snjlee58 0bd0315
Added nodes and links to sankey (needs adjusting)
snjlee58 91574f1
Removed dummy data and fixed missing links
snjlee58 f9b807b
Adjusted size of sankey to fill screen width and handle responsive si…
snjlee58 677a6b8
Added hover tooltip to sankey
snjlee58 c5e8bb5
Removed unneeded code
snjlee58 5051a19
Added d3 sankey dependencies
snjlee58 3bd120c
Resolved PR review comments
snjlee58 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,16 @@ type FastaEntry struct { | |
type SearchResult struct { | ||
Database string `json:"db"` | ||
Alignments interface{} `json:"alignments"` | ||
TaxonomyReport interface{} `json:"taxonomyreport"` | ||
} | ||
|
||
type TaxonomyReport struct { | ||
Proportion float64 `json:"proportion"` | ||
CladeReads int `json:"clade_reads"` | ||
TaxonReads int `json:"taxon_reads"` | ||
Rank string `json:"rank"` | ||
TaxonID string `json:"taxon_id"` | ||
ScientificName string `json:"name"` | ||
} | ||
|
||
func dbpaths(path string) (string, string) { | ||
|
@@ -320,13 +330,76 @@ func ReadAlignments[T any, U interface{ ~uint32 | ~int64 }](id Id, entries []U, | |
all = append(all, results) | ||
} | ||
reader.Delete() | ||
|
||
// Read the taxonomy report | ||
taxonomyReportPath := filepath.Join(base, "alis_afsp_report") | ||
taxonomyReport, err := ReadTaxonomyReport(taxonomyReportPath) | ||
if err != nil { | ||
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. Should this not return an empty taxonomy report if the file does not exist? |
||
return res, err | ||
} | ||
|
||
base := filepath.Base(name) | ||
res = append(res, SearchResult{strings.TrimPrefix(base, "alis_"), all}) | ||
res = append(res, SearchResult{ | ||
strings.TrimPrefix(base, "alis_"), | ||
all, | ||
taxonomyReport, // Include taxonomy report | ||
}) | ||
} | ||
|
||
return res, nil | ||
} | ||
|
||
func ReadTaxonomyReport(filePath string) ([]TaxonomyReport, error) { | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer file.Close() | ||
|
||
var reports []TaxonomyReport | ||
scanner := bufio.NewScanner(file) | ||
|
||
for scanner.Scan() { | ||
line := scanner.Text() | ||
fields := strings.Split(line, "\t") | ||
if len(fields) < 6 { | ||
return nil, err | ||
} | ||
|
||
// Parse the fields | ||
proportion, err := strconv.ParseFloat(fields[0], 64) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
cladeReads, err := strconv.Atoi(fields[1]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
taxonReads, err := strconv.Atoi(fields[2]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
report := TaxonomyReport{ | ||
Proportion: proportion, | ||
CladeReads: cladeReads, | ||
TaxonReads: taxonReads, | ||
Rank: fields[3], | ||
TaxonID: fields[4], | ||
ScientificName: strings.TrimSpace(fields[5]), | ||
} | ||
reports = append(reports, report) | ||
} | ||
|
||
if err := scanner.Err(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return reports, nil | ||
} | ||
|
||
func Alignments(id Id, entry []int64, databases []string, jobsbase string) ([]SearchResult, error) { | ||
return ReadAlignments[AlignmentEntry, int64](id, entry, databases, jobsbase) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,9 @@ | |
</v-btn> | ||
</v-btn-toggle> | ||
</v-flex> | ||
|
||
<v-flex> | ||
<SankeyDiagram :rawData="hits.results[0].taxonomyreport"></SankeyDiagram> | ||
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. Does this need a v-if for when hits is still null? |
||
</v-flex> | ||
<table class="v-table result-table" style="position:relativ; margin-bottom: 3em;"> | ||
<colgroup> | ||
<template v-if="isComplex"> | ||
|
@@ -251,6 +253,7 @@ | |
import Panel from './Panel.vue'; | ||
import AlignmentPanel from './AlignmentPanel.vue'; | ||
import Ruler from './Ruler.vue'; | ||
import SankeyDiagram from './SankeyDiagram.vue'; | ||
|
||
import { debounce } from './lib/debounce'; | ||
|
||
|
@@ -265,7 +268,7 @@ function getAbsOffsetTop($el) { | |
|
||
export default { | ||
name: 'ResultView', | ||
components: { Panel, AlignmentPanel, Ruler }, | ||
components: { Panel, AlignmentPanel, Ruler, SankeyDiagram }, | ||
data() { | ||
return { | ||
alignment: null, | ||
|
@@ -424,7 +427,6 @@ src: url(assets/InconsolataClustal2.woff2), | |
} | ||
} | ||
|
||
|
||
.theme--dark { | ||
.result-table { | ||
a:not([href]) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should probably be "alis_"+db+"_report"