Functions#
- pycomsa.open(file, mode='r', format=None, size_format='N')#
Open a file for reading or for writing with CoMSA.
- Parameters:
file (
str,PathLike, orIOBase) – Either the path to a file to be opened, or a file-like object in binary mode that supportsseek.mode (
rorw) – The mode with which to open the file, similarly toopen.format (
fasta,stockholmorNone) – The format of the file to be read or written. IfNonegiven (the default), the format will be auto-detected while reading, or set tostockholmwhen writing.size_format (
str) – The format to use for reading and writingsize_tvalues, as astructformat specifier. The defaultNuses the nativesize_ttype, but other formats can be given for cross-platform compatibility.
Example
>>> with pycomsa.open("trimal.msac") as reader: ... msa = reader[0] ... len(msa.sequences) 50
- Raises:
ValueError – When given an invalid argument, or when the file format could not be auto-detected from the file contents.