Testing regular expression

need to use regex to put everything in the right hash for comparing
later.

This is testing if the regex works to deal with building the hash
selecting the correct parts and putting them in the right part.
Working hash building

the read in file is tab delimited, which was messing up my regex.
Added an if to deal with lines that don't match my regex
diff --git a/comp_contigs.pl b/comp_contigs.pl
index 761ae2d..fc16d26 100644
--- a/comp_contigs.pl
+++ b/comp_contigs.pl
@@ -14,7 +14,10 @@ my %forward_probe_for  = ();
 my %gene_probe_for 	= ();

 while (my $line = <$probe_list>) {
-	if ($line =~ m/(CUST_\d+_\w+)\s(rc_contig\d{5})/) {
+	if ($line !~ m/CUST_\d+_\w+/) {
+		next;
+	}
+	if ($line =~ m/(CUST_\d+_\w+)\src_(contig\d{5})/) {

 		# add an entry to reverse hash
 		$reverse_probe_for{$2} = $1;
@@ -32,9 +35,27 @@ while (my $line = <$probe_list>) {

 }

-# loop through the contigs, find the ones that have the same id and see if
-# they are the same
+# comparing the contigs
+my @same_probes;
+my @different_probes;

-# if they are the same add to an array
+foreach my $contig (keys %reverse_probe_for) {
+	# get the forward and back of contig
+	my $forward = $forward_probe_for{$contig};
+	my $reverse = $reverse_probe_for{$contig};

-# if not add to a different array
+	if ($forward eq $reverse ) {
+		push(@same_probes, $contig)
+
+	} else {
+		push(@different_probes, $contig)
+
+	}
+}
+
+# reporting results
+
+print length(keys %reverse_probe_for), " reverse contigs\n";
+print length(keys %forward_probe_for), " forward contigs\n";
+print length(@same_probes), " are the same\n";
+print length(@different_probes), " are different\n";
The code for comparing the Hashes

a for loop over the keys of one of the hashes. As the names of
the keys is the same for both, I can use that to access the
probe name for the reverse complement and the forward contig.
From there I can compare the two and push the name onto the
approprate hash.
Print output report

Report the number of same and different probes as well as the
number of forward and reverse contigs in the hashes

diff --git a/comp_contigs.pl b/comp_contigs.pl
index 761ae2d..fc16d26 100644
--- a/comp_contigs.pl
+++ b/comp_contigs.pl
@@ -14,7 +14,10 @@ my %forward_probe_for  = ();
 my %gene_probe_for 	= ();

 while (my $line = <$probe_list>) {
-	if ($line =~ m/(CUST_\d+_\w+)\s(rc_contig\d{5})/) {
+	if ($line !~ m/CUST_\d+_\w+/) {
+		next;
+	}
+	if ($line =~ m/(CUST_\d+_\w+)\src_(contig\d{5})/) {

 		# add an entry to reverse hash
 		$reverse_probe_for{$2} = $1;
@@ -32,9 +35,27 @@ while (my $line = <$probe_list>) {

 }

-# loop through the contigs, find the ones that have the same id and see if
-# they are the same
+# comparing the contigs
+my @same_probes;
+my @different_probes;

-# if they are the same add to an array
+foreach my $contig (keys %reverse_probe_for) {
+	# get the forward and back of contig
+	my $forward = $forward_probe_for{$contig};
+	my $reverse = $reverse_probe_for{$contig};

-# if not add to a different array
+	if ($forward eq $reverse ) {
+		push(@same_probes, $contig)
+
+	} else {
+		push(@different_probes, $contig)
+
+	}
+}
+
+# reporting results
+
+print length(keys %reverse_probe_for), " reverse contigs\n";
+print length(keys %forward_probe_for), " forward contigs\n";
+print length(@same_probes), " are the same\n";
+print length(@different_probes), " are different\n";