sugar._io.stockholm module

Stockholm IO

sugar._io.stockholm.fts2row(fts, inchar='-', outchar='.', splitchar='|', lensec=None)[source]
sugar._io.stockholm.is_stockholm(f, **kw)[source]
sugar._io.stockholm.read_stockholm(f, comments=None)[source]

Read Stockholm file

Parameters:

comments (list) – comment lines inside the file are stored in the comments list (optional)

Note

By default only the first alignment is read and returned. If your file contains more than one alignment, you can read some or all of them with:

from sugar import read
with open('example_stockholm_multi.stk') as f:
    seqs1 = read(f, 'stockholm')  # read 1st alignment
    seqs2 = read(f, 'stockholm')  # read 2nd alignment

Warning

This function should NOT be called directly, it registers via read() and iter_(), call this instead.

sugar._io.stockholm.row2fts(row, type_=None, seqid=None, fillchars='-.', splitchar='|')[source]
sugar._io.stockholm.write_stockholm(seqs, f, header_sugar=True)[source]

Write sequences to Stockholm file

Parameters:

header_sugar (bool) – Add a comment to the header with sugar version, default is True

Warning

This function should NOT be called directly, it registers via BioBasket.write(), call this instead.