in reply to Re^3: calculation of charged amino acids
in thread calculation of charged amino acids
I expect that's supposed to be a response to me: you've actually responded to yourself.
Here's the sort of thing I think you want:
#!/usr/bin/env perl use 5.010; use strict; use warnings; use autodie; my $header = ''; my (@headers_found, %header_data); open my $fasta_fh, '<', $ARGV[0]; while (<$fasta_fh>) { chomp; next if /^\s*($|#)/; if (/^>(.*)$/) { push @headers_found, ($header = $1); } else { die 'Sequence data found without a header!' unless $header; for (split '', "\U$_") { /(?<a>[DNEQ])|(?<b>[KRH])|(?<n>.)/; ++$header_data{$header}{(keys %+)[0]}; } } } close $fasta_fh; for (@headers_found) { say "Header: $_"; say "\tAcidic: $header_data{$_}{a}"; say "\tBasic: $header_data{$_}{b}"; say "\tNeutral: $header_data{$_}{n}"; }
I made a slight modification to ++mtmcc's sample data: just added some comments with and without leading whitespace for testing purposes. Do note that's what sample data should look like! It's not the command you type. Here's a sample run:
$ pm_fasta_amino_charge_calc.pl pm_mtmccs_data_modified.fasta Header: DROTME_HH_Q02936 Acidic: 14 Basic: 18 Neutral: 67 Header: DROME_HH_Q02937 Acidic: 33 Basic: 35 Neutral: 136 Header: DROME_HH_Q02938 Acidic: 18 Basic: 17 Neutral: 69
Notes:
-- Ken
|
|---|