I have a file which contains the following content:
set0027:
set0027_100-250
set0027_1-150
set0027_50-200
set0038:
set0038_100-250
set0038_1-150
set0038_50-200
I want to modify it in the following way:
cd set0027
clustalw INFILE=set0027_100-250 OUTFILE=set0027_100-250.aln
clustalw INFILE=set0027_1-150 OUTFILE=set0027_1-150.aln
clustalw INFILE=set0027_50-200 OUTFILE=set0027_50-200.aln
cd ..
cd set0038
clustalw INFILE=set0038_100-250 OUTFILE=set0038_100-250.aln
clustalw INFILE=set0038_1-150 OUTFILE=set0038_1-150.aln
clustalw INFILE=set0038_50-200 OUTFILE=set0038_50-200.aln
cd ..
How can I do this using bash script?
Something like this will work:
$ perl -npe 's/(.*):/cd \1/; s/^(set.*)/clustalw INFILE=\1 OUTFILE=\1.aln/; s/^\s+/cd ..\n/;' file
cd set0027
clustalw INFILE=set0027_100-250 OUTFILE=set0027_100-250.aln
clustalw INFILE=set0027_1-150 OUTFILE=set0027_1-150.aln
clustalw INFILE=set0027_50-200 OUTFILE=set0027_50-200.aln
cd ..
cd set0038
clustalw INFILE=set0038_100-250 OUTFILE=set0038_100-250.aln
clustalw INFILE=set0038_1-150 OUTFILE=set0038_1-150.aln
clustalw INFILE=set0038_50-200 OUTFILE=set0038_50-200.aln
uses command line options
-n implicit loop
-e execute perl inline
-p print line
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments