3 # $Id: pf_cutoff_extract.pl,v 1.4 2009/11/11 02:28:19 cmzmasek Exp $
5 # This extracts GA, TC, or NC score cutoff values from
6 # Pfam HMM files (GA1, TC1, NC1)
7 # Copyright (C) 2008-2009 Christian M. Zmasek
9 # Created 2007-08-01 in Winterthur, Switzerland by CMZ
11 # Usage: pf_cutoff_extract.pl <Pfam HMM file> <GA|TC|NC> <outfile>
15 if ( scalar( @ARGV ) != 3 ) {
16 print "\npf_cutoff_extract.pl <Pfam HMM file> <GA|TC|NC> <outfile>\n\n";
20 my $infile = $ARGV[ 0 ];
21 my $cutoff_type = uc( $ARGV[ 1 ] );
22 my $outfile = $ARGV[ 2 ];
29 die "\n$0: \"$outfile\" already exists.\n\n";
31 unless( ( -s $infile ) && ( -f $infile ) && ( -T $infile ) ) {
32 die "\n$0: cannot read from \"$infile\".\n\n";
34 unless( $cutoff_type eq $GA || $cutoff_type eq $TC || $cutoff_type eq $NC ) {
35 die "\n$0: illegal value \"$cutoff_type\" for cutoff type.\n\n";
38 open( IN, "$infile" ) || die "\n$0: Cannot open file \"$infile\": $!\n";
39 open( OUT, ">$outfile" ) || die "\n$0: Cannot create file \"$outfile\": $!\n";
46 while ( $line = <IN> ) {
48 if ( $line =~ /^NAME\s+(.+)/ ) {
49 if ( length( $name ) > 0 ) {
50 die "\n$0: Unexpected line $line at line $line_number: $!\n";
54 elsif ( $line =~ /^$cutoff_type\s+(\S+)\s+[^;]+/ ) {
55 if ( length( $name ) < 1 ) {
56 die "\n$0: Unexpected line $line at line $line_number: $!\n";
59 print OUT "$name $1\n";
62 elsif ( $line =~ /\/\// ) {
67 close( OUT ) || die "\n$0: Cannot close file \"$outfile\": $!\n";;
69 print( "\nExtracted $n $cutoff_type" . "1 values to \"$outfile\"\n" );