#!/usr/local/bin/perl 
#gets line of amino acids calculates % hydrophobic for the line and puts
#in temp file

# tempres is the eisenberg-weiss hydrophobicity scale
#for this scale the cutoff for being hydrophobic is .1 and up
# hydrophylic is -.51 and below

open (REPORT, ">tempres.txt")||die "could not create temp report file";


# read in hydrophobicity values
open (HYDRO, "scale.txt");
while (<HYDRO>){
	#print "in while";
	/(.*)\s+(-?\d+\.\d+).*/;
	$phobicityhash{$1}=$2;
}


$phobic=0;
$phylic=0;
close HYDRO;
$currentacid=0;
while (<@ARGV>){
    #print $_;
	$currentacid=$phobicityhash{$_};
        if($currentacid!=undef){
		if ($currentacid>.1) {$phobic++;}
		if ($currentacid<-.51){$phylic++;}
    } 
			
} #whileone acids on one line
if ($phylic+$phobic!=0){
	print REPORT $phobic/($phylic+$phobic)."\t";
}
else {
	print REPORT "-1"."\t";
}
close REPORT;

	
