Skip to content
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
197 changes: 129 additions & 68 deletions cmd/interpro-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,85 +14,146 @@ const (
defaultTaxonID = "44689"
defaultOutput = "interpro_proteins.tsv"
defaultPageSize = 20
defaultConcurrency = 25
defaultPollInterval = 15 * time.Second
defaultTimeout = 30 * time.Minute
)

func main() {
cmd := &cli.Command{
if err := newCommand().Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}

func newCommand() *cli.Command {
return &cli.Command{
Name: "interpro-manager",
Usage: "CLI for interacting with the InterPro protein database",
Commands: []*cli.Command{
{
Name: "download",
Usage: "Fetch InterPro protein records for a taxonomy ID and save to TSV",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "taxon-id",
Aliases: []string{"t"},
Value: defaultTaxonID,
Usage: "NCBI Taxonomy ID",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: defaultOutput,
Usage: "Output TSV file path",
},
&cli.IntFlag{
Name: "page-size",
Aliases: []string{"p"},
Value: defaultPageSize,
Usage: "API page size",
},
},
Action: interpro.DownloadAndWrite,
},
{
Name: "scan",
Usage: "Submit protein sequences to InterProScan and save JSON results",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "fasta",
Aliases: []string{"f"},
Usage: "Path to FASTA file (supports multi-FASTA)",
},
&cli.StringFlag{
Name: "email",
Aliases: []string{"e"},
Sources: cli.EnvVars("EBI_EMAIL"),
Usage: "Email for EMBL-EBI Job Dispatcher (required)",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: ".",
Usage: "Output directory for JSON results",
},
&cli.StringFlag{
Name: "seq-type",
Aliases: []string{"s"},
Value: "p",
Usage: "Sequence type: p (protein) or n (nucleotide)",
},
&cli.DurationFlag{
Name: "poll-interval",
Value: defaultPollInterval,
Usage: "How often to check job status",
},
&cli.DurationFlag{
Name: "timeout",
Value: defaultTimeout,
Usage: "Maximum time to wait for a single job",
},
},
Action: interpro.Scan,
downloadCmd(),
scanCmd(),
concurrentScanCmd(),
},
}
}

func downloadCmd() *cli.Command {
return &cli.Command{
Name: "download",
Usage: "Fetch InterPro protein records for a taxonomy ID and save to TSV",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "taxon-id",
Aliases: []string{"t"},
Value: defaultTaxonID,
Usage: "NCBI Taxonomy ID",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: defaultOutput,
Usage: "Output TSV file path",
},
&cli.IntFlag{
Name: "page-size",
Aliases: []string{"p"},
Value: defaultPageSize,
Usage: "API page size",
},
},
Action: interpro.DownloadAndWrite,
}
}

if err := cmd.Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
func scanCmd() *cli.Command {
return &cli.Command{
Name: "scan",
Usage: "Submit protein sequences to InterProScan and save JSON results",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "fasta",
Aliases: []string{"f"},
Usage: "Path to FASTA file (supports multi-FASTA)",
},
&cli.StringFlag{
Name: "email",
Aliases: []string{"e"},
Sources: cli.EnvVars("EBI_EMAIL"),
Usage: "Email for EMBL-EBI Job Dispatcher (required)",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: ".",
Usage: "Output directory for JSON results",
},
&cli.StringFlag{
Name: "seq-type",
Aliases: []string{"s"},
Value: "p",
Usage: "Sequence type: p (protein) or n (nucleotide)",
},
&cli.DurationFlag{
Name: "poll-interval",
Value: defaultPollInterval,
Usage: "How often to check job status",
},
&cli.DurationFlag{
Name: "timeout",
Value: defaultTimeout,
Usage: "Maximum time to wait for a single job",
},
},
Action: interpro.Scan,
}
}

func concurrentScanCmd() *cli.Command {
return &cli.Command{
Name: "concurrent-scan",
Usage: "Submit protein sequences to InterProScan concurrently and save JSON results",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "fasta",
Aliases: []string{"f"},
Usage: "Path to FASTA file (supports multi-FASTA)",
},
&cli.StringFlag{
Name: "email",
Aliases: []string{"e"},
Sources: cli.EnvVars("EBI_EMAIL"),
Usage: "Email for EMBL-EBI Job Dispatcher (required)",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: ".",
Usage: "Output directory for JSON results",
},
&cli.StringFlag{
Name: "seq-type",
Aliases: []string{"s"},
Value: "p",
Usage: "Sequence type: p (protein) or n (nucleotide)",
},
&cli.DurationFlag{
Name: "poll-interval",
Value: defaultPollInterval,
Usage: "How often to check job status",
},
&cli.DurationFlag{
Name: "timeout",
Value: defaultTimeout,
Usage: "Maximum time to wait for a single job",
},
&cli.IntFlag{
Name: "concurrency",
Aliases: []string{"c"},
Value: defaultConcurrency,
Usage: "Maximum number of concurrent InterProScan jobs",
},
},
Action: interpro.ConcurrentScan,
}
}
Loading
Loading