diff --git a/scripts/S02_3.2.4_uniqueIDs.py b/scripts/S02_3.2.4_uniqueIDs.py index 9c62f5c..e32bcbb 100644 --- a/scripts/S02_3.2.4_uniqueIDs.py +++ b/scripts/S02_3.2.4_uniqueIDs.py @@ -9,27 +9,25 @@ os.makedirs(pathTo2) except OSError: pass -f0 = open(pathTo2+"/Genotype_fasta-headers-rename.log", "a+") # change appropriately how do you want to call log table -fname=glob.glob(pathTo1+"/assemblerNameGenotype*.fasta") # change appropriately pattern in your file naming -for i in range (len(fname)): - vname=fname[i].split("/") - vname=vname[len(vname)-1] - idname=re.sub('\.fasta$', '', vname) - f4 = open(fname[i], "r") - f5 = open(pathTo2+"/"+str(idname) + "_renamed.fasta", "w") - line4=f4.readline() - count=1 - while line4: - line4=str.rstrip(line4) - if '>' in line4: - line44=">"+str(idname)+"_"+str(count) - f5.write("%s\n" % (line44)) - f0.write("%s\t" % (line4)) - f0.write("%s\n" % (line44)) - count=count+1 - else: - f5.write("%s\n" % (line4)) - line4 = f4.readline() - f4.close() - f5.close() -f0.close() +with open(f"{pathTo2}/Genotype_fasta-headers-rename.log", "a+") as f0: + fname = glob.glob(f"{pathTo1}/assemblerNameGenotype*.fasta") + for item in fname: + vname = item.split("/") + vname=vname[len(vname)-1] + idname=re.sub('\.fasta$', '', vname) + with open(item, "r") as f4: + f5 = open(f"{pathTo2}/{str(idname)}_renamed.fasta", "w") + line4=f4.readline() + count=1 + while line4: + line4=str.rstrip(line4) + if '>' in line4: + line44 = f">{str(idname)}_{str(count)}" + f5.write("%s\n" % (line44)) + f0.write("%s\t" % (line4)) + f0.write("%s\n" % (line44)) + count=count+1 + else: + f5.write("%s\n" % (line4)) + line4 = f4.readline() + f5.close() diff --git a/scripts/S03_3.3.9_MSA.py b/scripts/S03_3.3.9_MSA.py index f2990a5..f5e5b1f 100644 --- a/scripts/S03_3.3.9_MSA.py +++ b/scripts/S03_3.3.9_MSA.py @@ -11,15 +11,24 @@ import numbers # ref: https://www.geeksforgeeks.org/print-colors-python-terminal/ -def prRed(skk): print("\033[91m {}\033[00m" .format(skk)) -def prGreen(skk): print("\033[92m {}\033[00m" .format(skk)) -def prYellow(skk): print("\033[93m {}\033[00m" .format(skk)) -def prLightPurple(skk): print("\033[94m {}\033[00m" .format(skk)) -def prPurple(skk): print("\033[95m {}\033[00m" .format(skk)) -def prCyan(skk): print("\033[96m {}\033[00m" .format(skk)) -def prLightGray(skk): print("\033[97m {}\033[00m" .format(skk)) -def prBlack(skk): print("\033[98m {}\033[00m" .format(skk)) -def prBlue(skk): print("\033[94m {}\033[00m" .format(skk)) +def prRed(skk): + print(f"\033[91m {skk}\033[00m") +def prGreen(skk): + print(f"\033[92m {skk}\033[00m") +def prYellow(skk): + print(f"\033[93m {skk}\033[00m") +def prLightPurple(skk): + print(f"\033[94m {skk}\033[00m") +def prPurple(skk): + print(f"\033[95m {skk}\033[00m") +def prCyan(skk): + print(f"\033[96m {skk}\033[00m") +def prLightGray(skk): + print(f"\033[97m {skk}\033[00m") +def prBlack(skk): + print(f"\033[98m {skk}\033[00m") +def prBlue(skk): + print(f"\033[94m {skk}\033[00m") # from BioPython def read_fasta(fp):