-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_ModuleInputFile.py
69 lines (52 loc) · 2.09 KB
/
6_ModuleInputFile.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
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
import sys, argparse
import logging
###########################################################
# Parses on STDIN a tsv file as produced
# by BuildInteractome.py
# Adds a 3rd column: Edge weight
# Edge weight value = 1
#
# Prints to STDOUT in .tsv format
# Output consists of 3 columns:
# - ENSG of Protein A
# - ENSG of Protein B
# - Edge weight = 1
def ModuleInputFile(highqualityPPI):
logging.info("Starting to run...")
highqualityPPI = sys.stdin
# Parsing the file
for line in highqualityPPI:
line = line.rstrip('\n')
Interactome_fields = line.split('\t')
print(Interactome_fields[0] + "\t" + Interactome_fields[1] + "\t" + str(1))
logging.info("All Done, completed successfully!")
return
###########################################################
# Taking and handling command-line arguments
def main():
file_parser = argparse.ArgumentParser(description =
"""
-----------------------------------------------------------------------------------------------------------
Program: Parses the output file produced by Interactome.py, processes it and prints to STDOUT
-----------------------------------------------------------------------------------------------------------
Usage:
% python 6_ModuleInputFile.py < Input file
OR
% cat Input file | python 6_ModuleInputFile.py
The output consists of three columns in .tsv format:
-> ENSG of Protein A
-> ENSG of Protein B
-> Edge weight = 1
The OUTPUT FILE generated by this script can be used as INPUT for most of the MODULE IDENTIFICATION METHODS
-----------------------------------------------------------------------------------------------------------
""",
formatter_class = argparse.RawDescriptionHelpFormatter)
file_parser.set_defaults(func=ModuleInputFile)
args = file_parser.parse_args()
args.func(args)
if __name__ == "__main__":
# Logging to Standard Error
Log_Format = "%(levelname)s - %(asctime)s - %(message)s \n"
logging.basicConfig(stream = sys.stderr, format = Log_Format, level = logging.DEBUG)
main()