1
1
#!/usr/bin/python
2
2
# -*- coding: utf-8 -*-
3
3
4
+ import os
4
5
from beams import in_out
6
+ import networkx as nx
7
+ from beams .grouping import group_features
5
8
from beams .annotation import annotate_adducts
6
9
from beams .annotation import annotate_isotopes
10
+ from beams .annotation import annotate_oligomers
11
+ from beams .annotation import annotate_multiple_charged_ions
7
12
from beams .annotation import annotate_compounds
8
13
from beams .annotation import annotate_molecular_formulae
9
14
from beams .annotation import summary
15
+ from beams import plots
16
+
10
17
11
18
def main ():
12
19
13
- fn_peaklist = "../tests/test_data/variableMetadata.txt"
14
- fn_matrix = "../tests/test_data/dataMatrix.txt"
20
+ path = "../tests/test_data/"
21
+ fn_peaklist = os .path .join (path , "variableMetadata.txt" )
22
+ fn_matrix = os .path .join (path , "dataMatrix.txt" )
15
23
16
- # df = in_out.combine_peaklist_matrix(fn_peaklist, fn_matrix)
24
+ df = in_out .combine_peaklist_matrix (fn_peaklist , fn_matrix )
17
25
18
- fn_matrix = "../tests/test_data/Study_pospeaks_both_parts_no_MPA.txt"
19
- #df = in_out.read_xset_matrix(fn_matrix, first_sample="s1")
26
+ ion_mode = "pos"
20
27
21
- fn_peaklist = "../tests/test_data/peaklist_dims_pos_theoretical.txt"
22
- df = in_out .read_peaklist (fn_peaklist )
28
+ db_out = "results_{}.sqlite" .format (ion_mode )
23
29
24
- db_out = "../tests/test_data/results.sqlite"
30
+ graphs = group_features ( df , db_out , max_rt_diff = 5.0 , coeff_thres = 0.7 , pvalue_thres = 0.01 , method = "pearson" )
25
31
26
- #df = df[0:700]
27
- #print(df)
28
- #graph = group_features(df, db_out, max_rt_diff=5.0, coeff_thres=0.7, pvalue_thres=None, method="pearson")
32
+ nx .write_gml (graphs , "graphs.gml" )
33
+ # graphs = nx.read_gml("graphs.gml")
29
34
30
- #nx.write_gml(graph, "../tests/test_data/graph.gml")
31
- #graph = nx.read_gml("../tests/test_data/graph.gml")
32
35
33
- lib_isotopes = in_out .read_isotopes ("../beams/data/isotopes.txt" , "pos" )
34
- lib_adducts = in_out .read_adducts ("../beams/data/adducts.txt" , "pos" )
35
- lib_multiple_charged_ions = in_out .read_multiple_charged_ions ("../beams/data/multiple_charged_ions.txt" , "pos" )
36
- #lib_mass_differences = in_out.read_mass_differences("data/multiple_charged_differences.txt", "pos")
37
- fn_mf = "../beams/data/trimMMD_sortAmass.txt"
38
- fn_cpds = "../beams/data/trimMMD_sortMF.txt"
39
- fn_sql_db = "../beams/data/MIDB_260916.sqlite"
36
+ path = "../beams/data"
37
+ lib_isotopes = in_out .read_isotopes (os .path .join (path , "isotopes.txt" ), ion_mode )
38
+ lib_adducts = in_out .read_adducts (os .path .join (path , "adducts.txt" ), ion_mode )
39
+ lib_multiple_charged_ions = in_out .read_multiple_charged_ions (os .path .join (path , "multiple_charged_ions.txt" ), ion_mode )
40
+ lib_mass_differences = in_out .read_mass_differences (os .path .join (path , "multiple_charged_differences.txt" ), ion_mode )
40
41
41
42
print (lib_isotopes )
42
43
print (lib_adducts )
43
- print (lib_multiple_charged_ions )
44
44
45
45
ppm = 5.0
46
46
47
- #annotate_adducts(graph, db_out, ppm, lib_adducts)
48
- annotate_adducts (df , db_out , ppm , lib_adducts )
49
- #annotate_isotopes(graph, db_out, ppm, lib_isotopes)
50
- #annotate_isotopes(df, db_out, ppm, lib_isotopes)
51
- #annotate_oligomers(graphs, db_out, ppm, lib_adducts)
52
- #annotate_artifacts(testdata_no_MPA, db_out, 0.005)
53
- #annotate_multiple_charged_ions(graph, db_out, ppm, lib_multiple_charged_ions)
47
+ annotate_adducts (graphs , db_out , ppm , lib_adducts )
48
+ annotate_isotopes (graphs , db_out , ppm , lib_isotopes )
49
+ annotate_oligomers (graphs , db_out , ppm , lib_adducts )
50
+ annotate_multiple_charged_ions (graphs , db_out , ppm , lib_multiple_charged_ions )
54
51
55
- annotate_molecular_formulae (df , lib_adducts , ppm , db_out , fn_mf )
56
- #annotate_molecular_formulae(df, lib_adducts, ppm, db_out)
57
- annotate_compounds (df , lib_adducts , ppm , db_out , fn_sql_db , "HMDB__25_09_2016" )
52
+ # annotate_molecular_formulae(df, lib_adducts, ppm, db_out)
53
+ annotate_compounds (df , lib_adducts , ppm , db_out , "lipidmaps_full_20181217_v1" )
58
54
59
55
df_out = summary (df , db_out )
60
- fn_out = "../tests/test_data/summary.txt"
61
- df_out .to_csv (fn_out , sep = "\t " , index = False )
56
+ fn_out = "summary_{}.txt" .format (ion_mode )
57
+ df_out .to_csv (fn_out , sep = "\t " , index = False , encoding = "utf-8" )
58
+
59
+ pdf_out = "report_{}.pdf" .format (ion_mode )
60
+ plots .report (db = db_out , pdf_out = pdf_out , column_corr = "r_value" , column_pvalue = "p_value" ,
61
+ column_ppm_error = "ppm_error" , column_adducts = "adduct" )
62
+
62
63
63
64
if __name__ == '__main__' :
64
- main ()
65
+ main ()
0 commit comments