#!/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;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|