Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^16: calculation of charged amino acids

by yuvraj_ghaly (Sexton)
on Aug 01, 2013 at 04:22 UTC ( #1047347=note: print w/ replies, xml ) Need Help??


in reply to Re^15: calculation of charged amino acids
in thread calculation of charged amino acids

Here is the fasta sequence in file

>gi|44809|emb|CAA29377.1| unnamed protein product [Myxococcus xanthus] MSVDKAFRDMIRNEIEVQLKPLRDVVARLEEGTADLDALRNVAERLAPLAEVVGPLFGAQIPAAAKAGRR +GPGRPPAARSAVTAAPAAVGGKRRGRKPAAAGADGSRACAIIGCGKPSRTKGYCAAHYQKLRMLEKTNR +RPSDWKDYADPDSVDDIKLPRGRAASKALAAAAQAGHAG


Comment on Re^16: calculation of charged amino acids
Download Code
Replies are listed 'Best First'.
Re^17: calculation of charged amino acids
by mtmcc (Hermit) on Aug 01, 2013 at 07:16 UTC
    #!/usr/bin/perl use strict; use warnings; use autodie; my $a; my $b; my $ali; my $aro; my $po; my $nonpo; my $sum = 0; my $u = 0; my $tag = 0; my @line; my $header = ''; my (@headers_found, %header_data); open (my $fasta_fh, '<', $ARGV[0]); while (<$fasta_fh>) { chomp; if ($_ !~ /^>(.*)$/) { @line = split('',$_); for (@line) { $a += 1 if $_ =~ /[BDEZ]/; $b += 1 if $_ =~ /[KRH]/; $ali += 1 if $_ =~ /[AVLI]/; $aro += 1 if $_ =~ /[FHYW]/; $po += 1 if $_ =~ /[DEHKNQRSTZ]/; $nonpo += 1 if $_ =~ /[ACFGILMPVWY]/; $u += 1 if $_ =~ /[XUGJOP]/; $sum += 1; } } if ((/^>(.*)$/) || (eof)) { if ($sum > 0) { $header_data{$tag}{'a'} = $a; $header_data{$tag}{'b'} = $b; $header_data{$tag}{'ali'} = $ali; $header_data{$tag}{'aro'} = $aro; $header_data{$tag}{'po'} = $po; $header_data{$tag}{'nonpo'} = $nonpo; $header_data{$tag}{'u'} = $u; $a = 0; $b = 0; $ali = 0; $aro = 0; $po = 0; $ +u = 0; $nonpo = 0; $sum = 0; } $tag = $_ unless eof; push (@headers_found, $tag) unless (eof); } } close $fasta_fh; for (@headers_found) { print STDOUT "\nHeader: $_\n"; print STDOUT "Acidic: $header_data{$_}{'a'}\n" if $header_dat +a{$_}{'a'} > 0;; print STDOUT "Basic: $header_data{$_}{'b'}\n" if $header_dat +a{$_}{'b'} > 0;; print STDOUT "Aliphatic: $header_data{$_}{'ali'}\n" if $header +_data{$_}{'ali'} > 0;; print STDOUT "Aromatic: $header_data{$_}{'aro'}\n" if $header_ +data{$_}{'aro'} > 0;; print STDOUT "Polar: $header_data{$_}{'po'}\n" if $header_data +{$_}{'po'} > 0;; print STDOUT "Nonpolar: $header_data{$_}{'nonpo'}\n" if $heade +r_data{$_}{'nonpo'} > 0;; print STDOUT "Unknown: $header_data{$_}{'u'}\n" if $header_dat +a{$_}{'u'} > 0; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047347]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-31 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls