Skip to content

Instantly share code, notes, and snippets.

@JonasR
Created June 21, 2012 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonasR/2966806 to your computer and use it in GitHub Desktop.
Save JonasR/2966806 to your computer and use it in GitHub Desktop.
Lowercase sequence and create one sequence per mutation
#!/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