-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
2 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Option } from "commander"; | ||
import { UnipeptSubcommand } from "./unipept_subcommand.js"; | ||
|
||
export class Taxa2lca extends UnipeptSubcommand { | ||
|
||
readonly description = `The unipept taxa2lca command computes the lowest common ancestor of a given list of NCBI Taxonomy Identifiers. The lowest common ancestor is based on the topology of the Unipept Taxonomy -- a cleaned up version of the NCBI Taxonomy -- and is itself a record from the NCBI Taxonomy. The command expects a list of NCBI Taxonomy Identifiers that are passed | ||
- as separate command line arguments | ||
- in a text file that is passed as an argument to the -i option | ||
- to standard input | ||
The command will give priority to the first way NCBI Taxonomy Identifiers are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`; | ||
|
||
constructor() { | ||
super("taxa2lca"); | ||
|
||
this.command | ||
.summary("Compute taxonomic lowest common ancestor for given list of taxa.") | ||
.description(this.description) | ||
.option("-a, --all", "report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.") | ||
.addOption(new Option("-s --select <fields...>", "select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.")) | ||
.argument("[proteins...]", "optionally, 1 or more UniProt ids") | ||
.action((args, options) => this.run(args, options)); | ||
} | ||
|
||
defaultBatchSize(): number { | ||
throw new Error("Batch size not needed for this command."); | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { jest } from '@jest/globals'; | ||
import { Taxa2lca } from "../../../lib/commands/unipept/taxa2lca"; | ||
|
||
let output: string[]; | ||
jest | ||
.spyOn(process.stdout, "write") | ||
.mockImplementation((data: unknown) => { output.push(data as string); return true; }); | ||
|
||
beforeEach(() => { | ||
output = []; | ||
}); | ||
|
||
test('test with default args', async () => { | ||
const command = new Taxa2lca(); | ||
await command.run(["216816", "1680"], { header: true, format: "csv" }); | ||
expect(output[0].startsWith("taxon_id,taxon_name,taxon_rank")).toBeTruthy(); | ||
expect(output[1].startsWith("1678,Bifidobacterium,genus")).toBeTruthy(); | ||
expect(output.length).toBe(2); | ||
}); |