1- import { toFasta } from './util.ts'
2-
31import type { InterProScanResponse , InterProScanResults } from 'msa-parsers'
42
53const BASE_URL = 'https://www.ebi.ac.uk/Tools/services/rest/iprscan5'
64
75async function submitJob (
8- sequences : { id : string ; seq : string } [ ] ,
6+ sequence : { id : string ; seq : string } ,
97 programs : string [ ] ,
108 email : string ,
119) : Promise < string > {
@@ -16,13 +14,14 @@ async function submitJob(
1614 } ,
1715 body : new URLSearchParams ( {
1816 email,
19- sequence : toFasta ( sequences ) ,
17+ sequence : `> ${ sequence . id } \n ${ sequence . seq } ` ,
2018 appl : programs . join ( ',' ) ,
2119 } ) ,
2220 } )
2321
2422 if ( ! response . ok ) {
25- throw new Error ( `Failed to submit job: ${ response . statusText } ` )
23+ const text = await response . text ( )
24+ throw new Error ( `Failed to submit job: ${ response . statusText } - ${ text } ` )
2625 }
2726
2827 return response . text ( )
@@ -45,9 +44,8 @@ async function getResults(jobId: string): Promise<InterProScanResponse> {
4544}
4645
4746async function waitForJob ( jobId : string ) : Promise < void > {
48- console . log ( ` Waiting for job ${ jobId } ...` )
4947 let attempts = 0
50- const maxAttempts = 300 // 5 minutes max wait
48+ const maxAttempts = 300
5149
5250 while ( attempts < maxAttempts ) {
5351 const status = await checkStatus ( jobId )
@@ -74,25 +72,16 @@ export async function runEbiInterProScan(
7472 sequences : { id : string ; seq : string } [ ] ,
7573 programs : string [ ] ,
7674 email : string ,
77- batchSize : number ,
75+ _batchSize : number ,
7876) : Promise < InterProScanResults [ ] > {
7977 const allResults : InterProScanResults [ ] = [ ]
80- const batches : { id : string ; seq : string } [ ] [ ] = [ ]
81-
82- for ( let i = 0 ; i < sequences . length ; i += batchSize ) {
83- batches . push ( sequences . slice ( i , i + batchSize ) )
84- }
85-
86- console . log ( ` Submitting ${ batches . length } batch(es)...` )
8778
88- for ( let i = 0 ; i < batches . length ; i ++ ) {
89- const batch = batches [ i ] !
90- console . log (
91- ` Processing batch ${ i + 1 } /${ batches . length } (${ batch . length } sequences)...` ,
92- )
79+ for ( let i = 0 ; i < sequences . length ; i ++ ) {
80+ const seq = sequences [ i ] !
81+ console . log ( ` [${ i + 1 } /${ sequences . length } ] Submitting ${ seq . id } ...` )
9382
94- const jobId = await submitJob ( batch , programs , email )
95- console . log ( ` Job submitted : ${ jobId } ` )
83+ const jobId = await submitJob ( seq , programs , email )
84+ console . log ( ` Job: ${ jobId } ` )
9685
9786 await waitForJob ( jobId )
9887
@@ -101,7 +90,7 @@ export async function runEbiInterProScan(
10190 allResults . push ( r )
10291 }
10392
104- console . log ( ` Batch ${ i + 1 } complete ` )
93+ console . log ( ` [ ${ i + 1 } / ${ sequences . length } ] Done ` )
10594 }
10695
10796 return allResults
0 commit comments