生物表型包
子模块
- Bio.表型.phen_微模块
PlateRecord
PlateRecord.__init__()
PlateRecord.__getitem__()
PlateRecord.__setitem__()
PlateRecord.__delitem__()
PlateRecord.__iter__()
PlateRecord.__contains__()
PlateRecord.__len__()
PlateRecord.__eq__()
PlateRecord.__add__()
PlateRecord.__sub__()
PlateRecord.get_row()
PlateRecord.get_column()
PlateRecord.subtract_control()
PlateRecord.__repr__()
PlateRecord.__str__()
PlateRecord.__firstlineno__
PlateRecord.__hash__
PlateRecord.__static_attributes__
WellRecord
WellRecord.__init__()
WellRecord.__setitem__()
WellRecord.__getitem__()
WellRecord.__iter__()
WellRecord.__eq__()
WellRecord.__add__()
WellRecord.__sub__()
WellRecord.__len__()
WellRecord.__repr__()
WellRecord.__str__()
WellRecord.get_raw()
WellRecord.get_times()
WellRecord.get_signals()
WellRecord.fit()
WellRecord.__firstlineno__
WellRecord.__hash__
WellRecord.__static_attributes__
JsonIterator()
CsvIterator()
JsonWriter
- Bio.phenotype.pm_试衣模块
模块内容
表型数据输入/输出。
输入
主要功能是Bio.表型.parse(.)它接受输入文件并格式化字符串。 这返回一个迭代器,给出PlateRecord对象:
>>> from Bio import phenotype
>>> for record in phenotype.parse("phenotype/Plates.csv", "pm-csv"):
... print("%s %i" % (record.id, len(record)))
...
PM01 96
PM09 96
请注意,parse()函数将通过默认设置调用格式的相关解析器。 您可能想要更多控制,在这种情况下,您需要直接创建特定于格式的序列迭代器。
输入-单一记录
如果您希望您的文件包含一条且只有一条记录,那么我们提供以下“helper”函数,该函数将返回单个PlateRecord,或者如果没有记录或有多个记录,则引发异常:
>>> from Bio import phenotype
>>> record = phenotype.read("phenotype/Plate.json", "pm-json")
>>> print("%s %i" % (record.id, len(record)))
PM01 96
当您只期望单个记录(并且会将多个记录视为错误)时,这种风格很有用。 例如,处理opm库保存的PM杨森文件时。
然而,如果您只是想要包含多个记录的文件中的第一个记录,请在迭代器上使用Next()函数:
>>> from Bio import phenotype
>>> record = next(phenotype.parse("phenotype/Plates.csv", "pm-csv"))
>>> print("%s %i" % (record.id, len(record)))
PM01 96
只要文件至少包含一条记录,上述代码就可以工作。请注意,如果有多个记录,其余记录将被悄然忽略。
输出
使用函数Bio.表型. writing(.),它采用一组完整的PlateRecord对象(作为列表或迭代器)、输出文件柄(或者在Biopython的最新版本中,输出文件名作为字符串),当然还有文件格式::
from Bio import phenotype
records = ...
phenotype.write(records, "example.json", "pm-json")
或者,使用句柄:
from Bio import phenotype
records = ...
with open("example.json", "w") as handle:
phenotype.write(records, handle, "pm-json")
您需要调用此函数一次(包含您的所有记录),如果使用手柄,请确保关闭它以将数据刷新到硬盘。
文件格式
指定文件格式时,请使用MIDI字符串。
pm-json -Jackson格式的表现型微阵列板。
- pm-CSV -CSV格式的表型微阵列板,这是
机器供应商格式
请注意,虽然Bio. externative可以读取上述文件格式,但它只能以杨森格式写入。
- Bio.phenotype.write(plates, handle, format)
将完整的PlateRecords集写入文件。
板 - PlateRecord对象的列表(或迭代器)。
- 手柄 - 要写入的文件处理对象,或字符串形式的文件名
(note Biopython的旧版本只采用了手柄)。
格式 - 描述要写入的文件格式的大写字符串。
调用此函数后您应该关闭手柄。
返回写入的记录数(作为一个整数)。
- Bio.phenotype.parse(handle, format)
将表型文件转换为返回PlateRecords的迭代器。
- 手柄 - 文件的句柄,或字符串形式的文件名
(note Biopython的旧版本只采用了手柄)。
格式 - 描述文件格式的大写字符串。
典型用法,打开一个要读入的文件,并循环遍历记录:
>>> from Bio import phenotype >>> filename = "phenotype/Plates.csv" >>> for record in phenotype.parse(filename, "pm-csv"): ... print("ID %s" % record.id) ... print("Number of wells %i" % len(record)) ... ID PM01 Number of wells 96 ID PM09 Number of wells 96
使用Bio.phenotype.read(.)当您只需要单个记录时,函数。
- Bio.phenotype.read(handle, format)
将表型文件转换为单个PlateRecord。
- 手柄 - 文件的句柄,或字符串形式的文件名
(note Biopython的旧版本只采用了手柄)。
格式 - 描述文件格式的字符串。
此函数用于解析只包含一条记录的表型文件。 例如,读取PM JSON文件:
>>> from Bio import phenotype >>> record = phenotype.read("phenotype/Plate.json", "pm-json") >>> print("ID %s" % record.id) ID PM01 >>> print("Number of wells %i" % len(record)) Number of wells 96
如果手柄不包含记录或包含多个记录,则会引发异常。 例如::
from Bio import phenotype record = phenotype.read("plates.csv", "pm-csv") Traceback (most recent call last): ... ValueError: More than one record found in handle
然而,如果你想要一个包含多条记录的文件中的第一条记录,这个函数将引发一个异常(如上面的例子所示)。 相反用途:
>>> from Bio import phenotype >>> record = next(phenotype.parse("phenotype/Plates.csv", "pm-csv")) >>> print("First record's ID %s" % record.id) First record's ID PM01
如果您想从该手柄读取多个记录,请使用Bio. photype.parse(handle,form)函数。