Skip to content

Commit 72d92e6

Browse files
committed
nuc ups
1 parent f31076e commit 72d92e6

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

modelseedpy/core/msbuilder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def build_gpr(cpx_gene_role):
287287

288288
class MSBuilder:
289289
def __init__(
290-
self, genome, template=None, name=None, ontology_term="RAST", index="0"
290+
self, genome, template=None, name=None, ontology_term="RAST", index="0", template_core=None,
291291
):
292292
"""
293293
@@ -303,7 +303,7 @@ def __init__(
303303
self.name = name
304304
self.genome = genome
305305
self.template = template
306-
self.template_core = None
306+
self.template_core = template_core
307307
self.genome_class = None
308308
self.search_name_to_genes, self.search_name_to_original = _aaaa(
309309
genome, ontology_term

modelseedpy/core/msgenome.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
11
# -*- coding: utf-8 -*-
22
import logging
33
import re
4+
from typing import Iterable
45
from cobra.core.dictlist import DictList
56

67
logger = logging.getLogger(__name__)
78

89
DEFAULT_SPLIT = " "
910

1011

11-
def to_fasta(features, filename, line_size=80, fn_header=None):
12+
class MSFeature:
13+
def __init__(self, feature_id, sequence, description=None, aliases=None):
14+
"""
15+
16+
@param feature_id: identifier for the protein coding feature
17+
@param sequence: protein sequence
18+
@param description: description of the feature
19+
"""
20+
21+
self.id = feature_id
22+
self.seq = sequence
23+
self.description = description # temporary replace with proper parsing
24+
self.ontology_terms = {}
25+
self.aliases = aliases
26+
27+
def add_ontology_term(self, ontology_term, value):
28+
"""
29+
Add functional term to the feature
30+
31+
@param ontology_term: type of the ontology (e.g., RAST, EC)
32+
@param value: value for the ontology (e.g., pyruvate kinase)
33+
"""
34+
if ontology_term not in self.ontology_terms:
35+
self.ontology_terms[ontology_term] = []
36+
if value not in self.ontology_terms[ontology_term]:
37+
self.ontology_terms[ontology_term].append(value)
38+
39+
40+
def to_fasta(features: Iterable[MSFeature], filename, line_size=80, fn_header=None):
1241
with open(filename, "w") as fh:
1342
for feature in features:
1443
if feature.seq:
15-
h = f">{feature.id}\n"
44+
h = f">{feature.id}{DEFAULT_SPLIT}{feature.description}\n"
1645
if fn_header:
1746
h = fn_header(feature)
1847
fh.write(h)
1948
_seq = feature.seq
2049
lines = [
21-
_seq[i : i + line_size] + "\n"
50+
_seq[i: i + line_size] + "\n"
2251
for i in range(0, len(_seq), line_size)
2352
]
2453
for line in lines:
@@ -134,34 +163,6 @@ def extract_features(faa_str, split=DEFAULT_SPLIT, h_func=None):
134163
return features
135164

136165

137-
class MSFeature:
138-
def __init__(self, feature_id, sequence, description=None, aliases=None):
139-
"""
140-
141-
@param feature_id: identifier for the protein coding feature
142-
@param sequence: protein sequence
143-
@param description: description of the feature
144-
"""
145-
146-
self.id = feature_id
147-
self.seq = sequence
148-
self.description = description # temporary replace with proper parsing
149-
self.ontology_terms = {}
150-
self.aliases = aliases
151-
152-
def add_ontology_term(self, ontology_term, value):
153-
"""
154-
Add functional term to the feature
155-
156-
@param ontology_term: type of the ontology (e.g., RAST, EC)
157-
@param value: value for the ontology (e.g., pyruvate kinase)
158-
"""
159-
if ontology_term not in self.ontology_terms:
160-
self.ontology_terms[ontology_term] = []
161-
if value not in self.ontology_terms[ontology_term]:
162-
self.ontology_terms[ontology_term].append(value)
163-
164-
165166
class MSGenome:
166167
def __init__(self):
167168
self.features = DictList()

modelseedpy/core/rast_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def annotate_protein_sequence(self, protein_id: str, protein_seq: str):
100100
def annotate_protein_batch(self, protein_batch: dict):
101101
protein_annotations = {}
102102
features = [
103-
{"id": id, "protein_translation": seq} for id, seq in protein_batch.items()
103+
{"id": _id, "protein_translation": seq} for _id, seq in protein_batch.items()
104104
]
105105
params = [{"features": features}, {"stages": self.stages}]
106106
result = self.rpc_client.call("GenomeAnnotation.run_pipeline", params)

0 commit comments

Comments
 (0)