-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcriteria_runner.py
59 lines (40 loc) · 1.92 KB
/
criteria_runner.py
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
import argparse
import os
import criteria_mendelian_randomization
from criteria_mendelian_randomization import process_file
from criteria_mendelian_randomization import Criteria
import pandas as pd
parser = argparse.ArgumentParser(
description = 'Generates random sequence of clinical and demographic features',
usage = '%(prog)s [options] <infile> <outfile>')
#parser.add_argument('-n', '--iterations', default=10, dest='iter', action='store', required=True, help="Number of GSEA iterations")
parser.add_argument('-i','--criteria', dest='inp', action='store', required=True, help='Tab delimited criterion file', default = '')
parser.add_argument('-o','--outfile',dest='out', action='store', required=True, help='Name of fasta output file')
parser.add_argument('-n','--numbers',dest='nums', action='store', required=True, help='Number of random values to generate')
options = parser.parse_args()
# Check if input files exist
if not os.path.isfile(options.inp)==True:
print("Cannot find input file ",options.inp)
sys.exit(1)
if not os.path.isfile(options.inp)==True:
print("Cannot find input file ",options.inp)
sys.exit(1)
df = process_file(options.inp, options.nums)
print ("FIRST")
print (df)
# Adjust values for Height and Weight columns so that women are shorter and lighter
#df.loc[df['Gender'] == 'female', ['Height', 'Weight']] *= 0.9
#df.loc[df.loc['Gender'] == 'female', ['Height', 'Weight']] *= 0.9
#print (df.loc['Gender' == 'female'])
# Adjust values in the "Height" row based on "Gender" row
if df.loc['Gender'].str.contains('female').any():
df.loc['Height'] *= 0.9
# Adjust values in the "Weight" row based on "Gender" row
if df.loc['Gender'].str.contains('female').any():
df.loc['Weight'] *= 0.9
# Calculate BMI and create a new row
#df['BMI'] = df['Weight'] / ((df['Height'] / 100) ** 2)
df.loc['BMI'] = df.loc['Weight']/ ((df.loc['Height'] / 100) ** 2)
print()
print ("ADJUSTED")
print (df)