my $registry = 'Bio::EnsEMBL::Registry'; $registry->load_registry_from_db( -host => 'ensembldb.ensembl.org', -user => 'anonymous' ); my $home = $ENV{'HOME'}; my($ID, $query, $off, $idi, $subject, $ref, $st); print "ID\tposition\tvariation\tRef Genome coordinates\n"; unless(open DATA, "Input_files/Contig_Alignment_Selected_3.txt"){die "Cannot open the file file $! \n";} while() { chomp; if(m[^>]) { #Checks the start of the alignements ($ID) = (split '\|',$_)[1];#splits the first line with '|' ($ref) = $ID =~ /(\d+)\s+ref$/; } if(/^\s+Identities/){ #gets the percentage of identity my($identity, undef) = split/,/ ; ($idi) = $identity =~ /\sIdentities\s\=\s\d{3}\/\d{3}\s\((\d{2,3}\%)\)$/; } if(/^\s+Strand/){ #check strands Plus/Minus ($st) = $_ =~/^\s\w+\=\w{4}\/(\w{4,5})$/; } if(m/^Query/) { ($query) = m[^Query\s+(\d+)]; my $top = substr $_, 15;#substring the first 15 char my $pipes = substr ,15; #same,if the Sbjct is more than 5 numbers then this doesnt worx my $subject = ; my($value) = $subject =~ /^Sbjct\s+(\d+)/; my $bot = substr $subject, 15;#if the Sbjct is more than 5 numbers then this doesnt work my $p = 0 ; while ($p = 1+index $pipes,' ', $p) { my $pos1 = $value-$p; my $pos2 = $value+$p; my $var1 = substr( $top, $p-1, 1 ); my $var2 = substr( $bot, $p-1, 1 ); # my $genomref1 = 4900000 + $pos1; my $genomref2 = 4899999 + $pos2; if($st eq "Minus") { print join"\t", $ref,$pos1, $var1."/".$var2,$genomref2 ; snpdetails($genomref2); }else{ print join "\t", $ref,$pos2, $var1."/".$var2,$genomref2; snpdetails($genomref2); } } } #}