If I understood correctly, you want something like:
-
Read and parse the sequences file
- For each sequence, open a file that is named after the sequence header
- From that file, get the first number of each line
- Associate each letter in the sequence with those numbers
use strict;
use warnings;
my ($seqfile) = @ARGV;
#seqfile is the file with the sequences.
open my $seqfh, "<", $seqfile or die $!;
{
local $/ = "\n>";
while (my $nextseq = <$seqfh>){
chop $nextseq unless eof $seqfh;
substr ($nextseq,0,1,"") if $. == 1;
my ($name,@seq) = split /\n/,$nextseq;
my @aas = split //,join "",@seq;
my @coords = getCoords ($name);
print "$aas[$_] $coords[$_]\n" for(0..$#aas);
}
}
sub getCoords
{
my ($fname) = @_;
local $/="\n";
my @ns;
open my $fh, "<", $fname or die $!;
while (my $line = <$fh>){
chomp $line;
my @ff = split /\s+/,$line;
push @ns, (split /\s+/,$line)[0];
}
close $fh;
return @ns;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|