Leser: 29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
#!use/bin/perl -w #use strict; sub codon2aa { #eine Subrutine zur übersetzung der zu einer Aminosäure my($codon) = @_; if ( $codon =~ /TCA/i ) { return 'S' } #Serine elsif ( $codon =~ /TCC/i ) { return 'S' } #Serine elsif ( $codon =~ /TCG/i ) { return 'S' } #Serine elsif ( $codon =~ /TCT/i ) { return 'S' } #Serine elsif ( $codon =~ /TTC/i ) { return 'F' } #Phenylalanine elsif ( $codon =~ /TTT/i ) { return 'F' } #Phenylalanine elsif ( $codon =~ /TTA/i ) { return 'L' } #Leucine elsif ( $codon =~ /TTG/i ) { return 'L' } #Leucine elsif ( $codon =~ /TAC/i ) { return 'Y' } #Tyrosine elsif ( $codon =~ /TAT/i ) { return 'Y' } #Tyrosine elsif ( $codon =~ /TAA/i ) { return '_' } # Stop elsif ( $codon =~ /TAG/i ) { return '_' } # Stop elsif ( $codon =~ /TGC/i ) { return 'C' } #Cysteine elsif ( $codon =~ /TGT/i ) { return 'C' } #Cysteine elsif ( $codon =~ /TGA/i ) { return '_' } # Stop elsif ( $codon =~ /TGG/i ) { return 'W' } #Tryptophan elsif ( $codon =~ /CTA/i ) { return 'L' } #Leucine elsif ( $codon =~ /CTC/i ) { return 'L' } #Leucine elsif ( $codon =~ /CTG/i ) { return 'L' } #Leucine elsif ( $codon =~ /CTT/i ) { return 'L' } #Leucine elsif ( $codon =~ /CCA/i ) { return 'P' } #Proline elsif ( $codon =~ /CCC/i ) { return 'P' } #Proline elsif ( $codon =~ /CCG/i ) { return 'P' } #Proline elsif ( $codon =~ /CCT/i ) { return 'P' } #Proline elsif ( $codon =~ /CAC/i ) { return 'H' } #Histidine elsif ( $codon =~ /CAT/i ) { return 'H' } #Histidine elsif ( $codon =~ /CAA/i ) { return 'Q' } #Glutamine elsif ( $codon =~ /CAG/i ) { return 'Q' } #Glutamine elsif ( $codon =~ /CGA/i ) { return 'R' } #Arginine elsif ( $codon =~ /CGC/i ) { return 'R' } #Arginine elsif ( $codon =~ /CGG/i ) { return 'R' } #Arginine elsif ( $codon =~ /CGT/i ) { return 'R' } #Arginine elsif ( $codon =~ /ATA/i ) { return 'I' } #Isoleucine elsif ( $codon =~ /ATC/i ) { return 'I' } #Isoleucine elsif ( $codon =~ /ATT/i ) { return 'I' } #Isoleucine elsif ( $codon =~ /ATG/i ) { return 'M' } #Methionine elsif ( $codon =~ /ACA/i ) { return 'T' } #Threonine elsif ( $codon =~ /ACC/i ) { return 'T' } #Threonine elsif ( $codon =~ /ACG/i ) { return 'T' } #Threonine elsif ( $codon =~ /ACT/i ) { return 'T' } #Threonine elsif ( $codon =~ /AAC/i ) { return 'N' } #Asparagine elsif ( $codon =~ /AAT/i ) { return 'N' } #Asparagine elsif ( $codon =~ /AAA/i ) { return 'K' } #Lysine elsif ( $codon =~ /AAG/i ) { return 'K' } #Lysine elsif ( $codon =~ /AGC/i ) { return 'S' } #Serine elsif ( $codon =~ /AGT/i ) { return 'S' } #Serine elsif ( $codon =~ /AGA/i ) { return 'R' } #Arginine elsif ( $codon =~ /AGG/i ) { return 'R' } #Arginine elsif ( $codon =~ /GTA/i ) { return 'V' } #Valine elsif ( $codon =~ /GTC/i ) { return 'V' } #Valine elsif ( $codon =~ /GTG/i ) { return 'V' } #Valine elsif ( $codon =~ /GTT/i ) { return 'V' } #Valine elsif ( $codon =~ /GCA/i ) { return 'A' } #Alanine elsif ( $codon =~ /GCC/i ) { return 'A' } #Alanine elsif ( $codon =~ /GCG/i ) { return 'A' } #Alanine elsif ( $codon =~ /GCT/i ) { return 'A' } #Alanine elsif ( $codon =~ /GAC/i ) { return 'D' } #Aspartic Acid elsif ( $codon =~ /GAT/i ) { return 'D' } #Aspartic Acid elsif ( $codon =~ /GAA/i ) { return 'E' } #Glutamic Acid elsif ( $codon =~ /GAG/i ) { return 'E' } #Glutamic Acid elsif ( $codon =~ /GGA/i ) { return 'G' } #Glycine elsif ( $codon =~ /GGC/i ) { return 'G' } #Glycine elsif ( $codon =~ /GGG/i ) { return 'G' } #Glycine elsif ( $codon =~ /GGT/i ) { return 'G' } #Glycine else { print STDERR "Bad codon \"$codon\"!!\n"; exit; } } print "schreibe Dateinamen: "; my $dna =<STDIN>; my $protein =''; my $codon; unless (open (DNADATEI, $dna)) { print "can not open file!\n"; <>; exit; } @datei= <DNADATEI>; close DNADATEI; $dna =join ('',@datei); $dna =~s/\s//g; for (my $i=0; $i < (length($dna)-2);$i+=3) { my $codon =substr($dna,$i,3); my $protein .= codon2aa($codon); } print "$protein"; <STDIN>; exit;
2010-06-24T08:44:45 esskarwas heißt den funktionieren?
print "$protein"; kann meiner meinung nach nix vernüftiges ausspucken
1 2 3 4 5 6 7
for (my $i=0; $i < (length($dna)-2);$i+=3) { my $codon =substr($dna,$i,3); my $protein .= codon2aa($codon); } print "$protein";
2010-06-24T09:32:34 esskaraußerhalb wird $protein leer sein
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
print "schreibe Dateinamen: "; my $dna =<STDIN>; my $protein =''; my $codon; my @datei; unless (open (DNADATEI, $dna)) { print "can not open file!\n"; <>; exit; } @datei= <DNADATEI>; close DNADATEI; $dna =join ('',@datei); $dna =~s/\s//g; for (my $i=0; $i < (length($dna)-2);$i+=3) { $codon =substr($dna,$i,3); $protein .= codon2aa($codon); } print "Proteinstrang: "; print "$protein"; <STDIN>; exit;
1 2 3 4 5
my $dna =<STDIN>; ... open (DNADATEI, $dna) ... @datei= <DNADATEI>; $dna =join ('',@datei);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; use Bio::Perl; print "Bitte geben Sie einen Dateinamen ein: "; chomp( my $file = <STDIN> ); die "Can't read file $file" unless -r $file; my $sequence = do{ local( @ARGV,$/ ) = $file; <> }; my $amino_acids = translate_as_string( $sequence ); print "Proteinstrang: ", $amino_acids, "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
#!use/bin/perl -w use strict; use warnings; # initalisieren... my %aa=( 'S'=>[qw(TCA TCC TCG TCT AGC AGT)], 'F'=>[qw(TTC TTT)], 'L'=>[qw(TTA TTG CTA CTC CTG CTT)], 'Y'=>[qw(TAC TAT)], '_'=>[qw(TAA TAG)], 'C'=>[qw(TGC TGT TGA)], 'W'=>[qw(TGG)], 'P'=>[qw(CCA CCC CCG CCT )], 'H'=>[qw(CAC CAT)], 'Q'=>[qw(CAA CAG)], 'R'=>[qw(CGA CGC CGG CGT AGA AGG)], 'I'=>[qw(ATA ATC ATT)], 'M'=>[qw(ATG)], 'T'=>[qw(ACA ACC ACG ACT)], 'N'=>[qw(AAC AAT)], 'K'=>[qw(AAA AAG)], 'V'=>[qw(GTA GTC GTG GTT)], 'A'=>[qw(GCA GCC GCG GCT)], 'D'=>[qw(GAC GAT)], 'E'=>[qw(GAA GAG)], 'G'=>[qw(GGA GGC GGG GGT)], ); # daten umformen my %codons; for my $key (keys(%aa)) { $codons{$_}=$key for(@{$aa{$key}}); } # von Komandozeile lesen # oder Nachfragen my $file=shift(@ARGV); unless($file) { print "schreibe Dateinamen: "; $file=<STDIN>; #Zeilenumbruch abschneiden chomp($file); } # dna aus Datei lesen my $dns; open(my $fh ,'<', $file) || error("ERROR open $file ($!)"); { # zeilentrenner ignorieren local $/=undef; # Alles in Großschreibung wandeln $dns=uc(<$fh>); } close($fh); # alles unötige löschen $dns=~s/[\s\r\n]+//isg; my $protein =''; # immer 3 Zeichen vorne abschneiden while(my $codon=substr($dns,0,3,'')) { my $aa=$codons{$codon}; error(qq(ERROR convert "$codon"!)) unless($aa); $protein.=$aa; } print "$protein\n"; ende(); ######################################################################## sub error { my $msg=shift || ''; print STDERR "$msg\n"; <STDIN>; exit 1; } sub ende { <STDIN>; exit; }
my $codon = @_;
my $codon = shift(@_);
my $codon = shift;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/usr/bin/perl use warnings; use strict; sub codon2aa { my $codon = shift; my %aa = ("TCC" => "S", "TCG" => "S", "TCT" => "S", "TTC" => "F", "TTT" => "F", "TTA" => "L", "TTG" => "L", "TAC" => "Y", "TAT" => "Y", "TAA" => "_", "TAG" => "_", "TGC" => "C", "TGT" => "C", "TGA" => "_", "TGG" => "W", "CTA" => "L", "CTC" => "L", "CTG" => "L", "CTT" => "L", "CCA" => "P", "CCC" => "P", "CCG" => "P", "CCT" => "P", "CAC" => "H", "CAT" => "H", "CAA" => "Q", "CAG" => "Q", "CGA" => "R", "CGC" => "R", "CGG" => "R", "CGT" => "R", "ATA" => "I", "ATC" => "I", "ATT" => "I", "ATG" => "M", "ACA" => "T", "ACC" => "T", "ACG" => "T", "ACT" => "T", "AAC" => "N", "AAT" => "N", "AAA" => "K", "AAG" => "K", "AGC" => "S", "AGT" => "S", "AGA" => "R", "AGG" => "R", "GTA" => "V", "GTC" => "V", "GTG" => "V", "GTT" => "V", "GCA" => "A", "GCC" => "A", "GCG" => "A", "GCT" => "A", "GAC" => "D", "GAT" => "D", "GAA" => "E", "GAG" => "E", "GGA" => "G", "GGC" => "G", "GGG" => "G", "GGT" => "G"); $codon = uc($codon); if (exists($aa{$codon})) { return $aa{$codon}; } else { print STDERR "Bad codon \"$codon\"!\n"; exit; } } print &codon2aa("GaA") . "\n";
2010-06-24T19:10:14 hlubenowBei Funktionsaufrufen sollte man ein "&" voranstellen (z.B.: &codon2aa("GaA")), um "lose Wörter" ("barewords") im Skript zu vermeiden.
2010-06-24T19:31:19 pq2010-06-24T19:10:14 hlubenowBei Funktionsaufrufen sollte man ein "&" voranstellen (z.B.: &codon2aa("GaA")), um "lose Wörter" ("barewords") im Skript zu vermeiden.
nein, bloss nicht.
klammern hintendran sind üblich.
das ampersand davor ist uralt und hat nebeneffekte. http://p3rl.org/perlsub
also, nicht &funktion, sondern funktion()