Off topic:How can I print all lines? PERL
0
0
Entering edit mode
6.7 years ago

Hello, I have such problem: I want to print all lines with new added column: IN or OUT, the script runs, but I can't understand, why there is only first line printed...do you have any suggestions?

This is my script:

use strict; 
use warnings;


open(FILE, "Q.txt");
my $file = <>;                            #FILE

my @column;

while (<>) {                               #FILE

@column=($file);

chomp @column; 

my $number=0;

    while($number <= $#column) {                    #go through the array from 0 to the last element
    my $j;
    my $count=0;
        foreach ($j=$number; $j < $#column; $j++) {   #select the numbers from the beginning of the line 
        my $d=($column[$j]=~/(\d+)/)[0] - ($column[$j+1]=~/(\d+)/)[0];  #difference
            last if abs($d)!= 1;                    #if differ more than 1 - leave. I


        $count+=$d;                                     #accumulate the difference.     


}     
    if(abs($count)>=8) {                            
    $column[$_].= " t\IN "      for $number..$j;                    
    $number=$j+1;                           
    }                        


    if(abs($count)<8){                
    $column[$number].= " \tOUT" ;                               
    $number++;       
    }        
}         
}        
print for @column;              
exit;

And here is my INPUT FILE:

5 Q CAA
16 Q CAG
21 Q CAA
74 Q CAA
80 Q CAG
82 Q CAG
84 Q CAG
85 Q CAG
89 Q CAG
90 Q CAG
91 Q CAG
92 Q CAG
93 Q CAA
94 Q CAG
95 Q CAG
96 Q CAG
98 Q CAG
99 Q CAG
100 Q CAG
101 Q CAG
102 Q CAG
106 Q CAG
107 Q CAG
108 Q CAG
109 Q CAG
110 Q CAG
111 Q CAG
112 Q CAG
113 Q CAA
114 Q CAG
115 Q CAG
116 Q CAG
118 Q CAG
120 Q CAG
121 Q CAG
125 Q CAG
126 Q CAG
127 Q CAG
129 Q CAA
133 Q CAG
134 Q CAG
135 Q CAG
136 Q CAG
137 Q CAG
139 Q CAG
140 Q CAG
141 Q CAG
142 Q CAG
143 Q CAG
144 Q CAG
145 Q CAG
146 Q CAG
154 Q CAA
156 Q CAG
157 Q CAA
158 Q CAG
160 Q CAG
161 Q CAG
162 Q CAG
163 Q CAA
164 Q CAG
165 Q CAG
167 Q CAG
171 Q CAG
173 Q CAG
175 Q CAA

Here is my OUTPUT FILE:

5 Q CAA OUT and etc...but it prints only my first line

Thank you!

polyQ perl sequence codon nucleotides • 1.3k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2076 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6