comparison spring_minz.py @ 22:acaff61a09b2 draft

"planemo upload commit 83cb18661a4c7839dbec8d42b6018ddc80defd8f-dirty"
author guerler
date Wed, 28 Oct 2020 06:49:58 +0000
parents 5feab7f00f02
children 5469e19f1f96
comparison
equal deleted inserted replaced
21:5feab7f00f02 22:acaff61a09b2
1 #! /usr/bin/env python3 1 #! /usr/bin/env python3
2 import argparse 2 import argparse
3 import os 3 import os
4 4
5 def main(args): 5 def main(args):
6 inputs = set() 6 inputs = list()
7 with open(args.inputlist) as file: 7 with open(args.inputlist) as file:
8 for index, line in enumerate(file): 8 for index, line in enumerate(file):
9 name = line.strip() 9 name = line.strip()
10 inputs.add(name) 10 inputs.append(name)
11 print ("Loaded %s input names from `%s`." % (len(inputs), args.inputlist)) 11 print ("Loaded %s input names from `%s`." % (len(inputs), args.inputlist))
12 targets = set() 12 targets = list()
13 duplicates = 0 13 duplicates = 0
14 with open(args.targetlist) as file: 14 with open(args.targetlist) as file:
15 for index, line in enumerate(file): 15 for index, line in enumerate(file):
16 name = line.strip() 16 name = line.strip()
17 targets.add(name) 17 targets.append(name)
18 if name in inputs: 18 if name in inputs:
19 duplicates = duplicates + 1 19 duplicates = duplicates + 1
20 print ("Loaded %s target names from `%s`." % (len(targets), args.targetlist)) 20 print ("Loaded %s target names from `%s`." % (len(targets), args.targetlist))
21 crossReference = dict() 21 crossReference = dict()
22 with open(args.crossreference) as file: 22 with open(args.crossreference) as file:
32 for targetName in targets: 32 for targetName in targets:
33 targetDirectory = args.targetpath.rstrip("/") 33 targetDirectory = args.targetpath.rstrip("/")
34 targetFile = "%s/%s" % (targetDirectory, targetName) 34 targetFile = "%s/%s" % (targetDirectory, targetName)
35 matchScores(targetFile=targetFile, 35 matchScores(targetFile=targetFile,
36 targetName=targetName, 36 targetName=targetName,
37 inputs=inputs, 37 inputs=sorted(inputs),
38 inputPath=args.inputpath, 38 inputPath=args.inputpath,
39 crossReference=crossReference, 39 crossReference=crossReference,
40 minScore=args.minscore, 40 minScore=args.minscore,
41 idLength=args.idx, 41 idLength=args.idx,
42 interactions=interactions) 42 interactions=interactions)
78 if score > minZ: 78 if score > minZ:
79 minZ = score 79 minZ = score
80 minInfo = "%s\t%s\t%s\t%s" % (targetTop, inputTop, t, p) 80 minInfo = "%s\t%s\t%s\t%s" % (targetTop, inputTop, t, p)
81 if minZ > minScore: 81 if minZ > minScore:
82 if targetName > inputName: 82 if targetName > inputName:
83 interactionKey = "%s_%s_%s" % (targetName, inputName, minZ) 83 interactionKey = "%s_%s" % (targetName, inputName)
84 else: 84 else:
85 interactionKey = "%s_%s_%s" % (inputName, targetName, minZ) 85 interactionKey = "%s_%s" % (inputName, targetName)
86 if interactionKey not in interactions: 86 if interactionKey in interactions:
87 interactions[interactionKey] = dict(targetName=targetName, inputName=inputName, minZ=minZ, minInfo=minInfo) 87 if interactions[interactionKey]["minZ"] >= minZ:
88 continue
89 interactions[interactionKey] = dict(targetName=targetName, inputName=inputName, minZ=minZ, minInfo=minInfo)
88 print("Predicting: %s, min-Z: %s, templates: %s" % (inputName, minZ, minInfo)) 90 print("Predicting: %s, min-Z: %s, templates: %s" % (inputName, minZ, minInfo))
89 return interactions 91 return interactions
90 92
91 def getTemplateScores(hhrFile, minScore, identifierLength): 93 def getTemplateScores(hhrFile, minScore, identifierLength):
92 result = dict() 94 result = dict()