-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_metadata_summary.py
More file actions
24 lines (22 loc) · 949 Bytes
/
build_metadata_summary.py
File metadata and controls
24 lines (22 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse
import glob
import csv
import json
def main(json_dir, output):
json_files = glob.glob(json_dir+"/*.json")
with open(output, 'w') as csv_out:
writer = csv.writer(csv_out)
header = ["accession","database","protein_name","enzyme_type","organism_name","organism_division","reviewed"]
writer.writerow(header)
for json_file in json_files:
row = []
for attribute in header:
value = json.load(open(json_file)).get(attribute)
row.append(value)
writer.writerow(row)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("json_dir", type=str, help="Path to directory with json files containing extra info for each query sequence")
parser.add_argument("output", type=str, help="Path to output .csv file")
args = parser.parse_args()
main(args.json_dir, args.output)