changeset 9:4ac5d5a9b21c draft

"planemo upload commit f465445ebca0307953f59938494a2244ca8ea23c"
author guerler
date Sat, 01 Aug 2020 02:13:31 -0400
parents f2f38991c36f
children 860bd6f8f480
files spring_minz.py spring_minz.xml
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/spring_minz.py	Sat Aug 01 00:35:20 2020 -0400
+++ b/spring_minz.py	Sat Aug 01 02:13:31 2020 -0400
@@ -18,7 +18,7 @@
 				crossreference[core] = []
 			crossreference[core].append(partner)
 	print ("Loaded cross reference from `%s`." % args.crossreference)
-	targets = get_template_scores(args.target, args.minscore)
+	targets = get_template_scores(args.target, args.minscore, args.idx)
 	interactions = []
 	if not targets:
 		print("No targets found `%s`" % args.target)
@@ -27,7 +27,7 @@
 		for name in names:
 			input_directory = args.inputs.rstrip("/")
 			input_file = "%s/%s" % (input_directory, name)
-			templates = get_template_scores(input_file, args.minscore)
+			templates = get_template_scores(input_file, args.minscore, args.idx)
 			minz = 0
 			for t in targets:
 				if t in crossreference:
@@ -45,15 +45,16 @@
 		for i in interactions:
 			output_file.write("%s %s\n" % (i[0], i[1]))
 
-def get_template_scores(hhr_file, min_score):
+def get_template_scores(hhr_file, min_score, identifier_length):
 	result = {}
+	identifier_length = identifier_length + 4
 	if os.path.isfile(hhr_file):
 		with open(hhr_file) as file:
 			for index, line in enumerate(file):
 				if index > 8:
 					if not line.strip():
 						break
-					template_id = line[4:10]
+					template_id = line[4:identifier_length]
 					template_score = float(line[57:63])
 					if template_score > min_score:
 						result[template_id] = template_score
@@ -63,8 +64,9 @@
 	parser = argparse.ArgumentParser(description='This script identifies interactions by detecting matching HH-search results.')
 	parser.add_argument('-t', '--target', help='HHR target file result', required=True)
 	parser.add_argument('-c', '--crossreference', help='Cross Reference index file', required=True)
+	parser.add_argument('-x', '--idx', help='Length of identifier', type=int, default=6)
 	parser.add_argument('-l', '--list', help='Text file containing identifiers.', required=True)
-	parser.add_argument('-i', '--inputs', help='Directory containing `hhr/X/Y.hhr` files', required=True)
+	parser.add_argument('-i', '--inputs', help='Directory containing `hhr` files', required=True)
 	parser.add_argument('-o', '--output', help='Output file containing minZ-scores`', required=True)
 	parser.add_argument('-m', '--minscore', help='min-Z score threshold', type=int, default=10)
 	args = parser.parse_args()
--- a/spring_minz.xml	Sat Aug 01 00:35:20 2020 -0400
+++ b/spring_minz.xml	Sat Aug 01 02:13:31 2020 -0400
@@ -7,13 +7,14 @@
             link '${str(input)}' 'inputs/${input.element_identifier}' &&
             echo '${input.element_identifier}' >> 'input_list' &&
         #end for
-        python3 '$__tool_directory__/spring_minz.py' -m '$minscore' -t '$target' -c '$crossreference' -o '$output' -l input_list -i inputs
+        python3 '$__tool_directory__/spring_minz.py' -m '$minscore' -t '$target' -c '$crossreference' -x '$idx' -o '$output' -l input_list -i inputs
     ]]></command>
     <inputs>
         <param format="txt" name="target" type="data" label="Target Profile" help="Homology search result of target/query profile `hhr`."/>
         <param format="txt" name="inputs" type="data_collection" collection_type="list" label="Input Profiles" help="Homology search results of input profiles `hhr`."/>
-        <param format="txt" name="crossreference" type="data" label="Cross Reference" help="Cross reference of interacting proteins pairs from SPRING database protocol."/>
+        <param format="txt" name="crossreference" type="data" label="Cross Reference" help="Cross reference of interacting proteins `first_id metadata_id second_id`."/>
         <param name="minscore" type="integer" label="min-Z score threshold" value="10" min="1" max="100" help="Matching interaction pairs with a score lower than this threshold will be excluded."/>
+        <param name="idx" type="integer" label="Identifier length" value="6" min="1" max="10" help="Specify the length of the identifier e.g. `1ACB_A` has length 6."/>
     </inputs>
     <outputs>
         <data format="txt" name="output" />