Mercurial > repos > guerler > springsuite
diff spring_minz.py @ 27:e34da554d415 draft
"planemo upload commit f12d400ea7827bb7d6b2ef31eb7f38e555bd053f-dirty"
author | guerler |
---|---|
date | Sat, 31 Oct 2020 22:46:10 +0000 |
parents | 5d1ae615e4ec |
children | 41353488926c |
line wrap: on
line diff
--- a/spring_minz.py Sat Oct 31 22:21:11 2020 +0000 +++ b/spring_minz.py Sat Oct 31 22:46:10 2020 +0000 @@ -40,6 +40,7 @@ inputs=inputs, inputPath=inputPath, crossReference=crossReference, + idLength=args.idlength, minScore=args.minscore, logFile=logFile, interactions=interactions) @@ -53,6 +54,7 @@ inputPath=targetPath, crossReference=crossReference, minScore=args.minscore, + idLength=args.idlength, logFile=logFile, interactions=interactions) interactions = sorted(interactions.values(), key=lambda item: item["minZ"], reverse=True) @@ -61,15 +63,15 @@ output_file.write("%s\t%s\t%s\t%s\n" % (entry["targetName"], entry["inputName"], entry["minZ"], entry["minInfo"])) logFile.close() -def matchScores(targetFile, targetName, inputs, inputPath, crossReference, minScore, logFile, interactions): - targetTop, targetHits = getTemplateScores(targetFile, minScore) +def matchScores(targetFile, targetName, inputs, inputPath, crossReference, minScore, idLength, logFile, interactions): + targetTop, targetHits = getTemplateScores(targetFile, minScore, idLength) if not targetHits: print("No targets found `%s`" % targetFile) else: print ("Loaded target scores from `%s`." % targetFile) for inputName in inputs: inputFile = "%s/%s" % (inputPath, inputName) - inputTop, inputHits = getTemplateScores(inputFile, minScore) + inputTop, inputHits = getTemplateScores(inputFile, minScore, idLength) minZ = 0 minInfo = "" for t in targetHits: @@ -92,16 +94,17 @@ interactions[interactionKey] = dict(targetName=targetName, inputName=inputName, minZ=minZ, minInfo=minInfo) logFile.write("Interaction between %s and %s [min-Z: %s].\n" % (targetName, inputName, minZ)) -def getTemplateScores(hhrFile, minScore): +def getTemplateScores(hhrFile, minScore, idLength): result = dict() topTemplate = None + idLength = idLength + 4 if os.path.isfile(hhrFile): with open(hhrFile) as file: for index, line in enumerate(file): if index > 8: if not line.strip(): break - templateId = line[4:10] + templateId = line[4:idLength] templateScore = float(line[57:63]) if templateScore > minScore: if topTemplate is None: @@ -119,5 +122,6 @@ parser.add_argument('-o', '--output', help='Output file containing min-Z scores', required=True) parser.add_argument('-l', '--log', help='Log file', required=True) parser.add_argument('-m', '--minscore', help='min-Z score threshold', type=int, default=10) + parser.add_argument('-idx', '--idlength', help='Length of identifier in reference', type=int, default=6) args = parser.parse_args() main(args) \ No newline at end of file