Difference between revisions of "DbSNP Silent Mutations Parser"
Line 1: | Line 1: | ||
+ | <syntaxhighlight> |
||
− | <source lang="text"> |
||
#!/usr/bin/perl |
#!/usr/bin/perl |
||
Line 147: | Line 147: | ||
print "|} \n"; |
print "|} \n"; |
||
} |
} |
||
+ | </syntaxhighlight> |
||
− | </source> |
Latest revision as of 23:20, 16 June 2011
<syntaxhighlight>
- !/usr/bin/perl
if ($#ARGV < 2){
print "wrong arguments!\n";
exit();
}
$out_format=$ARGV[0]; $inFile = $ARGV[1]; $mRNA_fasta = $ARGV[2];
if ($out_format ne "list" && $out_format ne "wiki" && $out_format ne "map"){ print "wrong output type!\n"; exit(); }
$mRNA_seq = ""; open(RNA, '<'.$mRNA_fasta) || die "Can not open file $inFile: $!";
while (<RNA>){ if(!/^>/){ chomp($_); $mRNA_seq = $mRNA_seq . $_; }
} close(RNA);
@mRNA_array = split(//, $mRNA_seq);
$codon_pos = 0; @codon = (); $frame = 1; $pos = 1; foreach(@mRNA_array){
$codon[$codon_pos] = $codon[$codon_pos] . $_;
if ($frame == 3){ $frame = 1; $codon_pos++; } else { $frame++; }
}
$rs = ""; $i=0;
$ref_allele =""; $mut_allele ="";
$ref_frame = ""; $mut_frame = "";
$ref_residue = ""; $mut_residue = "";
$ref_aa_pos = ""; $mut_aa_pos = ""; $ref_aa_pos_plus_1 = ""; $mut_aa_pos_plus_1 = "";
if($out_format eq "wiki"){ print '{| border="1"'."\n"; print "|-\n"; print "! Identifier\n"; print "! AA-Position\n"; print "! Reference Triplet\n"; print "! Mutated Triplet\n"; print "! Reference Allele\n"; print "! Mutated Allele\n"; print "! Frame\n"; print "! Reference Residue\n"; print "! Mutated Residue\n";
} $pref_rs ="-1"; open(IN, '<'.$inFile) || die "Can not open file $inFile: $!"; while (<IN>){
if(/^(rs\d+)/){ $rs = $1; }
if(/^LOC.+fxn-class=reference.+allele=(\w).+frame=(\d).+residue=(\w).+aa_position=(\d+)/){ $ref_allele = $1;
$ref_frame = $2; $ref_residue = $3; $ref_aa_pos = $4; $ref_aa_pos_plus_1 = $ref_aa_pos + 1;
}
if(/^LOC.+fxn-class=synonymous-codon.+allele=(\w).+frame=(\d).+residue=(\w).+aa_position=(\d+)/){ $mut_allele = $1; $mut_frame = $2; $mut_residue = $3; $mut_aa_pos = $4;
$mut_aa_pos_plus_1 = $mut_aa_pos + 1; }
if (/^\s/){ $ref_triplet= $codon[$ref_aa_pos]; $mut_triplet= $ref_triplet; if($mut_frame == 1){ $mut_triplet=~ s/(\w)(\w)(\w)/$mut_allele$2$3/; } elsif($mut_frame == 2){ $mut_triplet=~ s/(\w)(\w)(\w)/$1$_mut_allele$3/; } elsif($mut_frame == 3){ $mut_triplet=~ s/(\w)(\w)(\w)/$1$2$mut_allele/; } else { print "lol"; }
if($out_format eq "wiki" && $prev_rs ne $rs){ print "|-\n"; print "| $rs\n"; print "| $mut_aa_pos_plus_1\n"; print "| $ref_triplet\n"; print "| $mut_triplet\n"; print "| $ref_allele\n"; print "| $mut_allele\n"; print "| $mut_frame \n"; print "| $ref_residue \n"; print "| $mut_residue \n";
} elsif($out_format eq "map" && $prev_rs ne $rs){ print "$rs,silent,$ref_residue$mut_aa_pos_plus_1$mut_residue,$ref_triplet-$mut_triplet\n";
} elsif ($out_format eq "list" && $prev_rs ne $rs){ print "$rs triplet=$ref_triplet/$mut_triplet allele=$ref_allele/$mut_allele frame=$ref_frame/$mut_frame "; print "residue=$ref_residue/$mut_residue aa_pos=$ref_aa_pos_plus_1/$mut_aa_pos_plus_1 \n"; } $prev_rs = $rs; }
}
close(IN);
if($out_format eq "wiki"){ print "|} \n"; } </syntaxhighlight>