Skip to content

Commit

Permalink
Merge pull request #180 from unipept/next-unipept-subcommands
Browse files Browse the repository at this point in the history
Implement all unipept subcommands and tests
  • Loading branch information
bmesuere authored Aug 6, 2024
2 parents eac4282 + e7c2365 commit cc21dad
Show file tree
Hide file tree
Showing 27 changed files with 714 additions and 9 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default [
{
rules: {
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/ban-ts-comment": "off",
},
ignores: ["dist/"]
}
Expand Down
22 changes: 21 additions & 1 deletion lib/commands/unipept.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { BaseCommand } from './base_command.js';
import { Pept2ec } from './unipept/pept2ec.js';
import { Pept2funct } from './unipept/pept2funct.js';
import { Pept2go } from './unipept/pept2go.js';
import { Pept2interpro } from './unipept/pept2interpro.js';
import { Pept2lca } from './unipept/pept2lca.js';
import { Pept2prot } from './unipept/pept2prot.js';
import { Pept2taxa } from './unipept/pept2taxa.js';
import { Peptinfo } from './unipept/peptinfo.js';
import { Protinfo } from './unipept/protinfo.js';
import { Taxa2lca } from './unipept/taxa2lca.js';
import { Taxonomy } from './unipept/taxonomy.js';

export class Unipept extends BaseCommand {

Expand All @@ -19,7 +29,17 @@ The command will give priority to the first way the input is passed, in the orde
this.program
.summary("Command line interface to Unipept web services.")
.description(this.description)
.addCommand(new Pept2lca().command);
.addCommand(new Pept2ec().command)
.addCommand(new Pept2funct().command)
.addCommand(new Pept2go().command)
.addCommand(new Pept2interpro().command)
.addCommand(new Pept2lca().command)
.addCommand(new Pept2prot().command)
.addCommand(new Pept2taxa().command)
.addCommand(new Peptinfo().command)
.addCommand(new Protinfo().command)
.addCommand(new Taxa2lca().command)
.addCommand(new Taxonomy().command);
}

async run(args?: string[]) {
Expand Down
38 changes: 38 additions & 0 deletions lib/commands/unipept/pept2ec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2ec extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2ec command retrieves from Unipept the set of EC numbers from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2ec");

this.command
.summary("Fetch EC numbers of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "Also return the names of the EC numbers. 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 100;
} else {
return 1000;
}
}
}
38 changes: 38 additions & 0 deletions lib/commands/unipept/pept2funct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2funct extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2funct command retrieves from Unipept the set of EC numbers and GO terms from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2funct");

this.command
.summary("Fetch EC numbers, GO terms and InterPro codes of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "Also return the names of the EC numbers, GO terms and InterPro codes. 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 100;
} else {
return 1000;
}
}
}
38 changes: 38 additions & 0 deletions lib/commands/unipept/pept2go.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2go extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2go command retrieves from Unipept the set of GO terms from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2go");

this.command
.summary("Fetch GO terms of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "Also return the names of the GO terms. 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 100;
} else {
return 1000;
}
}
}
38 changes: 38 additions & 0 deletions lib/commands/unipept/pept2interpro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2interpro extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2interpro command retrieves from Unipept the set of InterPro entries from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2interpro");

this.command
.summary("Fetch InterPro entries of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "Also return the names of the InterPro entries. 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 100;
} else {
return 1000;
}
}
}
38 changes: 38 additions & 0 deletions lib/commands/unipept/pept2prot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2prot extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2prot command retrieves from Unipept all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2prot");

this.command
.summary("Fetch UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "report all information fields of UniProt entries 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 5;
} else {
return 10;
}
}
}
34 changes: 34 additions & 0 deletions lib/commands/unipept/pept2taxa.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Pept2taxa extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept pept2taxa command retrieves from Unipept the set of taxa from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("pept2taxa");

this.command
.summary("Fetch taxa of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
return 5;
}
}
38 changes: 38 additions & 0 deletions lib/commands/unipept/peptinfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Peptinfo extends UnipeptSubcommand {

readonly description = `For each tryptic peptide the unipept peptinfo command retrieves from Unipept the functional information and the lowest common ancestor of the set of taxa from all UniProt entries whose protein sequence contains an exact matches to the tryptic peptide. 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 tryptic peptides 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 tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.`;

constructor() {
super("peptinfo");

this.command
.summary("Fetch functional information and the taxonomic lowest common ancestor of UniProt entries that match tryptic peptides.")
.description(this.description)
.option("-e, --equate", "equate isoleucine (I) and leucine (L) when matching peptides")
.option("-a, --all", "report the names of the functional annotations and 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("[peptides...]", "optionally, 1 or more peptides")
.action((args, options) => this.run(args, options));
}

requiredFields(): string[] {
return ["peptide"];
}

defaultBatchSize(): number {
if (this.options.all) {
return 100;
} else {
return 1000;
}
}
}
32 changes: 32 additions & 0 deletions lib/commands/unipept/protinfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Option } from "commander";
import { UnipeptSubcommand } from "./unipept_subcommand.js";

export class Protinfo extends UnipeptSubcommand {

readonly description = `For each UniProt id the unipept protinfo command retrieves from Unipept the functional information and the NCBI id. The command expects a list of UniProt ids 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 protein id's are passed, in the order as listed above. Text files and standard input should have one protein id per line.`;

constructor() {
super("protinfo");

this.command
.summary("Fetch functional and taxonomic information of UniProt ids")
.description(this.description)
.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));
}

requiredFields(): string[] {
return ["protein"];
}

defaultBatchSize(): number {
return 1000;
}
}
29 changes: 29 additions & 0 deletions lib/commands/unipept/taxa2lca.ts
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 taxon id 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("[taxonids...]", "optionally, 1 or more taxon ids")
.action((args, options) => this.run(args, options));
}

defaultBatchSize(): number {
throw new Error("Batch size not needed for this command.");
}
}
Loading

0 comments on commit cc21dad

Please sign in to comment.