#!/usr/bin/perl use strict; use warnings; use Data::Dumper; =cut open( my $in, "c:/Documents and Settings/mydir/Desktop/current/mart_export.txt" ); open( my $out, ">c:/Documents and Settings/mydir/Desktop/current/clone_qual_counts.txt" ); my $first_line = <$in>; chomp $first_line; my %clone_hash; print $out "clone\tgood\tbad\n"; while (<$in>) { chomp; my @fields = split /\t/; my ($gene_symbol, $esc_qc) = ($fields[1], $fields[8]); #use regex to extend to a hash of hashes to separate good and bad clone counts my $grade = ($esc_qc =~ /^pass[1-3]$/) ? 'good' : 'bad'; $clone_hash{$gene_symbol}{$grade}++; } for (keys %clone_hash) { #print $out "$_ \t $clone_hash{$_}{good}\n" if exists $clone_hash{$_}{good}; print $out "$_ \t$clone_hash{$_}{good}\n" if exists $clone_hash{$_}{good}; #print $out "\t$clone_hash{$_}->{'bad'}\n"; } #print Dumper(\%clone_hash); close ($in); close ($out);