-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkerNamesQTL.py
More file actions
83 lines (63 loc) · 2.42 KB
/
Copy pathMarkerNamesQTL.py
File metadata and controls
83 lines (63 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'''
To prepare your data files to work with this script:
(1) Open in Excel, delete all rows at the top save as a .csv file
Don't forget to move the file into the same directory as this script
The next three lines import some scripting tools that do not normally load with python
'''
print(__doc__)
import argparse
parser = argparse.ArgumentParser(description='Do training.')
parser.add_argument(
'--pos_vecs_file',
required=True,
type=str,
help='')
parser.add_argument(
'--neg_vecs_file_set',
required=True,
type=str,
help='')
parser.add_argument(
'--out_base',
type=str,
help='')
parser.add_argument(
'--k_folds',
type=int,
default=str,
help='')
parser.add_argument(
'--kernal',type=str,default="RBF",
help='')
args = parser.parse_args()
pos_vecs_file = args.pos_vecs_file
#from itertools import *
#from operator import *
#from decimal import *
#The next step may not be needed.
#Calling 'os' allows python to interact with your operating system and understand its organization.
#The script can now read files in directories.
#This is useful so you can process more than one of these files at once.
import os
#The next two lines determine where the script is stored and what files are stored with it.
#The script needs to be stored in a directory with your .csv files.
#The directory can contain other files, too, but none of those should be .csv files
directory = os.getcwd()
directory_list = os.listdir(directory)
#This is my dictionary
markersDict = {}
dict_csv_file_name = "input_dict.csv"
in_file_name = "FLW_f2010_QTLstats.csv"
out_file_name = "outputfile_1.csv"
for line in open(dict_csv_file_name,'r'):
marker_number,marker_name = line.strip().split(",")
assert not marker_number in markersDict, marker_number
markersDict.update({marker_number:marker_name})
dataout = file(out_file_name,"w")
for line in open(in_file_name, "r" ):
linelist = line.strip().split(",")
linelist.append(markersDict[ linelist[2]+"_"+linelist[3] ])
linelist.append(markersDict[ linelist[2]+"_"+linelist[5] ])
linelist.append(markersDict[ linelist[2]+"_"+linelist[8] ])
dataout.write(",".join(linelist)+"\n")
dataout.close()