# 4.2.Structure Motif

## 1) workflow

* 选择RNA structure motif discovery的输入序列的方法和RNA sequence motif discovery是完全一样的。
* RNA structure motif discovery的应用场景相对更狭窄一些，目前也没有一个像MEME suite那样具有统治地位的工具。所以我们这里举了好几个例子。
* 本教程中实际使用的是BEAM这个工具，其他的软件我们也列出了相应的文章和说明文档，请有兴趣的同学自行了解。
* BEAM的具体做法是先用RNA二级结构预测的软件(RNAfold, RNAstructure等)预测出RNA的二级结构，在按照这个工具自己的一套规则定义一套掺入了结构信息的一套新的字母表，把原来四个核苷酸的字符串编码成在这个新的字母表上同样长度的字符串。这样它就把structure motif discovery的问题转化成了sequence motif discovery的问题，而sequence motif discovery的问题是有很多well established的算法去解决的。
* 这个方法的好处在于简单，但是也有明显的局限性，因为把二维结构按人为定义的规则转化为少量字符组成的一维序列，总是会丢失很多信息。

![](https://4115668567-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LPVsf5VZbQ7h14X29qW%2F-Ll_k3bEdWyNMbJ7KL0f%2F-Ll_k4ieIPkTAB6fDSjf%2Fstructure_motif.pipeline.png?generation=1565075202311428\&alt=media)

## 2) running steps

### 运行环境

* 如果使用docker，本节仍使用我们在[sequence motif](https://book.ncrnalab.org/teaching/part-iii.-ngs-data-analyses/4.motif/sequence_motif)一节用到的docker容器

```bash
docker exec -it -u test motif /bin/bash
cd /home/test/motif/structure_motif/BEAM
```

* 如果在P集群上使用singularity：

```bash
source /WORK/Samples/singularity.sh
export SINGULARITY_BINDPATH='/data:/data'
singularity shell /data/images/bioinfo_motif_2.0.simg
source /home/test/.bashrc
#...
exit
```

* 如果想使用P集群，又不想用singularity
  * 可以使用`/data/2022-bioinfo-shared/softwares`提供的工具
  * 输入序列为`/data/2022-bioinfo-shared/data/motif-analysis/test.fa`

### 预测RNA二级结构

* 用RNAfold预测RNA二级结构。这里的".dbn"后缀意思是"dot-bracket notation"，用点(dot,".")表示单链区域，括号(bracket,"("和")")表示互补配对。
* ".dbn"文件每三行为一个record，三行分别是以">"开头的序列id，序列，和dot-bracket notation表示的二级结构。dot-bracket notation后面空一格还会输出计算出的自由能。

```bash
cd /home/test/motif/structure_motif/BEAM
RNAfold --noPS <test.fa > test.dbn
```

### 把预测出的结构编码到新的字母表上

`BearEncoder.new.jar`这个java程序实现了把二级结构编码到新字母表上的过程。这个程序比较僵化，如果.dbn文件每一个record的第三行除了二级结构之外还有别的内容，就没法正确解析，所以我们第一行代码先把自由能一项给舍弃:

```bash
cat test.dbn | awk 'NR%3==0{print $1;next;}{print $0}' > test.fixed.dbn
java -jar /home/test/software/BEAM/beam-2.0/BearEncoder.new.jar test.fixed.dbn test.bear
```

#### motif discovery

```
java -jar /home/test/software/beam-2.0/BEAM_release_1.5.1.jar -f test.bear -w 10 -W 40 -M 3
```

#### motif可视化

```bash
cd risultati/test/webLogoOut/motifs
weblogo -a 'ZAQXSWCDEVFRBGTNHY' -f test_m1_run1_wl.fa \
-o out.jpeg -F jpeg --composition="none" \
-C red ZAQ 'Stem' -C blue XSW 'Loop' -C forestgreen CDE 'InternalLoop' \
-C orange VFR 'StemBranch' -C DarkOrange B 'Bulge' \
-C lime G 'BulgeBranch' -C purple T 'Branching' \
-C limegreen NHY 'InternalLoopBranch'
```

> example output ![](https://tva1.sinaimg.cn/large/006y8mN6ly1g85thyjml0j30ok08sgo9.jpg)

## 3) other tools

* **RNApromo**
* software: [RNApromo](https://genie.weizmann.ac.il/pubs/rnamotifs08/64bit_exe_rnamotifs08_motif_finder.tar.gz)
* publication: 2008,*PNAS*,[Computational prediction of RNA structural motifs involved in posttranscriptional regulatory processes](https://www.pnas.org/doi/10.1073/pnas.0803169105)
* **GraphProt**
* software: <https://github.com/dmaticzka/GraphProt>
* publication: 2014, *Genome Biology*,[GraphProt: modeling binding preferences of RNA-binding proteins](https://genomebiology.biomedcentral.com/articles/10.1186/gb-2014-15-1-r17)
* **RNAcontext**
* software: [RNAcontext](http://www.cs.toronto.edu/~hilal/rnacontext/)
* publication: 2010, *Plos Computational Biology*,[RNAcontext: A New Method for Learning the Sequence and Structure Binding Preferences of RNA-Binding Proteins](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1000832)

## 4) Homework

1. 阅读2014,*NAR*,[A novel approach to represent and compare RNA secondary structures](https://pubmed.ncbi.nlm.nih.gov/24753415/)这篇文章，简要描述BEAR encoder这个工具是怎样把二维结构编码到一维序列上的。
2. RNApromo这个工具是2008,*PNAS*,[Computational prediction of RNA structural motifs involved in posttranscriptional regulatory processes](https://www.pnas.org/doi/10.1073/pnas.0803169105)这篇文章发表的。阅读文章，简要回答RNApromo和meme的区别在什么的地方?
