File tree 2 files changed +40
-25
lines changed 2 files changed +40
-25
lines changed Original file line number Diff line number Diff line change 8
8
DEFAULT_SPLIT = " "
9
9
10
10
11
- def to_fasta (features , filename , l = 80 , fn_header = None ):
11
+ def to_fasta (features , filename , line_size = 80 , fn_header = None ):
12
12
with open (filename , "w" ) as fh :
13
13
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 )
23
26
return filename
24
27
25
28
@@ -188,3 +191,15 @@ def search_for_gene(self, query):
188
191
return self .features .get_by_id (query )
189
192
aliases = self .alias_hash ()
190
193
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>"""
Original file line number Diff line number Diff line change @@ -520,23 +520,23 @@ def get_data(self):
520
520
class MSTemplateBiomass :
521
521
def __init__ (
522
522
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 ,
536
536
):
537
537
"""
538
538
539
- :param bio_id :string
539
+ :param biomass_id :string
540
540
:param name:string
541
541
:param type:string
542
542
:param dna:float
@@ -550,7 +550,7 @@ def __init__(
550
550
:param energy:float
551
551
:param other:float
552
552
"""
553
- self .id = bio_id
553
+ self .id = biomass_id
554
554
self .name = name
555
555
self .type = type
556
556
self .dna = dna
You can’t perform that action at this time.
0 commit comments