I've written a code (a stupid one) for this and it worked, but my code only compares data that are positioned one after the other.A 83 GLU A 90 GLU^? A 163 ARG A 83 ARG^? A 222 ARG A 5 ARG^? A 229 ALA A 115 ALA~? A 257 ALA A 118 ALA~? A 328 ASP A 95 ASP~? A 83 GLU A 90 GLU^? A 163 ARG A 83 ARG^? A 222 ARG A 5 ARG^? A 83 GLU B 90 GLU^? A 163 ARG B 83 ARG^? A 222 ARG B 5 ARG^?
#!/usr/bin/perl open (FILE, 'bodo.txt'); open (OUTFILE, '>output.txt') or die "die"; $/ = " "; $i=0; $j=0; $k=0; $l=0; $m=0; $n=0; while ($line = <FILE>) { chomp; ($i_new, $j_new, $k_new) = (split /\s+/,$line) [ -2,-8,-14 ] ; #assign + each number to a variable ($l_new, $m_new, $n_new) = (split /\s+/,$line) [ -5,-11,-17 ] ; # assi +gn each number to a variable if ($i==$i_new && $j==$j_new && $k==$k_new && $l==$l_new && $m==$m_new + && $n==$n_new){ #do nothing } else { print OUTFILE $line; } $i=$i_new; $j=$j_new; $k=$k_new; $l=$l_new; $m=$m_new; $n=$n_new; } close (FILE); close (OUTFILE); exit;
The reason this was written was because I hadn't thought that the data to be compared could be positioned far from each other.
I am very new to Perl, and actually new to programming in general. Hope someone can help. Thank you.In reply to delete redundant data by nurulnad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |