Commit fe352f70 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Merge branch 'signalp-mature-option' into 'develop'

SignalP include_mature parameter

See merge request SOaAS/psot!8
parents 5e73cabf e626a12c
import sys
import json
import argparse
from os import path
parser = argparse.ArgumentParser(description='Convert signalp results to json documents')
parser.add_argument('--result', '-r', required=True, help='The signalp result file')
parser = argparse.ArgumentParser(description='Convert signalp results to json document')
parser.add_argument('--result', '-r', required=True, help='The signalp result directory')
parser.add_argument('--output', '-o', required=True, help='The converted results json file')
args = parser.parse_args()
filename = args.result
mature_file = args.result + '/mature.fas'
include_mature = path.isfile(mature_file)
mature = {}
if include_mature:
with open(mature_file) as m:
id = None
for line in m:
if line.startswith(">"):
id = line.split()[0][1:]
mature[id] = ''
elif id is not None:
mature[id] += line.strip()
filename = args.result + '/results.txt'
documents = {}
with open(filename) as f:
tool = None
for line in f:
......@@ -17,15 +34,21 @@ with open(filename) as f:
split = line.split()
if not split[0] in documents:
documents[split[0]] = {"id": split[0], "computations": [{'tool': tool, 'results':[]}]}
results = documents[split[0]]['computations'][0]["results"]
results = documents[split[0]]['computations'][0]["results"]
if split[9] == "Y":
'signalpeptide': True,
'score': float(split[8]),
'start': 1,
'end': int(split[2])-1
if include_mature:
results[-1]['mature sequence'] = mature[split[0]]
except ValueError:
print('SignalP Converter: No mature sequence received for protein {}, although signal peptide present!'.format(split[0]))
results.append({'signalpeptide': False})
......@@ -36,5 +59,6 @@ with open(filename) as f:
'mode': split[2]}
output_filename = args.output
with open(output_filename, 'w') as o:
json.dump(documents, o)
#!/usr/bin/env python3
import env
import argparse
from psot import config
from os import system
from os import system,makedirs
signalp_tool = config.load_config()['tools'].get('signalp', 'signalp')
parser = argparse.ArgumentParser(description='Find signal peptides in amino acid sequences')
parser.add_argument('--fasta', '-f', required=True, help='A fasta file with aminoacid sequences')
parser.add_argument('--organism', '-o', choices=['euk', 'gram+', 'gram-'], default='euk', help='The organism type')
parser.add_argument('--output', required=True, help='The output file')
parser.add_argument('--include_mature', '-m', action='store_true', help='Include mature sequences of proteins with signal peptide')
parser.add_argument('--output', required=True, help='The result directory. Will contain results.txt and optionally mature.fas.')
args = parser.parse_args()
system(signalp_tool + " -t " + args.organism + " " + args.fasta + " > " + args.output)
makedirs(args.output, exist_ok=True)
mature_param = " -m {}/mature.fas ".format(args.output) if args.include_mature else " "
results_file = args.output + '/results.txt'
system(signalp_tool + " -t " + args.organism + mature_param + args.fasta + " > " + results_file)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment