in reply to Re^6: calculation of charged amino acids
in thread calculation of charged amino acids
The only thing I can think of is that your fasta file might not have spaces between the entries. If that is the issue then this should work:
Apart from that, as much as I might like to help you, I simply can't unless I know what the problem is, not just that there is a problem.#!/usr/bin/perl -w use strict; use warnings; my $file = $ARGV[0]; my @currentProtein; my %protein; open (FASTA, "<", $file) || die "Can't open $file\n"; my $fastaLine; my $protSequence; while (<FASTA>) { #print STDERR "$_"; chomp; if (($_ !~ /^>/) && ($_ =~ /\w/)) { push (@currentProtein, $_); } if ((/^>/) || (eof)) { if ((@currentProtein > 0) || (eof)) { $protSequence = join("", @currentProtein); $protein{$fastaLine} = $protSequence; @currentProtein = (); } $fastaLine = $_ if $_ =~ /\w/; } } close FASTA; foreach my $key (sort(keys %protein)) { my $count_of_acidic = 0; my $count_of_basic = 0; my $count_of_neutral = 0; my $aa; my $sequence = "$protein{$key}"; $sequence =~ s/\s//g; my @prot=split("",$sequence); #splits string into an array #print " \nThe original PROTEIN file is:\n$sequence \n"; while(@prot) { $aa = shift (@prot); if($aa =~/[DNEQ]/ig) { $count_of_acidic++; } if($aa=~/[KRH]/ig) { $count_of_basic++; } if($aa=~/[DNEQKRH]/ig) { $count_of_neutral++; } } print "\nName: $key\n"; print "Number of acidic amino acids:".$count_of_acidic."\n"; print "Number of basic amino acids:".$count_of_basic."\n"; print "Number of neutral amino acids:".$count_of_neutral."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: calculation of charged amino acids
by yuvraj_ghaly (Sexton) on Jul 24, 2013 at 10:01 UTC | |
by mtmcc (Hermit) on Jul 24, 2013 at 10:09 UTC | |
by yuvraj_ghaly (Sexton) on Jul 25, 2013 at 04:07 UTC | |
by mtmcc (Hermit) on Jul 25, 2013 at 05:01 UTC | |
by yuvraj_ghaly (Sexton) on Jul 25, 2013 at 05:31 UTC | |
by yuvraj_ghaly (Sexton) on Jul 30, 2013 at 06:23 UTC | |
|