Bio.motifs 套件

子套件

子模組

模組內容

用於序列圖案分析的工具。

Bio.motifs 包含核心 Motif 類別,其中包含各種 I/O 方法,以及用於圖案比較和在序列中搜尋圖案的方法。它還包括解析來自 AlignACE、MEME 和 MAST 程式輸出的功能,以及 TRANSFAC 格式的檔案。

Bio.motifs.create(instances, alphabet='ACGT')

建立一個 Motif 物件。

Bio.motifs.parse(handle, fmt, strict=True)

從圖案搜尋程式剖析輸出檔案。

目前支援的格式(忽略大小寫)
  • AlignAce:AlignAce 輸出檔案格式

  • ClusterBuster:Cluster Buster 位置頻率矩陣格式

  • XMS:XMS 矩陣格式

  • MEME:MEME 輸出檔案圖案

  • MINIMAL:MINIMAL MEME 輸出檔案圖案

  • MAST:MAST 輸出檔案圖案

  • TRANSFAC:TRANSFAC 資料庫檔案格式

  • pfm-four-columns:具有四個欄位的通用位置頻率矩陣格式。(cisbp、homer、hocomoco、neph、tiffin)

  • pfm-four-rows:具有四個列的通用位置頻率矩陣格式。(scertf、yetfasco、hdpi、idmmpmm、flyfactor survey)

  • pfm:JASPAR 樣式的位置頻率矩陣

  • jaspar:JASPAR 樣式的多個 PFM 格式

  • sites:JASPAR 樣式的位點檔案

由於 pfm 和 sites 格式的檔案僅包含單一圖案,因此使用 Bio.motifs.read() 而不是 Bio.motifs.parse() 會比較容易。

例如

>>> from Bio import motifs
>>> with open("motifs/alignace.out") as handle:
...     for m in motifs.parse(handle, "AlignAce"):
...         print(m.consensus)
...
TCTACGATTGAG
CTGCACCTAGCTACGAGTGAG
GTGCCCTAAGCATACTAGGCG
GCCACTAGCAGAGCAGGGGGC
CGACTCAGAGGTT
CCACGCTAAGAGAAGTGCCGGAG
GCACGTCCCTGAGCA
GTCCATCGCAAAGCGTGGGGC
GAGATCAGAGGGCCG
TGGACGCGGGG
GACCAGAGCCTCGCATGGGGG
AGCGCGCGTG
GCCGGTTGCTGTTCATTAGG
ACCGACGGCAGCTAAAAGGG
GACGCCGGGGAT
CGACTCGCGCTTACAAGG

如果 strict 為 True(預設值),如果檔案內容不嚴格符合指定的檔案格式,剖析器將會引發 ValueError。

Bio.motifs.read(handle, fmt, strict=True)

使用指定的檔案格式從控制代碼讀取圖案。

這支援與 Bio.motifs.parse() 相同的格式,但僅適用於包含恰好一個圖案的檔案。例如,讀取 JASPAR 樣式的 pfm 檔案

>>> from Bio import motifs
>>> with open("motifs/SRF.pfm") as handle:
...     m = motifs.read(handle, "pfm")
>>> m.consensus
Seq('GCCCATATATGG')

或單一圖案的 MEME 檔案,

>>> from Bio import motifs
>>> with open("motifs/meme.psp_test.classic.zoops.xml") as handle:
...     m = motifs.read(handle, "meme")
>>> m.consensus
Seq('GCTTATGTAA')

如果控制代碼沒有記錄或有多個記錄,將會引發例外狀況

>>> from Bio import motifs
>>> with open("motifs/alignace.out") as handle:
...     motif = motifs.read(handle, "AlignAce")
Traceback (most recent call last):
    ...
ValueError: More than one motif found in handle

但是,如果您想要從包含多個圖案的檔案中取得第一個圖案,此函式會引發例外狀況(如上述範例所示)。請改為使用

>>> from Bio import motifs
>>> with open("motifs/alignace.out") as handle:
...     record = motifs.parse(handle, "alignace")
>>> motif = record[0]
>>> motif.consensus
Seq('TCTACGATTGAG')

如果您想要從控制代碼讀取多個記錄,請使用 Bio.motifs.parse(handle, fmt) 函式。

如果 strict 為 True(預設值),如果檔案內容不嚴格符合指定的檔案格式,剖析器將會引發 ValueError。

class Bio.motifs.Instances(instances=None, alphabet='ACGT')

基底:list

包含組成圖案的序列清單的類別。

__init__(instances=None, alphabet='ACGT')

初始化類別。

__str__()

傳回包含圖案序列的字串。

count()

計算位置中的核苷酸。

search(sequence)

在給定序列中找出圖案的位置。

這是一個產生器函式,會傳回在給定序列中找到的圖案實例位置。

reverse_complement()

計算序列的反向互補序列。

class Bio.motifs.Motif(alphabet='ACGT', alignment=None, counts=None, instances=None)

基底:object

代表序列圖案的類別。

__init__(alphabet='ACGT', alignment=None, counts=None, instances=None)

初始化類別。

property mask
property pseudocounts
property background
__getitem__(key)

傳回一個新的 Motif 物件,其包含在 key 中指定位置的資訊。

>>> from Bio import motifs
>>> motif = motifs.create(["AACGCCA", "ACCGCCC", "AACTCCG"])
>>> print(motif)
AACGCCA
ACCGCCC
AACTCCG
>>> print(motif[:-1])
AACGCC
ACCGCC
AACTCC
property pwm

計算並傳回此 motif 的位置權重矩陣 (position weight matrix)。

property pssm

計算並傳回此 motif 的位置特定計分矩陣 (position specific scoring matrix)。

property instances

傳回建構此 motif 的序列。

__str__(masked=False)

傳回 motif 的字串表示。

__len__()

傳回 motif 的長度。

請使用此方法(即呼叫 len(m))而不是直接參考 m.length。

reverse_complement()

傳回 motif 的反向互補序列,並以新的 motif 物件表示。

property consensus

傳回一致序列。

property anticonsensus

傳回從此 motif 產生最不可能的模式。

property degenerate_consensus

傳回簡併的一致序列。

遵循 D. R. Cavener 所改編的規則:「果蠅和脊椎動物中翻譯起始位點側翼一致序列的比較。」核酸研究 15(4): 1353-1361。(1987)。

TRANSFAC 使用相同的規則。

property relative_entropy

傳回一個陣列,其中包含 motif 每欄的相對熵值。

使用 Berkeley weblogo 服務下載並儲存 weblogo。

需要網路連線。

version 參數已棄用,並且無效。

來自 **kwds 的參數會直接傳遞給 weblogo 伺服器。

目前,此方法使用 WebLogo 3.3 版。 這些是傳遞給 WebLogo 3.3 的參數及其預設值; 請參閱他們的網站 http://weblogo.threeplusone.com 以取得更多資訊

'stack_width' : 'medium',
'stacks_per_line' : '40',
'alphabet' : 'alphabet_dna',
'ignore_lower_case' : True,
'unit_name' : "bits",
'first_index' : '1',
'logo_start' : '1',
'logo_end': str(self.length),
'composition' : "comp_auto",
'percentCG' : '',
'scale_width' : True,
'show_errorbars' : True,
'logo_title' : '',
'logo_label' : '',
'show_xaxis': True,
'xaxis_label': '',
'show_yaxis': True,
'yaxis_label': '',
'yaxis_scale': 'auto',
'yaxis_tic_interval' : '1.0',
'show_ends' : True,
'show_fineprint' : True,
'color_scheme': 'color_auto',
'symbols0': '',
'symbols1': '',
'symbols2': '',
'symbols3': '',
'symbols4': '',
'color0': '',
'color1': '',
'color2': '',
'color3': '',
'color4': '',
__format__(format_spec)

傳回指定格式的 Motif 字串表示。

目前支援的格式
  • clusterbuster: Cluster Buster 位置頻率矩陣格式

  • pfm : JASPAR 單個位置頻率矩陣

  • jaspar : JASPAR 多個位置頻率矩陣

  • transfac : 類似 TRANSFAC 的檔案

format(format_spec)

傳回指定格式的 Motif 字串表示。

目前支援的格式
  • clusterbuster: Cluster Buster 位置頻率矩陣格式

  • pfm : JASPAR 單個位置頻率矩陣

  • jaspar : JASPAR 多個位置頻率矩陣

  • transfac : 類似 TRANSFAC 的檔案

Bio.motifs.write(motifs, fmt)

傳回指定格式的 motifs 字串表示。

目前支援的格式(忽略大小寫)
  • clusterbuster: Cluster Buster 位置頻率矩陣格式

  • pfm : JASPAR 簡單單個位置頻率矩陣

  • jaspar : JASPAR 多個 PFM 格式

  • transfac : 類似 TRANSFAC 的檔案