I am not sure what your question really is. You are modifying @current_columns but you are keeping $current_line unmodified and store it in $previous_line for further processing. Do you want your modifications reflected in $previous_line in the next iteration of your loop? If that is the question, you should really store the array @current_columns instead of $current_line, e.g.
my $previous_line = <IN>;
chomp $previous_line;
my @previous_columns = split(" ", $previous_line);
while (my $current_line = <IN>) {
chomp $current_line;
my $end_coor = $previous_columns[2] + $previous_columns[3];
my @current_columns = split(" ", $current_line);
my $seq_length = length $previous_columns[6];
my $gap_count = $previous_columns[6] =~ tr/Q//;
my $original_length = $seq_length - $gap_count;
my $original_end_coor = $previous_columns[2] + $original_length;
my $distance = $current_columns[2] - $original_end_coor;
$current_columns[2] = $end_coor + $distance;
print OUT "$current_columns[2]\n";
@previous_columns = @current_columns;
}
Not tested...
-
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.
|