コード例 #1
0
 def listTopos(self):
     ## Outputs a file with the tree topologies in the file listed
     for j in range(1,self.runNum+1):
         os.chdir(self.basedir)
         outfile = open(self.outprefix +  "_" + str(j) + "_topolist.txt",'w')
         for i in range(len(self.treelist)):
             treek = self.treelist[i] + str(j)
             outfile.write(treek + "\n")
             treeline = ""
             
             for m in range(len(self.modellist)):
                 treedir = self.basedir + "/" + treek + "/" + self.modellist[m] + "/"
                 topofile = treek + "_" + self.modellist[m] + "_tree_topo.txt"
                 topoCount = countTopos(topofile, treedir)
                 topoline = ""
                 # Parse topology file:
                 tfile = open(treedir + topofile,'r')
                 for line in tfile:
                     temp = line.split()
                     if (re.search(r'([0-9][.])',temp[0]) != None):
                         topoline = topoline + temp[1] + ","
                     elif (temp[0] == "Raw"):
                         topoline = self.modellist[m] + "," + topoline
                         break
                     else:
                         continue
                 outfile.write(treeline + topoline.rstrip(",") + "\n")
         outfile.close()    
コード例 #2
0
 def countToposTwoModsOut(self, treelist2,headerlist2):
     ## Counts topologies for two different base trees (i.e. two models)
     for j in range(1,self.runNum + 1):
         os.chdir(self.basedir)
         outfile = open("treeleafgrowstopotable" + str(j) + ".txt",'w')
         header = "tree," + self.makeheadersuff(2)
         outfile.write(header)
         for i in range(len(self.treelist)):
             treek = self.treelist[i] + str(j)
             treeg = treelist2[i] + str(j) 
             treeline = treek
            
             for m in range(len(self.modellist)):
                 treedir = self.basedir + "/" + treek + "/" + self.modellist[m] + "/"
                 topofile = treek + "_" + self.modellist[m] + "_tree_topo.txt"
                 treeline = treeline + "," + str(countTopos(topofile,treedir))
                 topofile = treeg + "_" + self.modellist[m] + "_tree_topo.txt"
                 treeline = treeline + "," + str(countTopos(topofile,treedir))
             outfile.write(treeline + "\n")
         outfile.close()
コード例 #3
0
 def countToposOut(self):
     ## Counts topologies found for each type of simulation
     for j in range(1,self.runNum + 1):
         os.chdir(self.basedir)
         outfile = open(self.topooutprefix + str(j) + ".txt",'w')
         header = "tree," + self.makeheadersuff()
         outfile.write(header)
         for i in range(len(self.treelist)):
             treek = self.treelist[i] + str(j)
             treeline = treek
            
             for m in range(len(self.modellist)):
                 treedir = self.basedir + "/" + treek + "/" + self.modellist[m] + "/"
                 topofile = treek + "_" + self.modellist[m] + "_tree_topo.txt"
                 treeline = treeline + "," + str(countTopos(topofile,treedir))
             outfile.write(treeline + "\n")
         outfile.close()