-
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
4 changed files
with
68 additions
and
1 deletion.
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
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,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 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 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; | ||
} | ||
} | ||
} |
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,27 @@ | ||
import { jest } from '@jest/globals'; | ||
import { Pept2interpro } from "../../../lib/commands/unipept/pept2interpro"; | ||
|
||
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 Pept2interpro(); | ||
await command.run(["AALTER"], { header: true, format: "csv" }); | ||
expect(output[0].startsWith("peptide,total_protein_count,ipr_code,ipr_protein_count")).toBeTruthy(); | ||
expect(output[1].startsWith("AALTER,3310,IPR003613")).toBeTruthy(); | ||
expect(output.length).toBe(2); | ||
}); | ||
|
||
test('test with fasta', async () => { | ||
const command = new Pept2interpro(); | ||
await command.run([">test", "AALTER"], { header: true, format: "csv" }); | ||
expect(output[0].startsWith("fasta_header,peptide,total_protein_count,ipr_code,ipr_protein_count")).toBeTruthy(); | ||
expect(output[1].startsWith(">test,AALTER,3310,IPR003613")).toBeTruthy(); | ||
expect(output.length).toBe(2); | ||
}); |