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

Show top100 features for metaT #295

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Metatranscriptome(props) {
<Annotation title={'Annotation Result'} result={props.result['annotation-stats']} userType={props.type} allExpand={props.allExpand} allClosed={props.allClosed} />
}
{props.result['readMapping-features'] &&
<ReadMapping title={'Read Mapping Result'} project={props.project} tooLarge={props.result['readMapping-features-too-large']} features={props.result['readMapping-features']} userType={props.type} allExpand={props.allExpand} allClosed={props.allClosed} />
<ReadMapping title={'Read Mapping Result'} project={props.project} tooLarge={props.result['readMapping-features-too-large']} features={props.result['readMapping-features']} topFeatures={props.result['readMapping-top_features']} userType={props.type} allExpand={props.allExpand} allClosed={props.allClosed} />
}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function ReadMapping(props) {
<br></br>
<a href={url + props.features} target="_blank" rel="noreferrer" >[ Export the result as TSV ]</a>
<br></br><br></br>
Top 100 features
<br></br>
<FeaturesTable data={props.topFeatures} />
<br></br>
</>
: <>
<FeaturesTable data={props.features} />
Expand Down
51 changes: 19 additions & 32 deletions webapp/server/util/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,18 @@ const generateWorkflowResult = function (proj) {
} else if (workflowConf.workflow.name === 'Metatranscriptome') {
const dirs = fs.readdirSync(outdir);
dirs.forEach(function (dir) {
if (dir === 'qa') {
const files = fs.readdirSync(outdir + "/qa");
if (dir === 'qa' || dir === 'readsQC') {
const files = fs.readdirSync(outdir + "/" + dir);
files.forEach(function (file) {
if (file.endsWith("_stats.json")) {
result['readsQC-stats'] = JSON.parse(fs.readFileSync(outdir + "/qa/" + file));
}
});
}
if (dir === 'readsQC') {
const files = fs.readdirSync(outdir + "/readsQC");
files.forEach(function (file) {
if (file.endsWith("_stats.json")) {
result['readsQC-stats'] = JSON.parse(fs.readFileSync(outdir + "/readsQC/" + file));
result['readsQC-stats'] = JSON.parse(fs.readFileSync(outdir + "/" + dir + "/" + file));
}
});
}
else if (dir === 'assembly') {
const files = fs.readdirSync(outdir + "/assembly");
files.forEach(function (file) {
if (file.endsWith("_stats.json")) {
if (file.endsWith("stats.json")) {
result['assembly-stats'] = JSON.parse(fs.readFileSync(outdir + "/assembly/" + file));
}
});
Expand All @@ -221,32 +213,27 @@ const generateWorkflowResult = function (proj) {
}
});
}
else if (dir === 'metat_output') {
const files = fs.readdirSync(outdir + "/metat_output");
else if (dir === 'metat_output' || dir === 'readMapping') {
const files = fs.readdirSync(outdir + "/" + dir);
files.forEach(function (file) {
if (file.endsWith("_sorted_features.tsv")) {
var rows = parseInt(execSync("wc -l < " + outdir + "/metat_output/" + file).toString().trim());
if (rows > config.IO.MAX_DATATABLE_ROWS) {
result['readMapping-features-too-large'] = true;
result['readMapping-features'] = "output/Metatranscriptomics/metat_output/" + file;
} else {
result['readMapping-features-too-large'] = false;
result['readMapping-features'] = Papa.parse(fs.readFileSync(outdir + "/metat_output/" + file).toString(), { delimiter: '\t', header: true, skipEmptyLines: true }).data;
if (file.endsWith("sorted_features.tsv")) {
const jsonFile = file.replace('.tsv', '.json');
let topFeatures = "top100_features.json";
if (!fs.existsSync(outdir + "/" + dir + "/" + topFeatures)) {
topFeatures = file.replace('_sorted_features.tsv', '_top100_features.json');
}
}
});
}
else if (dir === 'readMapping') {
const files = fs.readdirSync(outdir + "/readMapping");
files.forEach(function (file) {
if (file.endsWith("_sorted_features.tsv")) {
var rows = parseInt(execSync("wc -l < " + outdir + "/readMapping/" + file).toString().trim());
var rows = parseInt(execSync("wc -l < " + outdir + "/" + dir + "/" + file).toString().trim());
if (rows > config.IO.MAX_DATATABLE_ROWS) {
result['readMapping-features-too-large'] = true;
result['readMapping-features'] = "output/Metatranscriptomics/readMapping/" + file;
result['readMapping-features'] = "output/Metatranscriptomics/" + dir + "/" + file;
result['readMapping-top_features'] = JSON.parse(fs.readFileSync(outdir + "/" + dir + "/" + topFeatures));
} else {
result['readMapping-features-too-large'] = false;
result['readMapping-features'] = Papa.parse(fs.readFileSync(outdir + "/readMapping/" + file).toString(), { delimiter: '\t', header: true, skipEmptyLines: true }).data;
if (fs.existsSync(outdir + "/" + dir + "/" + jsonFile)) {
result['readMapping-features'] = JSON.parse(fs.readFileSync(outdir + "/" + dir + "/" + jsonFile));
} else {
result['readMapping-features'] = Papa.parse(fs.readFileSync(outdir + "/" + dir + "/" + file).toString(), { delimiter: '\t', header: true, skipEmptyLines: true }).data;
}
}
}
});
Expand Down