#!/usr/bin/perl -w #unique_cct.pl use strict; use warnings; ##NB: To run this script on the file my_orthomcl_dir/groups.txt, specify it when runniong the script to add it to the @AGRV array die "usage: unique_cct.pl \n" if (@ARGV!=1);##if a file is not specified in the beginning, it will die print "Processing file $ARGV[0]\n"; ##counting lines/protein groups unique to ppb my $uniqppb=0; my $outfile ="unique_ppb_output.txt";##provides the groups with the protein accession number and counts my $outfile2 ="unique_ppb_data.txt";##just numbers to make analysis easy open (my $out, ">$outfile") or die ("Problem with opening $outfile: $!");#open the file or the program dies open (my $out2, ">$outfile2") or die ("Problem with opening $outfile2: $!"); print $out2 "# of ppb proteins in groups\n";##giving this a label while (my $line = <>){##takes a look at each line of the groups.txt next unless ($line=~/ppb/);##looks at lines that include ppb pattern (ppb protein) next unless ($line!~/cct/);####ignores lines that include cct pattern $uniqppb++;##add a count each time there is a line that matches above parameters my $count+= ()=($line =~ m/\|/g);#counts the number of proteins in each line of which they are all ppb (see above) print $out "$line \($count ppb proteins\)\n";##prints to the outfile the entire line (includes group number and proteins involved) and the number of proteins print $out2 "$count\n";##prints only the counts of the number of proteins in each group to a file } print "There are $uniqppb groups of protein families unique to ppb\n";##provides terminal output for the overall number of groups unique to ppb close($out) ##output "There are 116 groups of protein families uniqe to ppb"