Skip to content

Commit befcf99

Browse files
author
Ben Elsworth
committed
black formatting
1 parent 741ab37 commit befcf99

File tree

7 files changed

+35
-32
lines changed

7 files changed

+35
-32
lines changed

Diff for: demo/scripts/source/get_opengwas.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
gwas_data_file = f"/tmp/opengwas-metadata-{today}.csv"
1818
gwas_tophits = f"/tmp/opengwas-tophits-{today}.csv"
1919

20+
2021
def get_gwas_data():
2122
# create the data
2223
gwas_api_url = "http://gwasapi.mrcieu.ac.uk/gwasinfo"
@@ -29,11 +30,11 @@ def get_gwas_data():
2930
logger.info(df["year"].describe())
3031
df.to_csv(outData, index=False)
3132
outData.close()
32-
copy_source_data(data_name=data_name,filename=gwas_data_file)
33+
copy_source_data(data_name=data_name, filename=gwas_data_file)
3334

3435

3536
def get_top_hits():
36-
df = pd.read_csv(gwas_data_file,low_memory=False)
37+
df = pd.read_csv(gwas_data_file, low_memory=False)
3738
gwas_ids = list(df.id)
3839
logger.info(gwas_ids[0:10])
3940
gwas_api_url = "http://gwasapi.mrcieu.ac.uk/tophits"
@@ -42,7 +43,7 @@ def get_top_hits():
4243
res = response.json()
4344
th_df = pd.json_normalize(res)
4445
th_df.to_csv(gwas_tophits, index=False)
45-
copy_source_data(data_name=data_name,filename=gwas_tophits)
46+
copy_source_data(data_name=data_name, filename=gwas_tophits)
4647

4748

4849
if __name__ == "__main__":

Diff for: demo/scripts/source/get_opentargets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def main(oFile) -> None:
124124

125125
OPENTARGETS_DIR.mkdir(parents=True, exist_ok=True)
126126
ot_df.to_csv(oFile, index=False)
127-
copy_source_data(data_name=data_name,filename=oFile)
127+
copy_source_data(data_name=data_name, filename=oFile)
128128

129129

130130
if __name__ == "__main__":

Diff for: demo/scripts/source/get_reactome.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ def protein_to_pathway():
2929
logger.info(df.head())
3030
filename = f"/tmp/UniProt2Reactome_All_Levels_human_{today}.csv"
3131
df.to_csv(
32-
filename,
33-
index=False,
32+
filename, index=False,
3433
)
35-
copy_source_data(data_name=data_name,filename=filename)
34+
copy_source_data(data_name=data_name, filename=filename)
3635

3736

3837
def pathways():
@@ -45,10 +44,8 @@ def pathways():
4544
df1 = df1[df1["species"] == "Homo sapiens"]
4645
logger.info(df1.head())
4746
filename = f"/tmp/ReactomePathways_human_{today}.csv"
48-
df1.to_csv(
49-
filename, index=False
50-
)
51-
copy_source_data(data_name=data_name,filename=filename)
47+
df1.to_csv(filename, index=False)
48+
copy_source_data(data_name=data_name, filename=filename)
5249

5350
# hierarchy
5451
url = "https://reactome.org/download/current/ReactomePathwaysRelation.txt"
@@ -64,10 +61,10 @@ def pathways():
6461
logger.info(df2.shape)
6562
filename = f"/tmp/ReactomePathwaysRelation_human_{today}.csv"
6663
df2.to_csv(
67-
filename,
68-
index=False,
64+
filename, index=False,
6965
)
70-
copy_source_data(data_name=data_name,filename=filename)
66+
copy_source_data(data_name=data_name, filename=filename)
67+
7168

7269
if __name__ == "__main__":
7370
protein_to_pathway()

Diff for: demo/scripts/source/variant_vep.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919

2020
vep_data_dir = "/data/vep_data"
2121

22+
2223
def process_variants(variant_file):
2324
df = pd.read_csv(variant_file, low_memory=False)
2425
df = df["rsid"]
2526
df.drop_duplicates(inplace=True)
2627
logger.info(df.head())
2728
# in this example, only run 100 variants as can be quite slow
2829
filename = f"{vep_data_dir}/variants-{today}.txt"
29-
df.head(n=100).to_csv(
30-
filename, index=False, header=False
31-
)
32-
copy_source_data(data_name=data_name,filename=filename)
30+
df.head(n=100).to_csv(filename, index=False, header=False)
31+
copy_source_data(data_name=data_name, filename=filename)
32+
3333

3434
def run_vep(variant_dir, variant_file):
3535
com = """
@@ -46,9 +46,9 @@ def run_vep(variant_dir, variant_file):
4646
logger.info(com)
4747
subprocess.call(com, shell=True)
4848
# copy results
49-
#com = f"cp /data/vep_data/vep-{today}.txt {env_configs['data_dir']}/vep/"
50-
#subprocess.call(com, shell=True)
51-
copy_source_data(data_name=data_name,filename=f'{vep_data_dir}/vep-{today}.txt')
49+
# com = f"cp /data/vep_data/vep-{today}.txt {env_configs['data_dir']}/vep/"
50+
# subprocess.call(com, shell=True)
51+
copy_source_data(data_name=data_name, filename=f"{vep_data_dir}/vep-{today}.txt")
5252

5353

5454
if __name__ == "__main__":

Diff for: tests/utils/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def is_prop_array(prop: Dict) -> bool:
1111
return prop["type"] == "array"
1212

1313

14-
def group_props_by_type(entity: Dict, column_prefix: Optional[str], is_rel: bool = False) -> Tuple:
14+
def group_props_by_type(
15+
entity: Dict, column_prefix: Optional[str], is_rel: bool = False
16+
) -> Tuple:
1517
"""
1618
Group props by scalar and array props.
1719
If `is_rel`, remove source and target from props

Diff for: tests/utils/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pydantic import BaseModel, ValidationError, validator
44

5+
56
class PropertyScalar(BaseModel):
67
doc: str
78
type: str
@@ -16,6 +17,7 @@ class PropertyArray(BaseModel):
1617
class MetaNodeMetaField(BaseModel):
1718
id: str
1819
name: str
20+
1921
class Config:
2022
fields = {"id": "_id", "name": "_name"}
2123

Diff for: workflow/scripts/utils/general.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_schema_data(meta_name="all"):
137137
elif meta_name in schema_data["meta_rels"]:
138138
schema_data = schema_data["meta_rels"][meta_name]
139139
except:
140-
logger.error('Something is wrong with db_schema.yaml')
140+
logger.error("Something is wrong with db_schema.yaml")
141141
exit()
142142
return schema_data
143143

@@ -256,30 +256,31 @@ def create_df(data_dir, name, nrows=None):
256256
return df
257257

258258

259-
def copy_source_data(data_name,filename):
259+
def copy_source_data(data_name, filename):
260260
# make sure graph directory exists
261261
server = env_configs["server_name"]
262-
data_dir = os.path.join(env_configs["data_dir"],data_name)
262+
data_dir = os.path.join(env_configs["data_dir"], data_name)
263263

264-
#make directory
264+
# make directory
265265
if server == None:
266266
com = f"mkdir -p {data_dir}"
267267
else:
268268
com = f"ssh {server} mkdir -p {data_dir}"
269269
logger.info(com)
270270
subprocess.call(com, shell=True)
271271

272-
#copy new files to data directory
272+
# copy new files to data directory
273273
logger.info("Syncing {}", filename)
274274
if server == None:
275275
com = f"rsync -avz {filename} {data_dir}"
276276
else:
277277
com = f"rsync -avz {filename} {server}:{data_dir}"
278278
logger.info(com)
279279
subprocess.call(com, shell=True)
280-
281-
def create_neo4j_array_from_array(df,col_name):
282-
df[col_name]=df[col_name].astype('str')
283-
df[col_name]=df[col_name].str.replace(',',';')
284-
df[col_name]=df[col_name].str.strip('[]')
280+
281+
282+
def create_neo4j_array_from_array(df, col_name):
283+
df[col_name] = df[col_name].astype("str")
284+
df[col_name] = df[col_name].str.replace(",", ";")
285+
df[col_name] = df[col_name].str.strip("[]")
285286
return df

0 commit comments

Comments
 (0)