automate command using bash or perl script?
2
0
Entering edit mode
4.9 years ago

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 • 932 views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
4.9 years ago
ATpoint 85k
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?

ADD COMMENT
0
Entering edit mode
4.9 years ago
JC 13k

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

ADD COMMENT
0
Entering edit mode

Thanks for replying.. It works.

ADD REPLY

Login before adding your answer.

Traffic: 2555 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6