Index: trunk/tools/microtest.pl
===================================================================
--- trunk/tools/microtest.pl	(revision 27612)
+++ trunk/tools/microtest.pl	(revision 27619)
@@ -20,5 +20,5 @@
 my ($verbose);                             # Verbosity?
 my ($save_temps);                          # Save temporary outputs?
-my ($clusters_raw, $clusters_ds9, $streaks_ds9);     # Output modes
+my ($clusters_raw, $clusters_ds9, $streaks_raw, $streaks_ds9);     # Output modes
 
 GetOptions(
@@ -32,4 +32,5 @@
     'clusters-raw' => \$clusters_raw,       # Output raw x,y for clusters?
     'clusters-ds9' => \$clusters_ds9, # Output ds9 region files of clusters?
+    'streaks-raw' => \$streaks_raw,   # Output raw x,y for streaks?
     'streaks-ds9' => \$streaks_ds9,   # Output ds9 region files of streaks?
            'verbose' => \$verbose, # Verbosity?
@@ -79,8 +80,8 @@
 
     # Format the clusters file
-    open my $clustersFile, "$clusters" or die "Cannot open clusters file $clusters: $!";
+    open my $clustersInput, "$clusters" or die "Cannot open clusters file $clusters: $!";
     my ($radecFile, $radecName) = tempfile( "/tmp/microtest.XXXX",
                                           UNLINK => !$save_temps, SUFFIX => '.dat' );
-    my @contents = <$clustersFile>; # Contents of clusters file
+    my @contents = <$clustersInput>; # Contents of clusters file
     foreach my $line (@contents) {
         $line =~ s/^\s*//;
@@ -89,5 +90,5 @@
             defined $ra and defined $dec and $ra !~ /[[:alpha:]]/ and $dec !~ /[[:alpha:]]/;
     }
-    close $clustersFile;
+    close $clustersInput;
     close $radecFile;
 
@@ -96,5 +97,11 @@
         ) or die "Unable to execute SQL: $DBI::errstr";
 
-    open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw;
+    open my $clustersFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw;
+    print $clustersFile "# chip cell x y ra dec\n" if defined $clusters_raw;
+    my (@streak1, @streak2, $num_streaks);
+    if (defined $streaks_raw) {
+        $num_streaks = `head -n 1 $streaks`;
+        chomp $num_streaks;
+    }
     foreach my $chip (@$chips) {
         my $class = $chip->{class_id};
@@ -117,7 +124,62 @@
                 my $cellName = $line[6];
 
-                print $outFile "$chipName $cellName $x $y $ra $dec\n";
+                print $clustersFile "$chipName $cellName $x $y $ra $dec\n";
             }
         }
+
+        if (defined $streaks_raw) {
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => "$ppCoord -astrom $astrom -raw $uri -streaks $streaks -all -radians",
+                    verbose => $verbose);
+            die "Unable to run ppCoord" unless $success;
+
+            my @lines = split(/\n/, join("", @$stdout_buf));
+            my $index = 0;
+            foreach my $line (@lines) {
+                my @line = split /\s+/, $line;
+
+                my $ra1 = $line[0];
+                my $dec1 = $line[1];
+                my $ra2 = $line[2];
+                my $dec2 = $line[3];
+                my $x1 = $line[5];
+                my $y1 = $line[6];
+                my $chipName1 = $line[7];
+                my $cellName1 = $line[8];
+                my $x2 = $line[9];
+                my $y2 = $line[10];
+                my $chipName2 = $line[11];
+                my $cellName2 = $line[12];
+
+                if ($x1 ne "nan" and $y1 ne "nan") {
+                    my $streak = $streak1[$index];
+                    unless (defined $streak) {
+                        $streak = { 'ra' => $ra1,
+                                    'dec' => $dec1,
+                                    'x' => $x1,
+                                    'y' => $y1,
+                                    'chip' => $chipName1,
+                                    'cell' => $cellName1
+                        };
+                        $streak1[$index] = $streak;
+                    }
+                }
+                if ($x2 ne "nan" and $y2 ne "nan") {
+                    my $streak = $streak2[$index];
+                    unless (defined $streak) {
+                        $streak = { 'ra' => $ra2,
+                                    'dec' => $dec2,
+                                    'x' => $x2,
+                                    'y' => $y2,
+                                    'chip' => $chipName2,
+                                    'cell' => $cellName2
+                        };
+                        $streak2[$index] = $streak;
+                    }
+                }
+                $index++;
+             }
+        }
+
 
         if (defined $clusters_ds9) {
@@ -136,4 +198,37 @@
 
     }
-    close $outFile if defined $clusters_raw;
+    close $clustersFile if defined $clusters_raw;
+
+    if (defined $streaks_raw) {
+        open my $streaksFile, "> $label.${name}.streaks.xy" or die "Cannot open output file: $!";
+        print $streaksFile "# chip1 cell1 x1 y1 chip2 cell2 x2 y2 ra1 dec1 ra2 dec2\n";
+        for (my $i = 0; $i < $num_streaks; $i++) {
+            my $s1 = $streak1[$i];
+            my $s2 = $streak2[$i];
+
+            my $ra1 = $s1->{ra};
+            my $dec1 = $s1->{dec};
+            my $ra2 = $s2->{ra};
+            my $dec2 = $s2->{dec};
+            my $x1 = $s1->{x};
+            my $y1 = $s1->{y};
+            my $chipName1 = $s1->{chip};
+            my $cellName1 = $s1->{cell};
+            my $x2 = $s2->{x};
+            my $y2 = $s2->{y};
+            my $chipName2 = $s2->{chip};
+            my $cellName2 = $s2->{cell};
+
+            if (defined $ra1 and defined $dec1 and defined $ra2 and defined $dec2 and
+                defined $x1 and defined $y1 and defined $chipName1 and defined $cellName1 and
+                defined $x2 and defined $y2 and defined $chipName2 and defined $cellName2) {
+                print $streaksFile "$chipName1 $cellName1 $x1 $y1 $chipName2 $cellName2 $x2 $y2 $ra1 $dec1 $ra2 $dec2\n";
+            } else {
+                print $streaksFile "UNKNOWN UNKNOWN nan nan UNKNOWN UNKNOWN nan nan nan nan nan nan\n";
+            }
+        }
+        close $streaksFile;
+
+    }
+
 }
