Hi modified the program but it is still giving some errors :(
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $qfn1 = "File1.txt";
my $qfn2 = "File2.txt";
my %positions;
{
open(my $fh, '<', $qfn1)
or die("Cannot open file \"$qfn1\": $!\n");
while ( <$fh> ) {
chomp;
my ( $key, $pos ) = split /\s+/;
push @{ $positions{$key} }, $pos;
}
}
print Data::Dumper->Dumpxs( [ \ %positions ], [ qw{ *positions } ] );
my %sequences;
{
open(my $fh, '<', $qfn2)
or die("Cannot open file \"$qfn2\": $!\n");
my $key;
while (<$fh>) {
if ( s/^>// ) {
$key = ( split /\|/ )[1];
}
else {
chomp;
$sequences{$key} .= $_;
}
}
}
for my $key (sort keys %positions)
{
for my $key (keys %{$positions{$key}})
{
foreach my $value (@) {
if (! exists( $sequences{$key} )) {
warn "KEY $key in File1 not found in File2\n";
next;
}
if ( length( $sequences{$key} ) < $positions{$key} ) {
warn "KEY $key: File2 string length too short for File1 positi
+on value\n";
next;
}
my $index = rindex( $sequences{$key}, "ATG", $positions{$key} );
if ( $index < 0 ) {
warn sprintf( "KEY %s: No ATG in File2 string prior to positio
+n %d\n",
$key, $positions{$key} );
next;
}
$index += 3 while ( ($index + 3) < $positions{$key} );
print "$key $positions{$key} " . substr($sequences{$key}, $index,
+3) . "\n";
}
}
}
-
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.
|