Skip to content

Commit 2d1e624

Browse files
authored
Merge pull request #150 from Fxe/dev
genome IO
2 parents 7ad20c4 + 35ecbc7 commit 2d1e624

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

modelseedpy/core/msgenome.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
DEFAULT_SPLIT = " "
99

1010

11-
def to_fasta(features, filename, l=80, fn_header=None):
11+
def to_fasta(features, filename, line_size=80, fn_header=None):
1212
with open(filename, "w") as fh:
1313
for feature in features:
14-
h = f">{feature.id}\n"
15-
if fn_header:
16-
h = fn_header(feature)
17-
fh.write(h)
18-
lines = [
19-
feature.seq[i : i + l] + "\n" for i in range(0, len(feature.seq), l)
20-
]
21-
for line in lines:
22-
fh.write(line)
14+
if feature.seq:
15+
h = f">{feature.id}\n"
16+
if fn_header:
17+
h = fn_header(feature)
18+
fh.write(h)
19+
_seq = feature.seq
20+
lines = [
21+
_seq[i : i + line_size] + "\n"
22+
for i in range(0, len(_seq), line_size)
23+
]
24+
for line in lines:
25+
fh.write(line)
2326
return filename
2427

2528

@@ -188,3 +191,15 @@ def search_for_gene(self, query):
188191
return self.features.get_by_id(query)
189192
aliases = self.alias_hash()
190193
return aliases[query] if query in aliases else None
194+
195+
def _repr_html_(self):
196+
return f"""
197+
<table>
198+
<tr>
199+
<td><strong>Memory address</strong></td>
200+
<td>{f"{id(self):x}"}</td>
201+
</tr><tr>
202+
<td><strong>Features</strong></td>
203+
<td>{len(self.features)}</td>
204+
</tr>
205+
</table>"""

modelseedpy/core/mstemplate.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -520,23 +520,23 @@ def get_data(self):
520520
class MSTemplateBiomass:
521521
def __init__(
522522
self,
523-
bio_id,
524-
name,
525-
type,
526-
dna,
527-
rna,
528-
protein,
529-
lipid,
530-
cellwall,
531-
cofactor,
532-
pigment,
533-
carbohydrate,
534-
energy,
535-
other,
523+
biomass_id: str,
524+
name: str,
525+
type: str,
526+
dna: float,
527+
rna: float,
528+
protein: float,
529+
lipid: float,
530+
cellwall: float,
531+
cofactor: float,
532+
pigment: float,
533+
carbohydrate: float,
534+
energy: float,
535+
other: float,
536536
):
537537
"""
538538
539-
:param bio_id:string
539+
:param biomass_id:string
540540
:param name:string
541541
:param type:string
542542
:param dna:float
@@ -550,7 +550,7 @@ def __init__(
550550
:param energy:float
551551
:param other:float
552552
"""
553-
self.id = bio_id
553+
self.id = biomass_id
554554
self.name = name
555555
self.type = type
556556
self.dna = dna

0 commit comments

Comments
 (0)