in reply to Re^12: calculation of charged amino acids
in thread calculation of charged amino acids
Using this fasta file:
>DROTME_HH_Q02936 MRHIAHTQRCLSRLTSLVALLLIVLPMVFSPAHSCGPGRGLGRHRARNLY PLVLKQTIPNLSEYTNSASGPLEGVIRRDSPKFKDLVPNYNRDILFRDE >DROME_HH_Q02937 MRHIAHTQRCLSRLTSLVALLLIVLPMVFSPAHSCGPGRGLGRHRARNLY PLVLKQTIPNLSEYTNSASGPLEGVIRRDSPKFKDLVPNYNRDILFRDEE GTGADRLMSKRCKEKLNVLAYSVMNEWPGIRLLTTTTTTESWDEDYHHGQ YEGRAVTIATSDRDQSKYGMLARLAVEAGFDWVSYVSRRHIYCSVKSDSS ESLH >DROME_HH_Q02938 GTGADRLMSKRCKEKLNVLAYSVMNEWPGIRLLTTTTTTESWDEDYHHGQ YEGRAVTIATSDRDQSKYGMLARLAVEAGFDWVSYVSRRHIYCSVKSDSS ESLH
And this code (essentially the same as you've posted):
#!/usr/bin/perl 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 $he +ader; for (split '', "\U$_") { /(?<a>[BDEZ])|(?<b>[KRH])|(?<ali>[AVLI])|(?<aro +>[FHYW])|(?<po>[DEHKNQRSTZ])|(?<nonpo>[ACFGILMPVWY])/; if ($_ =~ /(?<u>[XUGJOP])/){ next;} ++$header_data{$header}{(keys %+)[0]}; } } } close $fasta_fh; for (@headers_found) { print STDERR "\n\nHeader: $_"; print STDERR "\nAcidic: $header_data{$_}{a}"; print STDERR "\nBasic: $header_data{$_}{b}"; print STDERR "\nAliphatic: $header_data{$_}{ali}"; print STDERR "\nAromatic: $header_data{$_}{aro}"; print STDERR "\nPolar: $header_data{$_}{po}"; print STDERR "\nNonpolar: $header_data{$_}{nonpo}"; print STDERR "\nUnknown: $header_data{$_}{u}" if defined $head +er_data{$_}{u}; }
I get this output:
Header: DROTME_HH_Q02936 Acidic: 7 Basic: 18 Aliphatic: 31 Aromatic: 6 Polar: 19 Nonpolar: 4 Header: DROME_HH_Q02937 Acidic: 22 Basic: 35 Aliphatic: 56 Aromatic: 16 Polar: 44 Nonpolar: 9 Header: DROME_HH_Q02938 Acidic: 14 Basic: 17 Aliphatic: 25 Aromatic: 10 Polar: 25 Nonpolar: 5If you're not getting that result, then post the error message that you get.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: calculation of charged amino acids
by yuvraj_ghaly (Sexton) on Jul 31, 2013 at 05:14 UTC | |
by Anonymous Monk on Jul 31, 2013 at 06:54 UTC | |
by yuvraj_ghaly (Sexton) on Jul 31, 2013 at 07:04 UTC | |
by mtmcc (Hermit) on Jul 31, 2013 at 07:40 UTC | |
|
Re^14: calculation of charged amino acids
by yuvraj_ghaly (Sexton) on Jul 31, 2013 at 07:02 UTC | |
by mtmcc (Hermit) on Jul 31, 2013 at 09:41 UTC | |
by yuvraj_ghaly (Sexton) on Aug 01, 2013 at 04:22 UTC | |
by mtmcc (Hermit) on Aug 01, 2013 at 07:16 UTC | |
by marto (Cardinal) on Jul 31, 2013 at 09:51 UTC |