08-05-2009
Foreach loop to run a perl script on multiple files
Hi,
I have thousands of files in a directory that have the following 2 formats:
289620178.aln
289620179.aln
289620180.aln
289620183.aln
289620184.aln
289620185.aln
289620186.aln
289620187.aln
289620188.aln
289620189.aln
289620190.aln
289620192.aln....
and:
alnCDS_1.fasta
alnCDS_2.fasta
alnCDS_3.fasta
alnCDS_4.fasta
alnCDS_5.fasta
alnCDS_6.fasta
alnCDS_7.fasta
alnCDS_8.fasta
alnCDS_9.fasta
alnCDS_10.fasta....
I am using the following foreach statement to run a perl script like so:
foreach file1 ( *.aln ) ; foreach file2 ( *.fasta )
foreach? ./perl.script.pl $file1 $file2 > $file1$file2.out
foreach? end
This gives me output files
289620178.alnalnCDS_1.fasta.out
289620178.alnalnCDS_2.fasta.out
289620178.alnalnCDS_3.fasta.out .....
when what I want is the following:
289620178.alnalnCDS_1.fasta.out
289620179.alnalnCDS_2.fasta.out
289620180.alnalnCDS_3.fasta.out.... etc...
so that each of the files (*.aln and *.fasta) are sequentially paired as input into the perl script without all of the possible pairs being run through.
Is there a way to do this ?
Thanks!!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i've reworked some code from an earlier post, and it isn't working as expected
i've simplified it to try and find the problem. i spent hours trying to figure out what is wrong, eventually thinking there was a bug in perl or a problem with my computer. but, i've tried it on 3 machines with the... (5 Replies)
Discussion started by: quantumechanix
5 Replies
2. Programming
Hello All,
Im a Hardware engineer, I have written this script to automate my job. I got stuck in the following location.
CODE:
..
..
...
foreach $key(keys %arr_hash) {
my ($loc,$ind,$add) = split /,/, $arr_hash{$key};
&create_verilog($key, $loc, $ind ,$add);
}
sub create_verilog{... (2 Replies)
Discussion started by: riyasnr007
2 Replies
3. Shell Programming and Scripting
Hi,
I want to run a Perl script on multiple files, with same name ("Data.txt") but in different directories (eg : 2010_06_09_A/Data.txt, 2010_06_09_B/Data.txt).
I know how to run this perl script on files in the same directory like:
for $i in *.txt
do
perl myscript.pl $i > $i.new... (8 Replies)
Discussion started by: ad23
8 Replies
4. Shell Programming and Scripting
Hello everyone,
I have two types of files in a directory:
*.txt
*.info
I have a perl script that uses these two files as arguments, and produces a result file:
perl myScript.pl abc.txt abc.xml
How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies
5. Shell Programming and Scripting
Hi all,
I have a script which searches for all sql files in the current directory and replaces all sql files with an underscore with a dash. The next part I need to do is record the number of changes made (underscore to dash) and display this value (e.g.2). This is what I have so far;
find /... (17 Replies)
Discussion started by: shawi
17 Replies
6. Shell Programming and Scripting
Hi
I have 100 files under file A labled 1.txt 2.txt.....100.txt(made up name)
I have 1 files under file B labled name.txt
How can i run the same perl script on 100 files and file name.txt
I want to run
perl script.pl A/1.txt B/name.txt
perl script.pl A/2.txt B/name.txt
.......
perl... (3 Replies)
Discussion started by: grace_shen
3 Replies
7. UNIX for Dummies Questions & Answers
How can I run the following command on multiple files and print out the corresponding multiple files.
perl script.pl genome.gff 1.txt > 1.gff
However, there are multiples files of 1.txt, from 1----100.txt
Thank you so much.
No duplicate posting! Continue here. (0 Replies)
Discussion started by: grace_shen
0 Replies
8. Shell Programming and Scripting
How can I Run one script on multiple files and print out multiple files.
FOR EXAMPLE
i want to run script.pl on 100 files named 1.txt ....100.txt under same directory and print out corresponding file 1.gff ....100.gff.THANKS (4 Replies)
Discussion started by: grace_shen
4 Replies
9. Shell Programming and Scripting
Dear folks
I have two data set which there names are "final.map" and "1.geno" and look like this structures:
final.map:
gi|358485511|ref|NC_006088.3| 2044
gi|358485511|ref|NC_006088.3| 2048
gi|358485511|ref|NC_006088.3| 2187
gi|358485511|ref|NC_006088.3| 17654
... (2 Replies)
Discussion started by: sajmar
2 Replies
10. Shell Programming and Scripting
Experts - Any advice on how to get a hash value in a foreach loop?
Values print correctly on standalone print statements, but I can't access value
in foreach loop.
See sample code below and thanks in advance.
foreach my $z (sort keys %hash) {
for $y (@{$hash{$z}}) {
print "$z... (6 Replies)
Discussion started by: timj123
6 Replies
LEARN ABOUT DEBIAN
kalign
KALIGN(1) Kalign User Manual KALIGN(1)
NAME
kalign - performs multiple alignment of biological sequences.
SYNOPSIS
kalign [infile.fasta] [outfile.fasta] [Options]
kalign [-i infile.fasta] [-o outfile.fasta] [Options]
kalign [< infile.fasta] [> outfile.fasta] [Options]
DESCRIPTION
Kalign is a command line tool to perform multiple alignment of biological sequences. It employs the Muth?Manber string-matching algorithm,
to improve both the accuracy and speed of the alignment. It uses global, progressive alignment approach, enriched by employing an
approximate string-matching algorithm to calculate sequence distances and by incorporating local matches into the otherwise global
alignment.
OPTIONS
-s -gpo -gapopen -gap_open x
Gap open penalty .
-e -gpe -gap_ext -gapextension x
Gap extension penalty.
-t -tgpe -terminal_gap_extension_penalty x
Terminal gap penalties.
-m -bonus -matrix_bonus x
A constant added to the substitution matrix.
-c -sort <input, tree, gaps.>
The order in which the sequences appear in the output alignment.
-g -feature
Selects feature mode and specifies which features are to be used: e.g. all, maxplp, STRUCT, PFAM-A?
-same_feature_score
Score for aligning same features.
-diff_feature_score
Penalty for aligning different features.
-d -distance <wu, pair>
Distance method
-b -tree -guide-tree <nj, upgma>
Guide tree method.
-z -zcutoff
Parameter used in the wu-manber based distance calculation.
-i -in -input
Name of the input file.
-o -out -output
Name of the output file.
-a -gap_inc
Increases gap penalties depending on the number of existing gaps.
-f -format <fasta, msf, aln, clu, macsim>
The output format.
-q -quiet
Print nothing to STDERR. Read nothing from STDIN.
REFERENCES
o Timo Lassmann and Erik L.L. Sonnhammer (2005) Kalign - an accurate and fast multiple sequence alignment algorithm. BMC Bioinformatics
6:298
o Timo Lassmann, Oliver Frings and Erik L. L. Sonnhammer (2009) Kalign2: high-performance multiple alignment of protein and nucleotide
sequences allowing external features. Nucleic Acid Research 3:858?865.
AUTHORS
Timo Lassmann <timolassmann@gmail.com>
Upstream author of Kalign.
Charles Plessy <plessy@debian.org>
Wrote the manpage.
COPYRIGHT
Copyright (C) 2004, 2005, 2006, 2007, 2008 Timo Lassmann
Kalign is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the
Free Software Foundation.
This manual page was written by Charles Plessy <plessy@debian.org> for the Debian(TM) system (but may be used by others). Permission is
granted to copy, distribute and/or modify this document under the same terms as kalign itself.
On Debian systems, the complete text of the GNU General Public License version 2 can be found in /usr/share/common-licenses/GPL-2.
kalign 2.04 February 25, 2009 KALIGN(1)