The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Perl


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-10-2007, 04:13 PM
Chasey Lane
Posts: n/a
[SOLVED] Can anybody help me out with a simple PERL program??

last year this course was discounted cuz nobody passed! this year though half the class have had some simple c+ on their curriculum last year and kind of have a grasp. the guy is throwing this coding at us but not really telling us what it means, and on top of that he mumbles and we can't understand his accent. it's worth 2 credits. i am completely lost. there is one book in the library on this (beginning perl for bioinformatics) but between the 30 of us AND the other classes trying to get it,it's impossible to get our hands on. can anybody help me out?
the assignments are here :
http://bioinf.gen.tcd.ie/GE3027/class4/assignments.html

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 06-10-2007, 04:13 PM
JakeCigar JakeCigar is offline
Novice
Join Date: Jun 2007
Posts: 14
iTrader: (0)
JakeCigar is on a distinguished road
#!/usr/bin/perl
use LWP::UserAgent;
use Data:umper;
use strict;
our $ua = LWP::UserAgent->new;
$ua->agent("NuBrowser/10.5 ");

our %genetic_code = (
'AAA' => 'K', # Lysine
'AAC' => 'N', # Asparagine
'AAG' => 'K', # Lysine
'AAT' => 'N', # Asparagine
'ACA' => 'T', # Threonine
'ACC' => 'T', # Threonine
'ACG' => 'T', # Threonine
'ACT' => 'T', # Threonine
'AGA' => 'R', # Arginine
'AGC' => 'S', # Serine
'AGG' => 'R', # Arginine
'AGT' => 'S', # Serine
'ATA' => 'I', # Isoleucine
'ATC' => 'I', # Isoleucine
'ATG' => 'M', # Methionine
'ATT' => 'I', # Isoleucine
'CAA' => 'Q', # Glutamine
'CAC' => 'H', # Histidine
'CAG' => 'Q', # Glutamine
'CAT' => 'H', # Histidine
'CCA' => 'P', # Proline
'CCC' => 'P', # Proline
'CCG' => 'P', # Proline
'CCT' => 'P', # Proline
'CGA' => 'R', # Arginine
'CGC' => 'R', # Arginine
'CGG' => 'R', # Arginine
'CGT' => 'R', # Arginine
'CTA' => 'L', # Leucine
'CTC' => 'L', # Leucine
'CTG' => 'L', # Leucine
'CTT' => 'L', # Leucine
'GAA' => 'E', # Glutamic Acid
'GAC' => 'D', # Aspartic Acid
'GAG' => 'E', # Glutamic Acid
'GAT' => 'D', # Aspartic Acid
'GCA' => 'A', # Alanine
'GCC' => 'A', # Alanine
'GCG' => 'A', # Alanine
'GCT' => 'A', # Alanine
'GGA' => 'G', # Glycine
'GGC' => 'G', # Glycine
'GGG' => 'G', # Glycine
'GGT' => 'G', # Glycine
'GTA' => 'V', # Valine
'GTC' => 'V', # Valine
'GTG' => 'V', # Valine
'GTT' => 'V', # Valine
'TAA' => '*', # Stop
'TAC' => 'Y', # Tyrosine
'TAG' => '*', # Stop
'TAT' => 'Y', # Tyrosine
'TCA' => 'S', # Serine
'TCC' => 'S', # Serine
'TCG' => 'S', # Serine
'TCT' => 'S', # Serine
'TGA' => '*', # Stop
'TGC' => 'C', # Cysteine
'TGG' => 'W', # Tryptofane
'TGT' => 'C', # Cysteine
'TTA' => 'L', # Leucine
'TTC' => 'F', # Phenylalanine
'TTG' => 'L', # Leucine
'TTT' => 'F', # Phenylalanine
);



my $ass = get("http://bioinf.gen.tcd.ie/ge3027/class4/assignments.html");
my @bits = split("<BR>",$ass);

my $dna = $bits[1];
print "dna\n",$dna;
print "\nprotein\n", protein($dna),"\n";


my %fasta1 = getFasta("http://bioinf.gen.tcd.ie/ge3027/class4/fasta1.txt");
print "fasta 1 \n", Dumper(\%fasta1);

my %fasta2 = getFasta("http://bioinf.gen.tcd.ie/ge3027/class4/fasta2.txt");
print "fasta 2 \n", Dumper(\%fasta2);

print "\n4. report the sequence IDs that are found only in the first and not in the second file\n";
foreach (sort keys %fasta1){
print "$_ " unless $fasta2{$_};
}
print "\n5. report the sequence IDs for which the sequences differ between the two files\n";
foreach (sort keys %fasta1){
print "$_ $fasta2{$_} != $fasta1{$_}\n" if $fasta2{$_} != $fasta1{$_};
}
print "\n-\n";
foreach (sort keys %fasta2){
print "$_ $fasta2{$_} != $fasta1{$_}\n" if $fasta2{$_} != $fasta1{$_};
}


sub get($){
my ($url) = @_;
my $res = $ua->request(HTTP::Request->new(GET => $url));
#print " status:", $res->status_line,"\n";
return $res->content;
}

sub getFasta($){
my ($url) = @_;
my $f =get($url);
my @seqs = split /\n{2,3}/,$f;
my %hash;
foreach (@seqs) {
my ($head,$dna) = split "\n";
$head = substr($head,1);
$hash{$head} = protein($dna);
}
return %hash;
}
sub protein($){
my ($dna) = @_;
$dna =~ s/\s//g;
return join "",map { $genetic_code{$_}} unpack("a3" x (length($dna)/3), $dna)

}

__________________
Powered by Yahoo! Answers
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Closed Thread


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 11:13 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


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