@@ -0,0 +1,1594 @@
+#!/opt/anaconda3/bin/python3.4%0Aimport sys%0Aimport re%0A%0Aif (len(sys.argv) != 2):%0A    print(%22exec %3Cphylip%3E%22)%0A    sys.exit(0)%0A%0Afile  = sys.argv%5B1%5D%0A%0Adef compute_CpG(puz):%0A    f = open(puz,%22r%22)%0A    lines = f.readlines()%0A    f.close()%0A    lines_clean = %5B%5D%0A    Nsite_nuc = 0%0A    for line,index in zip(lines,%5Bi for i in range(0,len(lines))%5D):%0A        if(index != 0):%0A            lines_clean.append(line.split(%22 %22)%5B-1%5D)%0A        else:%0A            Nsite_nuc = line.split(%22 %22)%5B-1%5D.strip()%0A%0A    Nsp = cpg12 = cpg23 = cpg31 = 0%0A    for line_clean in lines_clean:%0A        line_clean = line_clean.strip()%0A        Nsp += 1%0A%0A        for i,j in zip(%5Bline_clean%5Bi%5D for i in range(0,len(line_clean),3)%5D,%5C%0A                       %5Bline_clean%5Bi%5D for i in range(1,len(line_clean),3)%5D):%0A            if ((i==%22C%22 or i==%22c%22) and (j==%22G%22 or j == %22g%22)):%0A                cpg12 +=1%0A        for i,j in zip(%5Bline_clean%5Bi%5D for i in range(1,len(line_clean),3)%5D,%5C%0A                       %5Bline_clean%5Bi%5D for i in range(2,len(line_clean),3)%5D):%0A            if ((i==%22C%22 or i == %22c%22) and (j==%22G%22 or j==%22g%22)):%0A                cpg23 +=1%0A        for i,j in zip(%5Bline_clean%5Bi%5D for i in range(2,len(line_clean),3)%5D,%5C%0A                       %5Bline_clean%5Bi%5D for i in range(3,len(line_clean),3)%5D):%0A            if ((i==%22C%22 or i == %22c%22) and (j==%22G%22 or j==%22g%22)):%0A                cpg31 +=1%0A%0A    return (cpg12+cpg23+cpg31,cpg12,cpg23,cpg31,Nsp,Nsite_nuc)%0A%0Atup = compute_CpG(file)%0Aprint(%22Ntaxa %22, tup%5B4%5D, %22 Nsite_nuc %22, tup%5B5%5D)%0Aprint(%22CpG %22, round(tup%5B0%5D,3))%0Aprint(%22CpG1 %22, round(tup%5B1%5D,3))%0Aprint(%22CpG2 %22, round(tup%5B2%5D,3))%0Aprint(%22CpG3 %22, round(tup%5B3%5D,3))%0A

Compute CpG dinucleotide for codon postions 1-2, 2-3, and 3-1.