Created
June 21, 2012 16:19
-
-
Save JonasR/2966806 to your computer and use it in GitHub Desktop.
Lowercase sequence and create one sequence per mutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Getopt::Long; | |
our $opt_f = (); | |
sub usage { | |
printf "Usage: $0 [flags] file...\n"; | |
printf "flags:\n"; | |
printf " -i Infile reads the input from fileIN \n"; | |
printf " -mut Mutation\n"; | |
exit 1; | |
} | |
GetOptions( "i=s", "mut=s" ); | |
usage() if !( $opt_i && $opt_mut); | |
$wt = substr($opt_mut,0,1); | |
$mt = substr($opt_mut,length($opt_mut)-1,1); | |
$pos = substr($opt_mut,1,length($opt_mut)-2); | |
#print "wt:$wt, mt:$mt, pos:$pos"; | |
open( IN, "<$opt_i" ) or die "Inputfile not found"; | |
$sequence = ""; | |
while(<IN>){ | |
chomp; | |
@line = split('',$_); | |
push(@sequence,@line); | |
} | |
$pos2 = $pos - 167; | |
for($i = 0; $i<scalar(@sequence); $i++){ | |
if ($i == $pos2){ | |
if ($wt eq $sequence[$i]){ | |
print $mt; | |
} else {print "\n problem with matching snp $wt$pos$mt (pos in edited sequence $pos2) to sequence \n";} | |
} else { | |
print lc($sequence[$i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment