#! /usr/local/bin/perl -w use strict; my($num_of_params,$line,$key,$name); my @keys; my %orf_hash_pos; $num_of_params = @ARGV; if($num_of_params < 3) { die ("\n Not enough params have been entered!!!!\n"); } open (ORF_POS, $ARGV[0]) or die "unable to open file"; open (FASTA, $ARGV[1]) or die "unable to open file"; open (OUTFILE, ">$ARGV[2]"); foreach $line () { if(! ($line =~ /(\d+)\s+(\d+)\s+(\d+)/)) { print "CHECK YOR FILE .... continue \n"; next; } if($2 <= $3) { $orf_hash_pos{$2} = $3; } else { $orf_hash_pos{$3} = $2; } } @keys = sort { $a <=> $b } ( keys %orf_hash_pos ); #--------------- step 2 --------------------------- my $counter=0; my $orf_counter=0; my $new_pos; my $pos_start=0; my $pos_end=0; my $found_new=0; my @lines; my @dna; my @orf_array_pos; my $base; my $dna; my $orf_names; @lines = ; chomp @lines; $dna = join( '', @lines); @dna = split( '', $dna); foreach $key (@keys) { push @orf_array_pos , $key; push @orf_array_pos , $orf_hash_pos{$key}; } $pos_start = $orf_array_pos[$orf_counter]; $pos_end = $orf_array_pos[$orf_counter+1]; $found_new=0; foreach $base (@dna) { if( ($counter > $pos_end) && ($orf_counter < @orf_array_pos) ) { $orf_counter += 2; $new_pos = $orf_array_pos[$orf_counter]; if($new_pos < $pos_end) { $pos_start = $pos_end; } else { $pos_start = $new_pos; } $pos_end = $orf_array_pos[$orf_counter+1]; } if( ($counter >= $pos_start) && ($counter <= $pos_end) ) { $found_new=0; } else { if($found_new==0) { $orf_names = $orf_counter + 1; $found_new=1; print "\n\n> dORF$orf_names \n"; print OUTFILE "\n\n> dORF$orf_names \n"; } print $base; print OUTFILE $base; } $counter++; } print "\n";