#! /usr/bin/perl
# >@HWI-EAS269B:1:1:1614:601      hsa-mir-383     +       7       28      12232195  14G7
my ($mappingFileName) = @ARGV;
open INFILE_MAP, "<$mappingFileName" or die $!;
open OUTFILE_MAP, ">$mappingFileName.shrink" or die $!;
#in logos file I get some info needed for quality evaluation of the results the name of the ensembl gene and the description of the alignment and start of alignment in reference seq and start in read
  while (my $line = <INFILE_MAP>){
          if($line =~ /^>/){
             my @myarr = split('\t', $line);
             #removing strings with more than one SNP
             $count = 0;
             while($myarr[9] =~ /[A,T,C,G]/g){
                   $count++; 
             }
             if($count <= 1){
                #removing strings with sequencing errors 
                $count = 0;
                while($myarr[9] =~ /x/g){
                   $count++; 
                }
                if($count == 0){
                   my $string = join("\t", $myarr[1], $myarr[9]); #chr, strand (1, -1), start alignment
                   print OUTFILE_MAP $string;
                   print OUTFILE_MAP "\n";
                }
             }
          }
  }  
close INFILE_MAP;
close OUTFILE_MAP;
