Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^17: calculation of charged amino acids

by mtmcc (Hermit)
on Aug 01, 2013 at 07:16 UTC ( #1047375=note: print w/ replies, xml ) Need Help??


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

#!/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; }


Comment on Re^17: calculation of charged amino acids
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2014-08-21 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls