This is a test version of Biostars. For the public version, visit https://www.biostars.org.
automate command using bash or perl script?

Dear all I have a file containing genome Ids like

470.771
470.773

......so on upto 1000

and I need to automate a command for all 1000 genome id. Command is

p3-genome-fasta --contig 470.771 > out.contig

and I need a folder containing all the downloaded files. Can anybody help me out with this task?

assembly rast perl bash

try this and let me know if this is what you want:

$ parallel --dry-run  'p3-genome-fasta --contig {} > out_{}.contig' ::: 470.{771..1000}

if you have the ids in text file (ids.txt), try this:

$ parallel --dry-run  'p3-genome-fasta --contig {} > out_{}.contig' :::: ids.txt

remove dry-run to execute the command.

2 answers

for i in 470.{771..1000}
  do 
  p3-genome-fasta --contig ${i} > out_${i}.contig
  done

What do you mean by "a folder"? What does this command produce?

Not sure if your output need to be renamed, but here is in Perl:

#!/usr/bin/perl
use strict;
use warnings;

while (<>) {
    chomp;
    my $id = $_;
    system("p3-genome-fasta --contig $id > out_$id.contig")
}

so you can run as perl run.pl < file_with_ids.txt

Log in to answer this question.