summaryrefslogtreecommitdiff
path: root/biology/haplohseq/files/patch-scripts_ldmap.py
blob: f9fb588048b134ec2163ad809fb6bdda08e078b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--- scripts/ldmap.py.orig	2021-01-23 17:32:15 UTC
+++ scripts/ldmap.py
@@ -29,10 +29,10 @@ class MapMaker:
     coordinates of the haplotype marker genomic positions.
     '''
     def __init__(self, markerFilename, haplotypesFilename):
-        print "reading haplotype base coordinates ...."
+        print("reading haplotype base coordinates ....")
         self.coords, self.coordIndexes, self.refs, self.alts = self.readMarkers(markerFilename)
 #         self.haplotypes = self.readHaplotypes(haplotypesFilename)
-        print "reading haplotype panel ...."
+        print("reading haplotype panel ....")
         self.markerCalls = self.readHaplotypes(haplotypesFilename, transpose = True)
     
     # reads from a vcf file of defined positions representing the haplotype data    
@@ -118,7 +118,7 @@ class MapMaker:
         # 1) COLLECT MARGINALS AND IDENTIFY SITES THAT ARE POLYMORPHIC
         # If a site has only one allele in the haplotype panel it is not informative, so it won't be used
         # in LD calculations.  We may want to consider setting some minimum threshold for a minor allele frequency.
-        print "collecting marginal allele counts and identifying polymorphic sites from haplotype panel ...."
+        print("collecting marginal allele counts and identifying polymorphic sites from haplotype panel ....")
         for index in range(0,len(self.markerCalls)):
             ref = self.refs[index]
             alt = self.alts[index]
@@ -152,7 +152,7 @@ class MapMaker:
         log.write("Num non-polymorphic sites: " + str(numNonpolymorphicSites) + "\n")
                
         # 2) CALCULATE D FOR POLYMORPHIC SITES COMPARED WITH N SITES TO THE RIGHT THAT ARE POLYMORPHIC
-        print "calculating D between polymorphic sites and their neighbors ...."
+        print("calculating D between polymorphic sites and their neighbors ....")
         dVals = []
         for i in range(0, len(polymorphicIndexes)):   # the last coordinate won't have any partners
             index_i = polymorphicIndexes[i]
@@ -244,7 +244,7 @@ class LDMap:
         return ldMap
         
     def save(self, filename):
-        print "saving ldmap to " + filename
+        print("saving ldmap to " + filename)
         ldMapFile = open(filename, 'w')
         ldMapFile.write("\t".join(["COORD","REF","ALT","PAIRED_ALLELES"]) + "\n")
         for i in range(0,len(self.coords)):