Need help creating a basic script for writing a repetitive command line using a list as input


Joined
Mar 12, 2022
Messages
1
Reaction score
0
Hi
Bassically I need to write a comand line where three entries are label using the same name provided by a list object
For instance

prokka --prefix N16961-TIGR --cpus 6 --outdir N16961-TIGR --rfam --addgenes --addmrna --cdsrnaolap N16961-TIGR.fna && prokka --prefix O395-TIGR --cpus 6 --outdir O395-TIGR --rfam --addgenes --addmrna --cdsrnaolap O395-TIGR.fna &&

Bold names correspond to list elements and the number of repeats depends on number of list elements

I would appriciate any help

Regards
 
Ad

Advertisements

Joined
Mar 3, 2021
Messages
243
Reaction score
29
Simple string substitution would do alright for that. Untested, 'cause I can't use prokka, but this should do in a pinch. Just call it and provide all of the labels you want to run on the command line, e.g. ./run_prokka.pl N16961-TIGR 0395-TIGR. You can add the -TIGR bit to the code after each use of $label, if you want. I wasn't sure if that part could change or not.

Perl:
#!/usr/bin/env perl

use strict;
use warnings FATAL => 'all';

for my $label (@ARGV){
        print("prokka --prefix $label --cpus 6 --outdir $label --rfam --addgenes --addmrna --cdsrnaolap $label.fna");
        system("prokka --prefix $label --cpus 6 --outdir $label --rfam --addgenes --addmrna --cdsrnaolap $label.fna");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top