Author: Andreas Tille <tille@debian.org>
Last-Update: Wed, 10 Jul 2019 21:58:30 +0200
Description: Result of 2to3 port to Python3

--- a/scripts/count_fixed_catalog_snps.py
+++ b/scripts/count_fixed_catalog_snps.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import optparse
 import sys
@@ -39,7 +39,7 @@
         batch_id = int(opts.batch_id)
 
     if len(path) == 0 or os.path.exists(path) == False:
-        print >> sys.stderr, "You must specify a valid path to Stacks input files."
+        print("You must specify a valid path to Stacks input files.", file=sys.stderr)
         p.print_help()
         sys.exit()
 
@@ -62,10 +62,10 @@
                 pos = entry.find(".matches.tsv")
             if (pos != -1):
                 files.append(entry[0:pos])
-        print >> sys.stderr, "Found", len(files), "Stacks samples."
+        print("Found", len(files), "Stacks samples.", file=sys.stderr)
 
     except:
-        print >> sys.stderr, "Unable to read files from Stacks directory, '" + path + "'"
+        print("Unable to read files from Stacks directory, '" + path + "'", file=sys.stderr)
 
 
 def parse_cigar(cigar, components):
@@ -143,14 +143,14 @@
             matches[sample_locus] = cat_locus
         else:
             if cat_locus != matches[sample_locus]:
-                print >> sys.stderr, "Error: sample locus", sample_locus, "matches more than one catalog locus."
+                print("Error: sample locus", sample_locus, "matches more than one catalog locus.", file=sys.stderr)
 
         if len(cigar) > 0:
             if sample_locus not in cigars:
                 cigars[sample_locus] = cigar
             else:
                 if cigar != cigars[sample_locus]:
-                    print >> sys.stderr, "Error: sample locus", sample_locus, "has multiple cigar alignments."
+                    print("Error: sample locus", sample_locus, "has multiple cigar alignments.", file=sys.stderr)
 
     fh.close()
 
@@ -279,23 +279,23 @@
 #
 i = 1
 for file in files:
-    print >> sys.stderr, "Processing file", str(i), "of", len(files), "['" +  file + "']"
+    print("Processing file", str(i), "of", len(files), "['" +  file + "']", file=sys.stderr)
     cnt = count_sample_snps(path, file, sample_snps)
-    print >> sys.stderr, "  Found", cnt, "heterozygous SNPs in sample."
+    print("  Found", cnt, "heterozygous SNPs in sample.", file=sys.stderr)
     i += 1
 
 total_snps = 0
 for locus in sample_snps:
     for col in sample_snps[locus]:
         total_snps += 1
-print >> sys.stderr, "Found", total_snps, "variable sites across the population."
+print("Found", total_snps, "variable sites across the population.", file=sys.stderr)
 
 #
 # Count all the SNPs found in the catalog.
 #
-print >> sys.stderr, "Processing the catalog"
+print("Processing the catalog", file=sys.stderr)
 cnt = count_catalog_snps(path, batch_id, catalog_snps)
-print >> sys.stderr, "  Found", cnt, "heterozygous SNPs in the catalog."
+print("  Found", cnt, "heterozygous SNPs in the catalog.", file=sys.stderr)
 
 #
 # Count all the SNPs in the catalog but not in any sample: these are the fixed differences cstacks identified.
@@ -315,7 +315,7 @@
             fixed_snps += 1
     for col in sample_snps[locus]:
         if col not in c:
-            print "Locus:", locus, "col:", col, "Catalog SNPs:", catalog_snps[locus], "Sample SNPs:", sample_snps[locus]
+            print("Locus:", locus, "col:", col, "Catalog SNPs:", catalog_snps[locus], "Sample SNPs:", sample_snps[locus])
 
-print >> sys.stderr, "Found", total_snps, "SNPs across all samples and in the catalog."
-print >> sys.stderr, "Found", fixed_snps, "fixed SNPs only in the catalog."
+print("Found", total_snps, "SNPs across all samples and in the catalog.", file=sys.stderr)
+print("Found", fixed_snps, "fixed SNPs only in the catalog.", file=sys.stderr)
--- a/scripts/integrate_alignments.py
+++ b/scripts/integrate_alignments.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import optparse
 import sys
@@ -49,7 +49,7 @@
         batch_id = int(opts.batch_id)
 
     if len(out_path) == 0 or os.path.exists(out_path) == False:
-        print >> sys.stderr, "You must specify a valid path to write files to."
+        print("You must specify a valid path to write files to.", file=sys.stderr)
         p.print_help()
         sys.exit()
 
@@ -57,12 +57,12 @@
         out_path += "/"
 
     if len(aln_path) == 0 or os.path.exists(aln_path) == False:
-        print >> sys.stderr, "You must specify a valid path to a SAM file containing catalog locus alignments."
+        print("You must specify a valid path to a SAM file containing catalog locus alignments.", file=sys.stderr)
         p.print_help()
         sys.exit()
 
     if len(path) == 0 or os.path.exists(path) == False:
-        print >> sys.stderr, "You must specify a valid path to Stacks input files."
+        print("You must specify a valid path to Stacks input files.", file=sys.stderr)
         p.print_help()
         sys.exit()
 
@@ -85,10 +85,10 @@
                 pos = entry.find(".matches.tsv")
             if (pos != -1):
                 files.append(entry[0:pos])
-        print >> sys.stderr, "Found", len(files), "Stacks samples."
+        print("Found", len(files), "Stacks samples.", file=sys.stderr)
 
     except:
-        print >> sys.stderr, "Unable to read files from Stacks directory, '", path, "'"
+        print("Unable to read files from Stacks directory, '", path, "'", file=sys.stderr)
 
 
 def parse_catalog_alignments(aln_path, alns):
@@ -115,7 +115,7 @@
             alns[locus] = (chr, bp, "+");
 
     fh.close()
-    print >> sys.stderr, "Loaded", len(alns), "catalog locus alignments from '", aln_path, "'."
+    print("Loaded", len(alns), "catalog locus alignments from '", aln_path, "'.", file=sys.stderr)
 
 
 def convert_sample(path, file, out_path, alns):
@@ -414,14 +414,14 @@
 
 i  = 1
 for file in files:
-    print >> sys.stderr, "Processing file", str(i), "of", len(files), "['" +  file + "']"
+    print("Processing file", str(i), "of", len(files), "['" +  file + "']", file=sys.stderr)
     cnt = convert_sample(path, file, out_path, alns)
-    print >> sys.stderr, "  Added alignments for", cnt, "loci."
+    print("  Added alignments for", cnt, "loci.", file=sys.stderr)
     i += 1
 
 #
 # Now process the catalog.
 #
-print >> sys.stderr, "Processing the catalog"
+print("Processing the catalog", file=sys.stderr)
 cnt = convert_catalog(path, batch_id, out_path, alns)
-print >> sys.stderr, "  Added alignments for", cnt, "catalog loci."
+print("  Added alignments for", cnt, "catalog loci.", file=sys.stderr)
