in reply to Re: Listing occurence of all residues
in thread Listing occurence of all residues

Thank you. I have updated the question.I think it is more clear now.

  • Comment on Re^2: Listing occurence of all residues

Replies are listed 'Best First'.
Re^3: Listing occurence of all residues
by pme (Monsignor) on Mar 01, 2015 at 15:06 UTC
    Hi sreya, could you attach a sample 'e.txt'?
      Here is a sample file. I have used shebang line and declarations of varibles.But since I am posing the question to experts I just avoided them. Thank you for considering my question.

      >sp|P05100|3MG1_ECOLI DNA-3-methyladenine glycosylase 1

      MERCGWVSQDPLYIAYHDNEWGVPETDSKKLFEMICLEGQQAGLSWITVLKKRENYRACF

      HQFDPVKVAAMQEEDVERLVQDAGIIRHRGKIQAIIGNARAYLQMEQNGEPFVDFVWSUV

      >sp|P30871|3PASE_ECOLI Inorganic triphosphatase

      MAQEIELKFIVNHSAVEALRDHLNTLGGEHHDPVQLLNIYYETPDNWLRGHDMGLRI

      RGE NGRYEMTMKVAGRVTGGLHQRPEYNVALSEPTLDLAQLPTEVWPNGELPADLASRVQPLF

        I hope this little piece of code help. I supposed that the residues are marked with letters A-Z.
        #!/usr/bin/perl -w use strict; open FILE1, "<e.txt" or die "can't open file for reading: $!\n"; my %Fasta_split; my $id; while (<FILE1>) { chomp; next if(/^\s*$/); my $FastaLine = $_; if ( $FastaLine =~ /^>sp\|(\w+\S+)\|/ ) { $id = $1; } else { $Fasta_split{$id} .= $FastaLine; } } # print header my @header = qw/A B C D E F G H I J K L M N O P Q R S T U V W X Y Z/; print "ID " . join(' ', @header) . "\n"; # print data foreach my $id (sort keys %Fasta_split) { my %words; # count letters $words{$_}++ for split('', $Fasta_split{$id}); printf "%8s ", $id; # print counts foreach my $w (@header) { if (defined $words{$w}) { printf "%2d ", $words{$w}; } else { print ' - '; } } print "\n"; }