#!/usr/bin/perl -w #1_cp_ppb_x_cp_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: 1_cp_ppb_x_cp_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 groups that have a single copy in ppb and multiple copies in cct my $bothspp=0; my $outfile ="1_cp_ppb_x_cp_cct_output.txt";##provides the groups with the protein accession number and counts my $outfile2 ="1_cp_ppb_x_cp_cct_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 total proteins, cct proteins and ppb proteins in each group\n";##giving this a label while (my $line=<>){##takes a look at each line of the groups.txt next unless($line=~m/cct\|\S{38}\d{5,7}\S{1}\d{5,7}\S{1}\d{1}\scct\|/);##looks at lines that includes at least 2 cct proteins next unless ($line=~m/ppb/);#looks at lines that contains at least 1 ppb protein next if ($line=~m/ppb\|\S{38}\d{5,7}\S{1}\d{5,7}\S{1}\d{1}\sppb\|/);##skips line if it contains more than 1 ppb protein $bothspp++;#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 my $cct+= ()=($line =~ m/cct/g);# counts the number of cct proteins in each line my $ppb+= ()=($line =~ m/ppb/g);# counts the number of ppb proteins in each line print $out "$line \($count proteins total, $cct cct protein, $ppb ppb proteins\)\n";#prints to the outfile the entire line (includes group number and proteins involved) and the number of proteins print $out2 "$count $cct $ppb\n";##prints only the counts of the number of proteins in each group to a file } print "There are $bothspp groups of protein families that contain a single copy of ppb, but multiple copies of cct\n";#provides terminal output for the overall number of groups with multiple copies of cct and 1 copy of ppb ## "There are 9 groups of protein families that contain a single copy of ppb, but multiple copies of cct.