def aligner(exprs): mod = 2.5 gp = 0.30 mA = 10.0 bG = [] T2 = [] for i, v in exprs.items(): F1 = exprl2alignment(v) T1 = PairwiseAlignment(F1, mod, gp) A1 = align_with_tree(T1, min_peaks=3) T2.append(A1) print(len(F1), F1) print('bG=', bG) print(T2) T3 = PairwiseAlignment(T2, mA, gp) A2 = align_with_tree(T3, min_peaks=4) # T3 = PairwiseAlignment(T2, mA, gp) A2.write_csv( '/home/juicebox/Desktop/Acinis/CDFdata/all_csv/all_p120s30pe10n3_p34_rt.csv', '/home/juicebox/Desktop/Acinis/CDFdata/all_csv/all_p120s30pe10n3_p34_area.csv' )
def alifeGuru(listem, folder_expr): # within replicates alignment parameters Dw = 2.0 # rt modulation [s] Gw = 0.30 # gap penalty # do the alignment trees = [] expr_list = [] expr_dir = folder_expr for gru_list in listem: for item in gru_list: print('Aligning...' + item) file_name = os.path.join(expr_dir, item) expr = load_expr(file_name) expr_list.append(expr) F1 = exprl2alignment(expr_list) print('F1' + '\n') print(F1) trees.append(F1) for t in trees: T1 = PairwiseAlignment(t, Dw, Gw) print('T1' + '\n') print(T1) A1 = align_with_tree(T1, min_peaks=2) A1.write_csv( '/home/cocopalacelove/Desktop/StrawberryExotic/output/Alignments/fullSpec_rt.csv', '/home/cocopalacelove/Desktop/StrawberryExotic/output/Alignments/fullSpec_area.csv' ) print(trees)
def multi_align_local(exprlist, Dw, Gw, min_common=1, tofile=True, transposed=True): global exprdir global outdir out_prefix = (datetime.datetime.now()).strftime("%Y-%m-%d-%H%M") print "locally aligning peaks from ", exprdir F1 = exprl2alignment(exprlist) T1 = PairwiseAlignment(F1, Dw, Gw) A1 = align_with_tree(T1, min_peaks=min_common) if tofile == True: ci_list = A1.common_ion() if transposed == True: A1.write_transposed_output( os.path.join(exprdir, out_prefix + "_aligned_rt.xlsx")) else: A1.write_excel( os.path.join(exprdir, out_prefix + "_aligned_rt.xlsx")) A1.write_csv_dk( os.path.join(exprdir, out_prefix + '_aligned_rt.csv'), os.path.join(exprdir, out_prefix + '_aligned_area.csv')) #A1.write_common_ion_csv( os.path.join(exprdir, out_prefix + '_area_common_ion.csv'), ci_list) #A1.write_ion_areas_csv( os.path.join(exprdir, out_prefix + '_aligned_ions.csv') ) return A1
def aligner(exprs): mod = 2.5 gp = 0.30 mA = 10.0 bG = [] T2 = [] for i in exprs: F1 = exprl2alignment(i) print(len(F1), F1) bG.append(F1) print('bG=', bG) #count = 0 # for s in bG: # #count += 1 # print('s=',s) # T1 = PairwiseAlignment(s, mod, gp) # T2.append[T1] # print(T2) groups = [[], [], [], [], [], [], [], [], []] for s, g in zip(bG, groups): #count += 1 print('s=', s) g = PairwiseAlignment(s, mod, gp) print('g=', g) print(groups)
def aligner(exprs, bers, names): mod = 2.5 gp = 0.30 mA = 10.0 # print exprs # print names for dict, n, b in zip(exprs, names, bers): print dict print '\n' print b print n print '\n' #for item, na in zip(dict.items(), n.items()): for item, v in dict.items(): print item # print v F1 = exprl2alignment(v) T1 = PairwiseAlignment(F1, mod, gp) A1 = align_with_tree(T1, min_peaks=2) A1.write_csv( '/home/juicebox/Desktop/Acinis/CDFdata/CDF/output/' + item + 'rt.csv', '/home/juicebox/Desktop/Acinis/CDFdata/CDF/output/' + item + 'area.csv')
def alignAll(exprs, bers, names): mod = 2.5 gp = 0.30 gp2 = 0.5 mA = 10.0 bG = [] Tall = [] for dict, n, b in zip(exprs, names, bers): print('dict=', dict) print '\n' #print b print('n=', n) print '\n' T2 = [] # for item, na in zip(dict.items(), n.items()): for item, v in dict.items(): print('itemCount=', len(dict.items())) print('item=', item) # print v F1 = exprl2alignment(v) T1 = PairwiseAlignment(F1, mod, gp) A1 = align_with_tree(T1, min_peaks=2) T2.append(A1) print('t2=', T2) T3 = PairwiseAlignment(T2, mA, gp2) A2 = align_with_tree(T3, min_peaks=3) Tall.append(A2) T4 = PairwiseAlignment(Tall, mA, gp2) A3 = align_with_tree(T4, min_peaks=3) # # print'b='+str(b) # print'n=' + str(n) A3.write_csv( '/home/juicebox/Desktop/Acinis/CDFdata/all_csv/all_10020pe2n3p233_rt.csv', '/home/juicebox/Desktop/Acinis/CDFdata/all_csv/all_10020pe2n3p233_area.csv' )
def repAlign(exprs, dir, mod1, mod2, gp1, gp2, mp1, mp2, nameTag): """ @summary: Converts experiments into alignments then models the pairwise alignments The alignments are then aligned using the pairwise alignment object. The alignment tree is then exported and saved as a .csv file @param exprs: Dictionary containing .expr files and sample identifiers @param dir: Directory to save the output alignment .csv files @param mod1: Retention time tolerance, in seconds (inner-state) @param mod2: Retention time tolerance, in seconds (between-state) @param gp1: Gap penalty (inner-state) @param gp2: Gap penalty (between-state) @param mp1: Minimum peaks required (inner-state) @param mp2: Minimum peaks required (between-state) @param nameTag: Identifier for saving .csv file @return: Two .csv files which express the similarities of each sample in retention time & peak area """ bG = [] T2 = [] for i, v in exprs.items(): F1 = exprl2alignment(v) T1 = PairwiseAlignment(F1, mod1, gp1) A1 = align_with_tree(T1, min_peaks=mp1) T2.append(A1) #print('v=', v) #print("i=", i) print(len(F1), F1) print(T2) T3 = PairwiseAlignment(T2, mod2, gp2) A2 = align_with_tree(T3, min_peaks=mp2) # T3 = PairwiseAlignment(T2, mA, gp) A2.write_csv( str(dir) + nameTag + '_rep_rt.csv', str(dir) + nameTag + '_rep_area.csv') print( str(dir) + nameTag + '_rep_rt.csv', str(dir) + nameTag + '_rep_area.csv')
def multi_align_global(alignments_list, Db, Gb, min_common=1, tofile=True): print "globally aligning local alignments from list: ", alignments_list T1 = PairwiseAlignment(alignments_list, Db, Gb) A1 = align_with_tree(T1, min_peaks=min_common) if tofile == True: A1.write_csv(expr_dir + output_prefix + 'aligned_rt.csv', expr_dir + output_prefix + 'aligned_area.csv') # A1.write_common_ion_csv(expr_dir+output_prefix+'area_common_ion.csv', common_ion_list) A1.write_ion_areas_csv(expr_dir + output_prefix + 'aligned_ions.csv') return A1
def align2(exprs, names, bers): min = 1.5 mod = 2.5 gp = 0.30 #mA = 10.0 print() for dict, n, b in zip(exprs, names, bers): #print ('dict='+dict) #print '\n' #print ('b='+str(b)) print('b=' + str(b)) print '\n' T2 = [] #for item, na in zip(dict.items(), n.items()): for item, v in dict.items(): print('item=' + str(item)) # print v F1 = exprl2alignment(v) T1 = PairwiseAlignment(F1, min, gp) A1 = align_with_tree(T1, min_peaks=2) T2.append(A1) T3 = PairwiseAlignment(T2, mod, gp) A2 = align_with_tree(T3, min_peaks=2) # print'b='+str(b) # print'n=' + str(n) A2.write_csv( '/home/juicebox/Desktop/Acinis/CDFdata/CDF/output2/' + str(b) + '_7035rt.csv', '/home/juicebox/Desktop/Acinis/CDFdata/CDF/output2/' + str(b) + '_7035area.csv')
def singleAlign(exprs, dir, mod, gp, mp, nameTag): #mod = 2.5 #gp = 0.30 F1 = exprl2alignment(exprs) T1 = PairwiseAlignment(F1, mod, gp) A1 = align_with_tree(T1, min_peaks=mp) #A1.write_csv('/home/cocopalacelove/tmp/sb_out/A1a_rt.csv', '/home/cocopalacelove/tmp/sb_out/A1a_area.csv') #A1.write_csv(str(dir)+"rasp2018_rt.csv", str(dir)+"rasp2018_area.csv") #print(str(dir)+"rasp2018_rt.csv", str(dir)+"rasp2018_area.csv") A1.write_csv( str(dir) + nameTag + "_rt.csv", str(dir) + nameTag + "_area.csv") print(str(dir) + nameTag + "_rt.csv", str(dir) + nameTag + "_area.csv")
def alife(exprZ, folder_expr): # within replicates alignment parameters Dw = 10.0 # rt modulation [s] Gw = 0.30 # gap penalty # do the alignment expr_list = [] expr_dir = folder_expr for expr_code in exprZ: print('Aligning...' + expr_code) file_name = os.path.join(expr_dir, expr_code) expr = load_expr(file_name) expr_list.append(expr) F1 = exprl2alignment(expr_list) print('F1' + '\n') print(F1) T1 = PairwiseAlignment(F1, Dw, Gw) print('T1' + '\n') print(T1) A1 = align_with_tree(T1, min_peaks=2) A1.write_csv( '/home/cocopalacelove/Desktop/StrawberryExotic/output/Alignments/Allstar10_rt.csv', '/home/cocopalacelove/Desktop/StrawberryExotic/output/Alignments/Allstar10_area.csv' )
def singleAlign(exprs, dir, mod, gp, mp, nameTag): """ @summary: Converts experiments into alignments then models the pairwise alignments. The alignments are then aligned using the pairwise alignment object. The alignment tree is then exported and saved as a .csv file @param exprs: List containing .expr files to be aligned @param dir: Directory to save the output alignment .csv files @param mod: Retention time tolerance, in seconds @param gp: Gap penalty @param mp: Minimum peaks required @param nameTag: Identifier for saving .csv file @return: Two .csv files which express the similarities of each sample in retention time & peak area """ F1 = exprl2alignment(exprs) T1 = PairwiseAlignment(F1, mod, gp) A1 = align_with_tree(T1, min_peaks=mp) A1.write_csv( str(dir) + nameTag + "_s_rt.csv", str(dir) + nameTag + "_s_area.csv") print(str(dir) + nameTag + "_s_rt.csv", str(dir) + nameTag + "_s_area.csv")
exprB_codes = ["a0806_140", "a0806_141", "a0806_142"] # within replicates alignment parameters Dw = 2.5 # rt modulation [s] Gw = 0.30 # gap penalty # do the alignment print 'Aligning expt A' expr_list = [] expr_dir = "../61a/output/" for expr_code in exprA_codes: file_name = os.path.join(expr_dir, expr_code + ".expr") expr = load_expr(file_name) expr_list.append(expr) F1 = exprl2alignment(expr_list) T1 = PairwiseAlignment(F1, Dw, Gw) A1 = align_with_tree(T1, min_peaks=2) top_ion_list = A1.common_ion() A1.write_common_ion_csv('output/area2.csv', top_ion_list) print 'Aligning expt B' expr_list = [] expr_dir = "../61b/output/" for expr_code in exprB_codes: file_name = os.path.join(expr_dir, expr_code + ".expr") expr = load_expr(file_name) expr_list.append(expr) F2 = exprl2alignment(expr_list) T2 = PairwiseAlignment(F2, Dw, Gw) A2 = align_with_tree(T2, min_peaks=2)
""" import sys, os sys.path.append("/x/PyMS/") from pyms.Experiment.IO import load_expr from pyms.Peak.List.DPA.Class import PairwiseAlignment from pyms.Peak.List.DPA.Function import align_with_tree, exprl2alignment # define the input experiments list exprA_codes = ["a0806_077", "a0806_078", "a0806_079"] # within replicates alignment parameters Dw = 2.5 # rt modulation [s] Gw = 0.30 # gap penalty # do the alignment print 'Aligning expt A' expr_list = [] expr_dir = "../61a/output/" for expr_code in exprA_codes: file_name = os.path.join(expr_dir, expr_code + ".expr") expr = load_expr(file_name) expr_list.append(expr) F1 = exprl2alignment(expr_list) T1 = PairwiseAlignment(F1, Dw, Gw) A1 = align_with_tree(T1, min_peaks=2) A1.write_csv('output/rt.csv', 'output/area.csv')