-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.json
More file actions
477 lines (477 loc) · 137 KB
/
Copy pathindex.json
File metadata and controls
477 lines (477 loc) · 137 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
[
{
"uri": "/biology/",
"title": "Biology",
"tags": ["bioinfomatics"],
"description": "A collection of instructions and manuals for bioinformatics analysis, especially for RNAseq, CLIPseq, scRNAseq and so on.",
"content": "A collection for bioinformatics analysis\n RNAseq\n CLIPseq\n scRNAseq\n \u0026hellip;\n "
},
{
"uri": "/linux/",
"title": "Linux",
"tags": ["bioinfomatics"],
"description": "A collection of instructions and manuals for bioinformatics analysis, especially for RNAseq, CLIPseq, scRNAseq and so on.",
"content": "A collection for bioinformatics analysis\n RNAseq\n CLIPseq\n scRNAseq\n \u0026hellip;\n VirtualBox network Host and Virtualbox connection\n Git examples Useful instructions for git learning\n Git usage Useful instructions for git learning\n SSH connect to VirtualBox Connect to VirtualBox from host\n SSH connection closed Failed to connect remote through SSH\n Git submodule Failed to connect remote through SSH\n "
},
{
"uri": "/webpage_001/",
"title": "webpage 001",
"tags": ["bioinfomatics"],
"description": "A collection of webpages on website 001",
"content": "A collection for bioinformatics analysis\n Using Ensembl Genomes Perl API \n 安装Ubuntu 14.04 之后需要做的几件事 \n EOB-001: Synthetic RNA silencing in bacteria \n ggplot2 and parallel \n Manage this blog How to manage this blog?\n SSh login without password [2 steps] \n EOB-002: Toehold switches De-Novo-Designed Regulators of Gene Expression \n 超几何分析和GO富集分析 \n RNA-Seq分析工具的配置 \n 编辑Linux的$PATH \n 使用R和Bioconductor进行RNASeq差异表达分析 \n Github Markdown常用语法 \n 在Jekyll blog中添加搜索框 \n 国内可选择的开源软件镜像源 \n 通过Python批量下载文件 \n 通过R语言下载文档 \n 使用BioPython将GenBank转换为Fasta格式 \n MobaXterm: Permissions 0660 for \u0026#39;id_rsa\u0026#39; are too open \n 使用SSH管理Git \n 管理多个Github账号 \n jekyll\u0026#43;Github \n 创建Github blogs \n 在Github上管理个人blog \n R语言读取压缩文档 \n RCurl的问题 \n "
},
{
"uri": "/linux/virtualbox_network/",
"title": "VirtualBox network",
"tags": ["VirtualBox", "network"],
"description": "Host and Virtualbox connection",
"content": " [转] virtualbox-net Source: https://www.jianshu.com/p/0537b056790b\n 作者:lvvl 链接:https://www.jianshu.com/p/0537b056790b 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。\n参考资料:http://blog.csdn.net/yxc135/article/details/8458939\nhttp://www.centoscn.com/CentOS/config/2015/0311/4857.html\nhttp://favoorr.github.io/mac-use-virtualbox-config-network/\n如果出现主机无法ping通虚拟机的情况,请首先确认虚拟机防火墙已关闭。\n1. VirtualBox网络连接方式概要 VirtualBox图形界面下有四种网络接入方式,它们分别是: 1. NAT 网络地址转换模式(NAT,Network Address Translation) 2. Bridged Adapter 桥接模式 3. Internal 内部网络模式 4. Host-only Adapter 主机模式 而在CommandLine下则有八种方式,除上面列出的四种外还有下列四种: 1. UDP Tunnel networking 2. VDE networking 3. Limiting bandwidth for network I/O 4. Improving network performance VirturalBox为每个虚拟机提供八种虚拟的PCI 网卡,对于每一种虚拟网卡,你可以从下列六种网络硬件中任选一种: AMD PCNet PCI II (Am79C970A) AMD PCNet FAST III (Am79C973, the default) Intel PRO/1000 MT Desktop (82540EM)(Windows Vista and later versions) Intel PRO/1000 T Server (82543GC)(Windows XP) Intel PRO/1000 MT Server (82545EM)(OVF imports from other platforms) Paravirtualized network adapter (virtio-net) 2. NAT模式 特点: 虚拟机与主机关系: 只能单向访问,虚拟机可以通过网络访问到主机,主机无法通过网络访问到虚拟机。 虚拟机可以ping通主机(此时ping虚拟机的网关,即是ping主机) 虚拟机与网络中其他主机的关系: 只能单向访问,虚拟机可以访问到网络中其他主机,其他主机不能通过网络访问到虚拟机。 虚拟机与虚拟机之间的关系: 相互不能访问,虚拟机与虚拟机各自完全独立,相互间无法通过网络访问彼此。 应用场景: 虚拟机只要求可以上网,无其它特殊要求,满足最一般需求 配置方法: 连接方式 选择 网络地址转换(NAT) 高级-控制芯片 选择 PCnet-FAST III 高级-混杂模式 拒绝 高级-接入网线 √ (虚拟机ip自动获取) ip样式: ip 10.0.2.15 网关 10.0.2.2 DNS 10.0.2.3 注意此处的网关在不同虚拟机中可能是同一个值,但是这归属于不同的NAT Engine,因此实际上各个虚拟机用的不是同一个网关 原理: 虚拟机的请求传递给NAT Engine,由它来利用主机进行对外的网络访问,返回的数据包再由NAT Engine给虚拟机。 3. Bridged Adapter模式(桥接模式) 注意:注意如果主机是直接用拨号上网的,不是通过路由,那么此方式不可用。 只有主机能上网,虚拟机才能上网 特点: 虚拟机与主机关系: 可以相互访问,因为虚拟机在真实网络段中有独立IP,主机与虚拟机处于同一网络段中,彼此可以通过各自IP相互访问。 虚拟机于网络中其他主机关系:以相互访问,同样因为虚拟机在真实网络段中有独立IP, 虚拟机与所有网络其他主机处于同一网络段中,彼此可以通过各自IP相互访问。 虚拟机于虚拟机关系: 可以相互访问,原因同上。 应用场景: 虚拟机要求可以上网,且虚拟机完全模拟一台实体机 配置方法: 连接方式 选择 桥接网卡 界面名称 选择 (如果你的笔记本有无线网卡和有线网卡,需要根据现在的上网方式对应选择) 高级-控制芯片 选择 PCnet-FAST III 高级-混杂模式 拒绝 高级-接入网线 √ (虚拟机ip自动获取) ip样式: ip 与本机ip在同一网段内 网关 与本机网关相同 原理: 通过主机网卡,架设一条桥,直接连入到网络中。它使得虚拟机能被分配到一个网络中独立的IP,所有网络功能完全和 在网络中的真实机器一样。 (虚拟机是通过主机所在网络中的DHCP服务得到ip地址的,所以按理来说,两者是完全独立的,但事实却是虚拟机是没 有独立硬件的,它还是要依靠主机的网卡,因此,主机要断开网络,虚拟机也就没法拿到ip了,所以呵呵~~所有特点全 消失咯) 缺点: 1. 会获取跟宿主机一个段的ip地址,比如宿主机ip 192.168.1.101 ,虚拟机会获取192.168.1.103的ip, 但是公司的ip应该都是严格管理的,所以这种方法不好维护,如果主机所在局域网中得其他机器不需要使用虚拟机上的功能,最好使用Host-Only建立独立局域网 2. 如果宿主机上通过PPPOE拨号上网的,虚拟机也无法使用桥接 最佳方案 网卡一 NAT 方式和宿主机共享网络,虚拟机可以联网,方便下载安装各种软件 网卡二 与主机建立独立局域网,和路由上其他的机器分离,(现在看这种方式太对了,我后来把mac带到公司用了,因为要演示hadoop集群计算,而公司的ip是需要向网管申请的) 每一台虚拟机的ip固定,因为hadoop集群要设置master,ip要固定下来 4. Host-only Adapter模式 主机模式,这是一种比较复杂的模式,需要有比较扎实的网络基础知识才能玩转。可以说前面几种模式所实现的功能,在这种模式下,通过虚拟机及网卡的设置都可以被实现。 我们可以理解为Vbox在主机中模拟出一张专供虚拟机使用的网卡,所有虚拟机都是连接到该网卡上的,我们可以通过设置这张网卡来实现上网及其他很多功能,比如(网卡共享. 网卡桥接等)。 特点: 虚拟机与主机关系 :默认不能相互访问,双方不属于同一IP段,host-only网卡默认IP段为192.168.56.X 子网掩码为255.255.255.0,后面的虚拟机被分配到的也都是这个网段。通过网卡共享. 网卡桥接等,可以实现虚拟机于主机相互访问。 虚拟机访问主机: 用的是主机的VirtualBox Host-Only Network网卡的IP:192.168.56.1 ,不管主机“本地连接”有无红叉,永远通。 (注意虚拟机与主机通信是通过主机的名为VirtualBox Host-Only Network的网卡,因此ip是该网卡ip 192.168.56.1,而不是你现在正在上网所用的ip) 主机访问虚拟机,用是的虚拟机的网卡的IP: 192.168.56.101 ,不管主机“本地连接”有无红叉,永远通。 主机可以访问主机下的所有虚拟机,和192.168.56.1(是VirtualBox Host-Only Network网卡[在主机中模拟出的网卡,不是虚拟机中虚拟的网卡]的IP) 虚拟机与网络主机关系 :默认不能相互访问,也不能上网,原因同上,通过设置,可以实现相互访问。 虚拟机与虚拟机关系 :默认可以相互访问,都是同处于一个网段。 应用场景: 在主机无法上网的情况下(主机可以上网的情况下可以用host-only,也可以用桥接),需要搭建一个模拟局域网,所有机器可以互访 配置方法: 连接方式 选择 仅主机(Host-Only)适配器 界面名称 选择 VirtualBox Host-Only Ethernet Adapter 如果无法设置界面名称,可以:In VirtualBox \u0026gt; Preferences \u0026gt; Network, set up a host-only network 高级-控制芯片 选择 PCnet-FAST III 高级-混杂模式 拒绝 高级-接入网线 √ (虚拟机ip自动获取,也可以自己进行配置,网关配置为主机中虚拟网卡的地址【默认为192.168.56.1】,ip配置为与虚拟网卡地址同网段地址) ip样式: ip 与本机VirtualBox Host-Only Network的网卡ip在同一网段内(默认192.168.56.*) 网关 本机VirtualBox Host-Only Network的网卡ip(默认192.168.56.1) 原理: 通过VirtualBox Host-Only Network网卡进行通信,虚拟机以此ip作为网关,因此模拟了一个本机与各个虚拟机的局域网,如名称所指, 应该是无法上网的(但是有人说可以通过对VirtualBox Host-Only Network网卡进行桥接等操作使虚拟机可以上网,但如此就不如直接 采用桥接来的容易了,而且,呵呵,我没试成功,有的人也说不可以,因为主机不提供路由服务,我也不好乱说到底行不行,你自己试吧~~) 5. Internal模式(内网模式)虚拟机与外网完全断开,只实现虚拟机于虚拟机之间的内部网络模式。 特点: 虚拟机与主机关系: 不能相互访问,彼此不属于同一个网络,无法相互访问。 虚拟机与网络中其他主机关系: 不能相互访问,理由同上。 虚拟机与虚拟机关系: 可以相互访问,前提是在设置网络时,两台虚拟机设置同一网络名称。 应用场景: 让各台虚拟机处于隔离的局域网内,只让它们相互通信,与外界(包括主机)隔绝 配置方法: 连接方式 选择 内部网络 界面名称 选择 intnet(可以重新命名,所有放在同一局域网内的虚拟机此名称相同) 高级-控制芯片 选择 PCnet-FAST III 高级-混杂模式 拒绝 高级-接入网线 √ (虚拟机ip:对于XP自动获取ip即可,但对于linux,必须手动配置ip和子网掩码,手动配置时需保证各个虚拟机ip在同一网段) 如果是centos7,可依照如下操作,其它linux大同小异 centos7中手动添加ip和子网掩码的方法: ip addr 查看虚拟机上有哪些网卡 vi /etc/sysconfig/network-scripts/ifcfg-xxx xxx为具体的网卡名 修改BOOTPROTO=“none”或者“static”,这样设置成手动,默认是“dhcp“是动态获取ip, 最后增加IPADDR=”192.168.1.1“,NETMASK=”255.255.255.0“ :wq 退出保存 service network restart 重启服务,生效 以同样的方法,设置另1台centos7虚拟机 ip样式: ip 192.168.1.1 子网掩码 255.255.255.0 默认网关 无 或者如下 ip 169.254.147.9 子网掩码 255.255.0.0 默认网关 无 原理: 各个虚拟机利用VirtualBox内置的DHCP服务器得到ip,数据包传递不经过主机所在网络,因此安全性高,防止外部抓包~ 6. NAT模式+端口映射 将虚拟机某端口映射到主机某端口,可以使主机和外部机器访问虚拟机提供的服务哦~~ 命令如下: (在命令行模式下,先到VirtualBox的安装目录下面,否则找不到命令) vboxmanage setextradata \u0026lt;VM name\u0026gt; \u0026quot;VBoxInternal/Devices/pcnet/0/LUN#0/Config/\u0026lt;rule name\u0026gt;/Protocol\u0026quot; TCP vboxmanage setextradata \u0026lt;VM name\u0026gt; \u0026quot;VBoxInternal/Devices/pcnet/0/LUN#0/Config/\u0026lt;rule name\u0026gt;/GuestPort\u0026quot; 80 vboxmanage setextradata \u0026lt;VM name\u0026gt; \u0026quot;VBoxInternal/Devices/pcnet/0/LUN#0/Config/\u0026lt;rule name\u0026gt;/HostPort\u0026quot; 8000 7. 以下配置centos虚拟机里面能上外网,而主机与centos虚拟机也能连通。 1. 关掉虚拟机 -》在VBX主界面中,选中具体的centos7虚拟机,点击设置, -》网络,网卡1中,选择 NAT 网络,网卡2中选择Host-Only -》启动centos虚拟机, 就可以利用2张网卡,通过网卡1上网,通过网卡2同主机通讯, 同时,在些宿主机下的所有虚拟机默认都通过网卡2中指定的VirtualBox Host-Only Network网卡的ip,192.168.56.1,255.255.255.0,组成了192.168.56.x的内部局域网 2. 具体也可参考收下办法 最好的办法就是使用两块网卡,nat(虚拟机访问互联网,使用10.0.2.x段)和host-only(虚拟机和主机互相通信,使用192.168.56.x段),而virtualbox配置的网络的地方是:打开主机界,按Ctrl+G,然后network,就可以启用vboxnet0了。 打开虚拟机的配置,在networking里面添加第二块网卡为host-only。 接下来在virtualbox中安装centos。 ping baidu,不通,需要在/etc/sysconfig/network-scripts/ifcfg-eth0中将ONBOOT=\u0026quot;no\u0026quot;改为yes,再添加BOOTPROTO=\u0026quot;dhcp\u0026quot;,保存,退出,重启。再ping 百度,通了。此时可以用命令route看一下,记录一下路由,如果后面出现不能上网,再用route看一下什么异常 再ping主机上的虚拟网卡192.168.56.1,发现也没有问题,是通的,但是主机访问不了虚拟机,这就头痛了,这个时候就要用到我们的第二块网卡host-only来完成主机对虚拟机的访问。操作如下: 在/etc/sysconfig/network-scripts/下面看有没有ifcfg-eth1文件,如果没有,将ifcfg-eth0复制一份,改名为ifcfg-eth1,然后将ONBOOT值改为yes,这里我设置成静态IP,配置如下: BOOTPROTO=static #获取IP的方式是dhcp或bootp自动获取,static是固定IP,none是手动 IPADDR=192.168.56.2 NETMASK=255.255.255.0 注意不能设置GATEWAY,原因: linux双网卡默认路由问题 在安装第二块网卡后出现无法上网问题,使用route发现是默认路由出现问题,经过多 发查证,才晓得原来linux在加载网卡配置文件的时候是先加载eth0,再加载eht1的,这样,如果eth1设置了gateway项,则会覆盖掉 eth0中的gateway设置,因此解决方法就是删除eth1的gateway设置 ======================== 我使用的是第二种方式,Bridged Adapter桥接模式 修改centos7的网卡IP地址与主机是同一网段 $\u0026gt;cd /etc/sysconfig/network-scripts $\u0026gt;vi ifcfg-enp0s3 修改 BOOTPROTO=NONE IPADDR0=192.168.1.10 与主机一个网段 PREFIX0=24 :wq 保存退出 重启网络 $\u0026gt;service network restart "
},
{
"uri": "/linux/git_learning/",
"title": "Git examples",
"tags": ["bioinfomatics", "git"],
"description": "Useful instructions for git learning",
"content": "Instructions Requirement:\nYou will receive the url_of_repo after you submit \u0026lt;name_of_repo\u0026gt; and id_rsa.pub to wangm08@hotmail.com.\n\ninput: \u0026lt;name_of_repo\u0026gt;, \u0026lt;id_rsa.pub\u0026gt; output: \u0026lt;url_of_repo\u0026gt; rules of \u0026lt;name_of_repo\u0026gt;\n only accept letters, numbers, - and _ eg: project-001, demo_clip generate \u0026lt;id_rsa.pub\u0026gt;\n # check your public key ~/.ssh/id_rsa.pub # if not exists, create one $ ssh-keygen -t rsa # copy id_rsa.pub to remote server $ ssh-copy-id -i path/id_rsa.pub git@ip_address Getting started Option 1. You have scripts on your local machine suppose\n you have an empty remote repo: git@\u0026lt;ip_address\u0026gt;:/data/git/demo_yy.git you have files in demo_yy files in you local PC $ cd demo_yy $ ls file1 file2 file3 file4 $ git status fatal: Not a git repository (or any of the parent directories): .git # it means, this is not a git repo directory # So, let us do something within the directory # initate git repo $ git init Initialized empty Git repository in /home/mobaxterm/work/demo_yy/.git/ $ git status On branch master Initial commit Untracked files: (use \u0026quot;git add \u0026lt;file\u0026gt;...\u0026quot; to include in what will be committed) file1 file2 file3 file4 nothing added to commit but untracked files present (use \u0026quot;git add\u0026quot; to track) # now add all files to git repo $ git add --all $ git commit -a -m 'init repo' [master (root-commit) 61d80dd] init repo 4 files changed, 21 insertions(+) create mode 100644 file1 create mode 100644 file2 create mode 100644 file3 create mode 100644 file4 # now check working area again $ git status On branch master nothing to commit, working directory clean # checkout remote server $ git remote -v # add remote repo $ git remote add origin git@\u0026lt;ip_address\u0026gt;:/data/git/demo_yy.git # checkout remote server again $ git remote -v origin git@\u0026lt;ip_address\u0026gt;:/data/git/demo_yy.git (fetch) origin git@\u0026lt;ip_address\u0026gt;:/data/git/demo_yy.git (push) # push your local files to remote server # for the first time, use -u, link local master to remote master $ git push -u origin master Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 841 bytes | 0 bytes/s, done. Total 6 (delta 0), reused 0 (delta 0) To git@lib232.ibp.ac.cn:/data/git/demo_yy.git * [new branch] master -\u0026gt; master Branch master set up to track remote branch master from origin. # checkout status again $ git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean Option 2: start working with empty repo # clone remote repo to your local computer $ git clone git@\u0026lt;ip_address\u0026gt;:/data/git/demo_yy.git $ cd demo_yy # now, you can enjoy coding $ git add file $ git commit -m 'modify file' file $ git push origin master "
},
{
"uri": "/linux/git_usage/",
"title": "Git usage",
"tags": ["bioinfomatics", "git"],
"description": "Useful instructions for git learning",
"content": " source https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375234012342f90be1fc4d81446c967bbdc19e7c03d3000\n 多人协作的工作模式通常是这样:\n 首先,可以试图用git push origin branch-name推送自己的修改; 如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并; 如果合并有冲突,则解决冲突,并在本地提交; 没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功! \n如果git pull提示“no tracking information”,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream branch-name origin/branch-name。这就是多人协作的工作模式,一旦熟悉了,就非常简单。\n标签\n 命令git tag \u0026lt;name\u0026gt;用于新建一个标签,默认为HEAD,也可以指定一个commit id; git tag -a \u0026lt;tagname\u0026gt; -m \u0026quot;blablabla...\u0026quot;可以指定标签信息; git tag -s \u0026lt;tagname\u0026gt; -m \u0026quot;blablabla...\u0026quot;可以用PGP签名标签; 命令git tag可以查看所有标签。\n 命令git push origin \u0026lt;tagname\u0026gt;可以推送一个本地标签;\n 命令git push origin --tags可以推送全部未推送过的本地标签;\n 命令git tag -d \u0026lt;tagname\u0026gt;可以删除一个本地标签;\n 命令git push origin :refs/tags/\u0026lt;tagname\u0026gt;可以删除一个远程标签。\n Branches $ git branch # checkout branch $ git branch \u0026lt;name\u0026gt; # create branch $ git checkout \u0026lt;name\u0026gt; # switch branches $ git checkout -b \u0026lt;name\u0026gt; # switch branch and create $ git merge --no-ff \u0026lt;name\u0026gt; # merge branch to current $ git branch -d \u0026lt;name\u0026gt; # delete branch Fix bug and branch Note: Save your work to stash\nsave: git stash, take back: git stash pop\n save work / changes to stash # on dev branch open / create a issue-1 branch, and fix the bugs# on master branch merge bug branch to master branch, and delete issue-1 branch go back to dev branch take your work from stash $ git stash # save changes to stash $ git status # checkout working directory $ git checkout master $ git checkout -b issue-1 ... # make changes, fix bugs $ git add file $ git commit -m 'fix bug 1' $ git checkout master # go back to master $ git merge --no-ff -m \u0026quot;merged bug fix 1\u0026quot; issue-1 $ git checkout dev # go back to your previous working directory $ git status #(nothing to commit) # recover from stash $ git stash list # show your stash work $ git stash pop # recover and delete your stashed work ... # continue working on your project Feature branch Develop a new function named falcon, and you do not want to disorder the master branch.\n# on dev branch $ git checkout -b feature-falcon ... # make changes $ git add falcon.sh $ git commit -m 'add feature falcon' $ git checkout dev # option-1. go through $ git merge --no-ff -m 'add feature falcon, merge' feature-falcon $ git branch -d feature-falcon # find, done! # option-2. need to drop new feature, before merge $ git branch -d feature-falcon #!!!! error, feature-falcon branch is not merged yet. # force to delete the branch $ git branch -D feature-falcon Multiple users Note suppose two users, Amy and Baker, working on the same project.\nAmy: maintain the project\n$ git branch * master dev $ git remote -v origin https://github.com/bakerwm/wm.git (fetch) origin https://github.com/bakerwm/wm.git (push) # push master to remote master $ git push origin master # push dev to remote dev $ git checkout dev $ git branch * dev master $ git push origin dev Baker join this project\n$ git clone https://github.com/bakerwm/wm.git $ cd wm $ git branch * master # only master branch were pulled, # Baker need the dev branch $ git checkout -b dev origin/dev # Baker can work on dev branch, now $ git branch * dev master ... #changes $ git add file $ git commit -m 'update, baker' $ git push origin dev # push dev to dev Amy also work on the same file, and failed to push\n$ git branch * dev master ... # changes $ git add file $ git commit -m 'update, amy' $ git push origin dev ... ! [rejected] dev -\u0026gt; dev (non-fast-forward) ... # fix the reject # pull the latest changes, fix the reject, merge, push $ git pull origin dev ... CONFLICT (content): Merge conflict in file Automatic merge failed; fix conflicts and then commit the result. # manually fix the conflict $ git add file $ git commit -m \u0026quot;merge \u0026amp; fix file\u0026quot; $ git push origin dev Baker pull data, working on the same pace\n$ git branch * dev master $ git pull origin dev Move between versions 1. Show the commit_ids git $ git log --pretty=oneline 2. Go back to last version $ git reset --hard HEAD^ last 100 version, HEAD~100\nDiscard changes 1. changes are not git add yet and you want to go back to last git commit or git add\n$ git checkout -- file # # -- is required 2. changes have already been git add, but not git commit yet use the command git reset HEAD file can take the changes from stage to your work area.\n$ git rest HEAD file # move changes out from stage $ git checkout -- file # discard the changes 3. changes have been git commit. it means all the changes have been moved to git version. you can go back to last version by git reset --hard HEAD^\n$ git reset --hard HEAD^ # or if you want go back to specific version $ git reset --hard 3628164 Check out changes Delete files $ git rm file # recover the miss-delete file $ git checkout -- file "
},
{
"uri": "/linux/ssh_connect_to_virtualbox/",
"title": "SSH connect to VirtualBox",
"tags": ["virtualbox", "ssh"],
"description": "Connect to VirtualBox from host",
"content": " Q1: SSH access to VirutalBox\nA: use NAT\n \n Start VirtualBox, choose one of the Linux OS. eg: Ubuntu 16.04\n Go to the following setting:\n Setting Network Advanced Port Forwarding Click Add button on the right Finish the new line Name - anything you want, eg. ssh Protocol - suggest Host IP - \u0026lt;\u0026gt; leave it blank Host Port - change a port number Guest IP - \u0026lt;\u0026gt; leave it blank Guest SSH - default port for SSH\n Click OK\n Open the console on you host machine, eg: Putty\n $ ssh -p 2222 ming@127.0.0.1 Note\nTry to restart your virtualBox, if it does not work.\n"
},
{
"uri": "/linux/ssh_connection_closed_by_remote/",
"title": "SSH connection closed",
"tags": ["SSH", "remote", "failed", "QA"],
"description": "Failed to connect remote through SSH",
"content": " Source: https://linux.cn/article-4226-1.html\n Status: SSH: Connection closed by \n Q1: When I tried to connect to a remote server through SSH. It failed and pop the following message on my console \u0026ldquo;Connection close by 127.0.0.1\u0026rdquo;? A: Something goes wrong with your SSH key on the remote server reinstall SSH Host keys by: sudo dpkg-reconfigure openssh-server\n Step 1. Checkout the log on server /var/log/auth.log $ tail -n 20 /var/log/auth.log Dec 25 12:35:57 ming sshd[1891]: error: key_load_private: invalid format Dec 25 12:35:57 ming sshd[1891]: error: key_load_public: invalid format Dec 25 12:35:57 ming sshd[1891]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key Dec 25 12:35:57 ming sshd[1891]: error: key_load_private: invalid format Dec 25 12:35:57 ming sshd[1891]: error: key_load_public: invalid format Dec 25 12:35:57 ming sshd[1891]: error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key Dec 25 12:35:57 ming sshd[1891]: error: key_load_private: invalid format Dec 25 12:35:57 ming sshd[1891]: error: key_load_public: invalid format Dec 25 12:35:57 ming sshd[1891]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key Dec 25 12:35:57 ming sshd[1891]: fatal: No supported key exchange algorithms [preauth] Note: sshd could not load SSH host keys, somthing goes wrong with OpenSSH.\nStep 2. Checkout SSH host keys $ ls -al /etc/ssh/ssh*key total 568 drwxr-xr-x 2 root root 4096 12月 22 08:28 ./ drwxr-xr-x 123 root root 12288 12月 25 11:19 ../ -rw-r--r-- 1 root root 553122 9月 1 18:17 moduli -rw-r--r-- 1 root root 1723 9月 1 18:17 ssh_config -rw-r--r-- 1 root root 0 9月 1 18:17 sshd_config -rw------- 1 root root 0 12月 22 08:28 ssh_host_ecdsa_key -rw-r--r-- 1 root root 0 12月 22 08:28 ssh_host_ecdsa_key.pub -rw------- 1 root root 0 12月 22 08:28 ssh_host_ed25519_key -rw-r--r-- 1 root root 0 12月 22 08:28 ssh_host_ed25519_key.pub -rw------- 1 root root 0 12月 22 08:28 ssh_host_rsa_key -rw-r--r-- 1 root root 0 12月 22 08:28 ssh_host_rsa_key.pub -rw-r--r-- 1 root root 338 12月 22 08:28 ssh_import_id Step 3. Re-create SSH host keys # remove the old keys $ sudo rm -r /etc/ssh/ssh*key $ sudo dpkg-reconfigure openssh-server ming@ming:/etc/ssh$ sudo dpkg-reconfigure openssh-server Creating SSH2 RSA key; this may take some time ... 2048 SHA256:VN6V295MlILRBpLOXfY9WD1QEbfjKy5u1IgyXr6eDRY root@ming (RSA) Creating SSH2 ECDSA key; this may take some time ... 256 SHA256:W6g1fi+iudRVn1v2lDXO0NfQIE2C7U4vXz3sQDp/nx0 root@ming (ECDddddddddSA) Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:u0oE7euuS8V8R+fK7WebZvXERPwOb9Ho49fUlDQdxvE root@ming (ED25519) $ ls -al /etc/ssh/ssh*key total 592 drwxr-xr-x 2 root root 4096 12月 25 12:39 ./ drwxr-xr-x 123 root root 12288 12月 25 11:19 ../ -rw-r--r-- 1 root root 553122 9月 1 18:17 moduli -rw-r--r-- 1 root root 1723 9月 1 18:17 ssh_config -rw-r--r-- 1 root root 0 9月 1 18:17 sshd_config -rw------- 1 root root 227 12月 25 12:39 ssh_host_ecdsa_key -rw-r--r-- 1 root root 171 12月 25 12:39 ssh_host_ecdsa_key.pub -rw------- 1 root root 399 12月 25 12:39 ssh_host_ed25519_key -rw-r--r-- 1 root root 91 12月 25 12:39 ssh_host_ed25519_key.pub -rw------- 1 root root 1675 12月 25 12:39 ssh_host_rsa_key -rw-r--r-- 1 root root 391 12月 25 12:39 ssh_host_rsa_key.pub -rw-r--r-- 1 root root 338 12月 22 08:28 ssh_import_id # restart sshd $ sudo service sshd restart Step 4. SSH to remote server again # from your local machine, console $ ssh user@ip_address "
},
{
"uri": "/linux/git_submodule/",
"title": "Git submodule",
"tags": ["SSH", "remote", "failed", "QA"],
"description": "Failed to connect remote through SSH",
"content": " Source: https://www.jianshu.com/p/ca2862e449fa\n \nIn brief # Add submodule $ git submodule add \u0026lt;repo.git\u0026gt; \u0026lt;path\u0026gt; # on another machine $ git clone \u0026lt;repo.git\u0026gt; $ git submodule update --init --recursive # update URL # 1. change URL of submodule in .gitsubmodules # 2. change URL of submodule in .git/config # 3. run: git submodule sync # remove submodule # 1. remove submodule record in .gitmodules # 2. remove submodule record in .git/config # 3. run: git rm --cached \u0026lt;submodule_path\u0026gt; # do not add \u0026quot;/\u0026quot; at the end of path 在软件开发过程中,通常我们会遇到有一些通用的部分希望抽取出来做成一个公共库的情况,比如安卓和IOS都通用的H5页面。而公共代码库的版本管理是个麻烦的事情。幸运的是,万能的Git有个叫子模组(git submodule)的命令完美地帮我们解决了这个问题。\n添加子模块 为当前工程添加submodule,命令如下:\ngit submodule add 仓库地址 路径\n其中,仓库地址是指子模块仓库地址,路径指将子模块放置在当前工程下的路径。\n注意:路径不能以 / 结尾(会造成修改不生效)、不能是现有工程已有的目录(不能順利 Clone)\n命令执行完成,会在当前工程根路径下生成一个名为“.gitmodules”的文件,其中记录了子模块的信息。添加完成以后,再将子模块所在的文件夹添加到工程中即可。\n下载的工程带有submodule 当使用git clone下来的工程中带有submodule时,初始的时候,submodule的内容并不会自动下载下来的,此时,只需执行如下命令:\ngit submodule init\ngit submodule update\n或者是执行以下命令(该命令效果等同于上面两个命令):\ngit submodule update \u0026ndash;init \u0026ndash;recursive\n即可将子模块内容下载下来后工程才不会缺少相应的文件。\n更新submodule的URL 1.更新.gitsubmodule中对应submodule的条目URL\n2.更新 .git/config 中对应submodule的条目的URL\n3.执行 git submodule sync\n删除子模块\n 使用vim编辑.gitmodules(vim .gitmodule), 删除对应要删除的submodule的行.\n 使用vim编辑.git/config,删除有对应要删除的submodule的行.\n 3.执行 git rm \u0026ndash;cached {submodule_path}。注意,路径不要加后面的“/”。例如:你的submodule保存在 supports/libs/websocket/ 目录。执行命令为: git rm \u0026ndash;cached supports/libs/websocket\n"
},
{
"uri": "/license/",
"title": "License",
"tags": ["License"],
"description": "License",
"content": "License\n The MIT License (MIT)\nCopyright \u0026copy; 2017 YangYu Lab, Key Laboratory of RNA, Institute of Biophysics, Chinese Academy of Sciences, Beijing, China\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u0026ldquo;Software\u0026rdquo;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \u0026ldquo;AS IS\u0026rdquo;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n "
},
{
"uri": "/",
"title": "Bio M",
"tags": [],
"description": "Biology and bioinformatics",
"content": " HOME Something about biology and bioinformatics.\n"
},
{
"uri": "/webpage_001/2015-01-30-using-ensembl-genomes-perl-api/",
"title": "Using Ensembl Genomes Perl API",
"tags": ["Ensembl", "API"],
"description": "",
"content": " Using EnsEMBL Genomes Perl API\nURL: [http://ensemblgenomes.org/info/access/eg_api]()\nUp to date: 2015-01-30, using Ensembl version v78.\nNotes Before you read the following instructions, you are supposed to know about the Ensembl Perl API. The follow 2 links are very helpful.\n Ensembl Perl API tutorials: here Ensembl, Filmed API Workshop: here\n Begin Things to know about Ensembl Genomes: (different from Ensembl Core)\n 1. Load more than 250 genomes in a single database for bacteria. Whilst all Ensembl Genomes database can be accessed using the standard Ensembl API, the way that up to 250 genomes are loaded into a single database presents some barriers to easy access for Ensembl Bacteria. To overcome this, a simple API, ensemblgenomes-api is provided to make accessing the data easier.\n\u0026ndash;Ensembl genomes\n 2. Using different central object: Bio::EnsEMBL::LookUp This provides an interface for loading the EnsEMBL Registry with the large numbers of genomes from multiple databases, and allows individual DBAdaptor objects to be retrieved for genomes that match criteria including ENA accession (or other seq_region name), Genome Assembly accession, species name and taxonomy ID.\nOnce Bio::EnsEMBL::DBAdaptor objects have been returned, they can be used as for any Ensembl species. Alternatively, the now-loaded Bio::EnsEMBL::Registry object can be accessed directly.\n\u0026ndash;Ensembl genomes\n Installing the API First, the standard Ensembl API and its dependencies should be installed as described here. This should be the same version of Ensembl that is used by Ensembl Bacteria.\nSecondly, the ensemblgenomes-api API should be installed from the GitHub repository. You will need to add the modules directory from this package to your PERL5LIB. You may also need to install the CPAN package JSON - please consult your local systems adminstration if you are unsure about how to do this.\n\u0026ndash;Ensembl genomes\n Basic usage The default mode for using the API is to use a specialised lookup database on the public Ensembl Genomes server. The usage of this is shown below, but note that there is a pregenerated snippet of code for each DBAdaptor on the species description page in the genome browser. Note that full PerlDoc is available from the API or here \u0026ndash;Ensembl genomes\n Example 1: Retrieve gene/\u0026hellip; informations\nuse strict; use warnings; use Bio::EnsEMBL::LookUp; my $lookup = Bio::EnsEMBL::LookUp-\u0026gt;new(); # Getting DBAdaptors # 1. by name $dba = $lookup-\u0026gt;get_by_name_exact('escherichia_coli_str_k_12_substr_mg1655'); $dba = $lookup-\u0026gt;get_all_by_name_pattern('escherichia_coli_str_k_12_*'); # 2. by taxonomy $dba = $lookup-\u0026gt;get_all_by_taxon_id(388919); # $dba = $lookup-\u0026gt;get_all_by_taxon_branch(561); # branch id # 3. by genomic INSDC accession $dba = $lookup-\u0026gt;get_all_by_accession('U00096'); # 4. by genome assembly accession $dba = $lookup-\u0026gt;get_by_assembly_accession('GCA_000005845.2') # E. coli supportting material:\n# E. coli K-12 MG1655 Organism name: Escherichia coli str. K-12 substr. MG1655 Infraspecific name: Strain: K-12 substr. MG1655 BioSample: SAMN02604091 Submitter: Univ. Wisconsin Date: 2013/09/26 Assembly level: Complete Genome Genome representation: full RefSeq category: reference genome GenBank assembly accession: GCA_000005845.2 (latest) RefSeq assembly accession: GCF_000005845.2 (latest) RefSeq assembly and GenBank assembly identical: yes IDs: 79781 [UID] 854978 [GenBank] 854998 [RefSeq] Molecule name GenBank sequence RefSeq sequence Chromosome U00096.3 = NC_000913.3 Advanced usages: The ensemblgenomes-api API can be used in conjunction with the Compara Perl API to access gene family data for Bacteria. We can also use Registry to get the family data. (see the script 1)\n* 1. Retrieve which family a gene belonging to? * 2. Retrieve genes belonging to a family. * 3. Retrieve genes belonging to a family, within a specific specie. * 4. Retrieve canonical peptides from a family. 1. Retrieve which famil a genen belonging to? (Two ways to get geneAdaptors of specific gene.) see script on github and the output.\nuse strict; use warnings; use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::LookUp; use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; use Data::Dumper; # Retrieve the family of a given gene #my $nom = 'mycobacterium_tuberculosis_h37rv_gca_000195955_2'; #my $input_gene = 'Rv2925c'; # RNase III my $nom = 'escherichia_coli_str_k_12_substr_mg1655'; my $input_gene = 'b0344'; my $lookup = Bio::EnsEMBL::LookUp-\u0026gt;new(); # load gene adaptor my $dba = $lookup-\u0026gt;get_by_name_exact($nom); my $gene_adaptor = $dba-\u0026gt;get_GeneAdaptor(); my $gene = $gene_adaptor-\u0026gt;fetch_by_stable_id($input_gene); # lacZ # OPTIONS 1, Bio::EnsEMBL::Registry # load Registry my $registry = 'Bio::EnsEMBL::Registry'; $registry-\u0026gt;load_registry_from_db( -host =\u0026gt; 'mysql-eg-publicsql.ebi.ac.uk', -port =\u0026gt; '4157', -user =\u0026gt; 'anonymous' ); my $member_adaptor = $registry-\u0026gt;get_adaptor('bacteria', 'compara', 'GeneMember'); my $family_adaptor = $registry-\u0026gt;get_adaptor('bacteria', 'compara', 'Family'); my $member = $member_adaptor-\u0026gt;fetch_by_stable_id($input_gene); my $families = $family_adaptor-\u0026gt;fetch_all_by_GeneMember($member); # OPTIONS 2, Compara ## load compara adaptor #my $compara_dba = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor-\u0026gt;new( # -host =\u0026gt; 'mysql-eg-publicsql.ebi.ac.uk', # -port =\u0026gt; '4157', # -user =\u0026gt; 'anonymous', # -dbname =\u0026gt; 'ensembl_compara_bacteria_25_78' # ); # #my $member = $compara_dba-\u0026gt;get_GeneMemberAdaptor()-\u0026gt;fetch_by_stable_id($input_gene); #my $families = $compara_dba-\u0026gt;get_FamilyAdaptor()-\u0026gt;fetch_all_by_GeneMember($member); # loop out print \u0026quot;Retrieve the family of input gene: \u0026quot;, $input_gene, \u0026quot;\\n\u0026quot;, \u0026quot;From genome: \u0026quot;, $nom, \u0026quot;\\n\\n\u0026quot;; print \u0026quot;Family\u0026quot;, \u0026quot;\\t\u0026quot;, \u0026quot;Family_description\u0026quot;, \u0026quot;\\n\u0026quot;; foreach my $family (@{$families}){ # this family print $family-\u0026gt;stable_id(), \u0026quot;\\t\u0026quot;, $family-\u0026gt;description(), \u0026quot;\\n\u0026quot;; } 2. Retrieve genes belonging to a family see script on github and the output.\nuse strict; use warnings; #use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::LookUp; use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; use Data::Dumper; my $input_family = 'MF_00395'; # # Retrieve genes from a given family my $lookup = Bio::EnsEMBL::LookUp-\u0026gt;new(); # load compara adaptor my $compara_dba = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor-\u0026gt;new( -host =\u0026gt; 'mysql-eg-publicsql.ebi.ac.uk', -port =\u0026gt; '4157', -user =\u0026gt; 'anonymous', -dbname =\u0026gt; 'ensembl_compara_bacteria_25_78' ); my $family = $compara_dba-\u0026gt;get_FamilyAdaptor()-\u0026gt;fetch_by_stable_id($input_family); # output print \u0026quot;Retrieve genes from a given family\\n\u0026quot;; print \u0026quot;Input family: \u0026quot;, $family-\u0026gt;stable_id(), \u0026quot; \u0026quot;, $family-\u0026gt;description(), \u0026quot;\\n\\n\u0026quot;; print \u0026quot;Output:\\n\u0026quot;, \u0026quot;Gene\u0026quot;, \u0026quot;\\t\u0026quot;, \u0026quot;GeneName\u0026quot;, \u0026quot;\\t\u0026quot;, \u0026quot;Species\u0026quot;, \u0026quot;\\n\u0026quot;; # find members in the family my $members = $family-\u0026gt;get_all_Members(); foreach my $member (@{$members}){ my $genome_db = $member-\u0026gt;genome_db(); # member dba my $member_dba = $lookup-\u0026gt;get_by_name_exact($genome_db-\u0026gt;name()); if(defined $member_dba){ my $gene_adaptor = $member_dba-\u0026gt;get_GeneAdaptor(); my $gene = $gene_adaptor-\u0026gt;fetch_by_stable_id($member-\u0026gt;gene_member()-\u0026gt;stable_id()); my $gene_external_name = (defined $gene-\u0026gt;external_name())?$gene-\u0026gt;external_name():\u0026quot;-\u0026quot;; print $gene-\u0026gt;stable_id(), \u0026quot;\\t\u0026quot;, $gene_external_name, \u0026quot;\\t\u0026quot;, $member_dba-\u0026gt;species(), \u0026quot;\\n\u0026quot;; $member_dba-\u0026gt;dbc()-\u0026gt;disconnect_if_idle(); } } 3. Retrieve genes belonging to a family, within a specific specie see script on github and the output.\nuse strict; use warnings; #use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::LookUp; use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; use Data::Dumper; my $input_family = 'MF_00395'; my $taxid = 1219; #Prochlorococcus marinus # find all genomes that descendants of a specified node (as a filter) my $lookup = Bio::EnsEMBL::LookUp-\u0026gt;new(); my $branches = $lookup-\u0026gt;get_all_by_taxon_branch($taxid); my %target_species = map {$_-\u0026gt;species() =\u0026gt; $_ } @{$branches}; # load compara adaptors my $compara_dba = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor-\u0026gt;new( -host =\u0026gt; 'mysql-eg-publicsql.ebi.ac.uk', -port =\u0026gt; '4157', -user =\u0026gt; 'anonymous', -dbname =\u0026gt; 'ensembl_compara_bacteria_25_78' ); my $family = $compara_dba-\u0026gt;get_FamilyAdaptor()-\u0026gt;fetch_by_stable_id($input_family); print \u0026quot;Retrieve genes from a given family, of specific genomes\\n\u0026quot;; print \u0026quot;Input family: \u0026quot;, $family-\u0026gt;stable_id(), \u0026quot;\\t\u0026quot;, $family-\u0026gt;description(), \u0026quot;\\n\u0026quot;; # find members in this family print \u0026quot;Find members of taxid 1219 in this family\\n\\n\u0026quot;; print \u0026quot;GeneID\u0026quot;, \u0026quot;\\t\u0026quot;, \u0026quot;Species\u0026quot;, \u0026quot;\\n\u0026quot;; my $members = $family-\u0026gt;get_all_Members(); foreach my $member (@{$members}){ my $genome_db = $member-\u0026gt;genome_db(); # filter by taxon from the list my $member_dba = $target_species{$genome_db-\u0026gt;name()}; if(defined $member_dba){ my $gene_adaptor = $member_dba-\u0026gt;get_GeneAdaptor(); my $gene = $gene_adaptor-\u0026gt;fetch_by_stable_id($member-\u0026gt;gene_member()-\u0026gt;stable_id()); my $gene_external_name = (defined $gene-\u0026gt;external_name())?$gene-\u0026gt;external_name():\u0026quot;-\u0026quot;; print $gene-\u0026gt;stable_id(), \u0026quot;\\t\u0026quot;, $gene_external_name, \u0026quot;\\t\u0026quot;, $member_dba-\u0026gt;species(), \u0026quot;\\n\u0026quot;; $member_dba-\u0026gt;dbc()-\u0026gt;disconnect_if_idle(); } } 4. Retrieve canonical peptides from a family see script on github, and the output.\nuse strict; use warnings; #use Bio::EnsEMBL::Registry; use Bio::EnsEMBL::LookUp; use Bio::SeqIO; use Data::Dumper; # Retrieve the canonical peptides from genes belonging to a given family # Input data my $input_family = 'MF_00395'; # lookup my $lookup = Bio::EnsEMBL::LookUp-\u0026gt;new(); # load compara my $compara_dba = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor-\u0026gt;new( -host =\u0026gt; 'mysql-eg-publicsql.ebi.ac.uk', -port =\u0026gt; '4157', -user =\u0026gt; 'anonymous', -dbname =\u0026gt; 'ensembl_compara_bacteria_25_78' ); my $family = $compara_dba-\u0026gt;get_FamilyAdaptor()-\u0026gt;fetch_by_stable_id($input_family); my $outfile = \u0026quot;\u0026gt;\u0026quot;. $family-\u0026gt;stable_id. \u0026quot;.fa\u0026quot;; my $seq_out = Bio::SeqIO-\u0026gt;new(-file =\u0026gt; $outfile, -format =\u0026gt; \u0026quot;fasta\u0026quot; ); print \u0026quot;Write family: \u0026quot;, $family-\u0026gt;stable_id(), \u0026quot; to $outfile\\n\u0026quot;; # loop over members my $members = $family-\u0026gt;get_all_Members(); foreach my $member (@{$members}){ my $genome_db = $member-\u0026gt;genome_db(); my $member_dba = $lookup-\u0026gt;get_by_name_exact($genome_db-\u0026gt;name()); if(defined $member_dba){ my $gene = $member_dba-\u0026gt;get_GeneAdaptor()-\u0026gt;fetch_by_stable_id($member-\u0026gt;gene_member()-\u0026gt;stable_id() ); print \u0026quot;Write sequence of \u0026quot;, $member-\u0026gt;stable_id(), \u0026quot;\\n\u0026quot;; my $s = $gene-\u0026gt;canonical_transcript()-\u0026gt;translate(); $seq_out-\u0026gt;write_seq($s); $member_dba-\u0026gt;dbc()-\u0026gt;disconnect_if_idle(); } } "
},
{
"uri": "/webpage_001/2014-10-14-things-to-do-after-install-ubuntu-1404/",
"title": "安装Ubuntu 14.04 之后需要做的几件事",
"tags": ["ubuntu"],
"description": "",
"content": " 使用中文界面的Ubuntu,需要做一些调整,更方便使用。主要包括系统优化、软件安装。\n1. 更改软件更新源: 在系统设置 -\u0026gt; Ubuntu 软件 -\u0026gt; 下载自,调整镜像为 http:// mirrors.163.com\n2. 安装软件: 1) 新立得件管理包:在Ubuntu软件中心搜索 新立得 即可。\n 2) Chromium: 在Ubuntu软件中心搜索并安装 chromium\n 3) 搜狗拼音for Linux:前往pinyin.sogou.com/linux/ 下载搜狗输入法for Linux, Ubuntu 14.04可直接双击deb包安装。\n 4) WPS office for Linux: 前往community.wps.cn/download下载最新版 deb 包,双击安装即可\n 5) VLC媒体播放器 3. 系统美化 1. 更改中文字体\n安装文泉驿黑字体\n sudo apt-get install ttf-wqy-microhei 2. 删除原默认字体 ukai, uming\n sudo apt-get remove fonts-arphic-ukai fonts-arphic-uming 3. 主题美化工具\n在Ubuntu软件中心安装美化工具 Unity Tweak Tool\n或者前往 http://ubuntu-twewak.com/ 下载 Ubuntu Tweak的deb包,双击安装即可。\n 4. 安装 Adobe Flash Player 1. 安装Adobe Flash Player (pepper flash player) sudo apt-get update sudo apt-get install chromium-browser sudo apt-get install pepperflashplugin-nonfree sudo update-pepperflashplugin-nonfree --install 2. 软件中心搜索adobe flash player安装即可 5. 安装Jekyll \u0026amp; git Jekyll 2 was recently released and can be installed on Ubuntu 14.04 using apt-get and gem install. Additional features such as Rdiscount can be added with the same meth od. Although there are packages for Jekyll in the Ubuntu repository, the packages are for older versions of Jekyll. See the reference:Install Jekyll 2 on Ubuntu 14.04\n 1. Insall Prerequisites\nInstall ruby, the ruby development libraries, and the make command. sudo apt-get install ruby ruby-dev make 2. Install Jekyll\nInstall the Jekyll gem system wide. To include all documentation, omit the --no-rdoc --no-ri switches. sudo gem install jekyll --no-rdoc --no-ri 3. ExecJS Workaround\nInstall nodejs to work around this issue sudo apt-get install nodejs 4. Start Jekyll\nCheck that Jekyll has been successfully installed.\n jekyll -v 5. Recommended\nInstall other required packages.\n - Install git sudo apt-get install git - Install Rdiscount Markdown renderer sudo gem install rdiscount --no-rdoc --no-ri - Install Redcarpet Markdown renderer sudo gem install redcarpet --no-rdoc --no-ri - Install 汉字to拼音 sudo gem install hz2py --no-rdoc --no-ri Check you site locally\nStart the website website HTML and start a local server. jekyll serve 6. 安装Bioinfo-tools 1. R 3.1.1 for ubuntu 14.04\n sudo add-apt-repository ppa:marutter/rrutter sudo apt-get update sudo apt-get upgrade sudo apt-get install r-base r-base-dev 2. Rstudio for ubuntu 14.04\n 前往 http://www.rstudio.com/products/rstudio/download/ 下载相应版本的 deb 包,双击安装。\n 3. Bioconductor\n source(\u0026quot;http://bioconductor.org/biocLite.R\u0026quot;) biocLite() biocLite(\u0026quot;DEG\u0026quot;) # install package Check which package is available on the website of Bioconductor.\n 4. Biopython\n Need to install the dependencies and biopython:\n a. Install Biopython dependencies # Numerical Python (NumPy) sudo apt-get install python-numpy python-scipy # Check python \u0026gt;\u0026gt;\u0026gt; import numpy b. Install ReportLab The ReportLab package is a library for generating PDF documents.\nsudo pip install rlextra -i https://wangm08@yeah.net:gongpeng!110@www.reportlab.com/pypi/ # For an automated install, the command line must split over separate lines. # Check \u0026gt;\u0026gt;\u0026gt; from reportlab.graphics import renderPDF c. Install Biopython Download biopython distribution: http://biopython.org/wiki/Download.\n# Unpack the file with tar -xzvpf biopython-**.tar.gz # Then change to the biopython* directory, and then install biopython sudo python setup.py install d. Check whether everything is worked Option 1:\n\u0026gt;\u0026gt;\u0026gt; from Bio.Seq import Seq \u0026gt;\u0026gt;\u0026gt; from Bio.Alphabet.IUPAC import unambiguous_dna \u0026gt;\u0026gt;\u0026gt; seq = Seq('GATCAGAAG', unambiguous_dna) \u0026gt;\u0026gt;\u0026gt; seq[0:2] \u0026gt;\u0026gt;\u0026gt; seq.translate() Option 2:\npython setup.py test 5 Install third-party tools from Synaptic\n a. NCBI Standalone BLAST\n b. clustalo, libargtable,\n c. EMBOSS,\n 6 Install samtools\n 7 install bedtools\n sudo apt-get install bedtools\n7. Q\u0026amp;A ============================ 1. Unable to access Windows partitions\n Error messages: Unable to access “OS” Error mounting /dev/sda1 at /media/ming/OS: Command-line `mount -t \u0026quot;ntfs\u0026quot; -o \u0026quot;uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000\u0026quot; \u0026quot;/dev/sda1\u0026quot; \u0026quot;/media/ming/OS\u0026quot;' exited with non-zero exit status 14: Windows is hibernated, refused to mount. Failed to mount '/dev/sda1': Operation not permitted The NTFS partition is in an unsafe state. Please resume and shutdown Windows fully (no hibernation or fast restarting), or mount the volume read-only with the 'ro' mount option. Solution Run the following commands in your terminal:\nsudo ntfsfix /dev/sd**NN**/ the NN is the partition you want to mount, (in my examples, it is sda1)\n[Warnnings: I do not know whether this solution will crash your windows.]\n8. 修改Ubuntu \u0026amp; Windows 双系统启动顺序 在Windows 8.1 系统上安装的 Ubuntu 15.04, 安装后默认的首选启动是: \u0026ldquo;Ubuntu\u0026rdquo;\n×Ubuntu Advanced options for Ubuntu Memory test (memtest86+) Memory test (memtest86+, serial console 11520) Windows 8 (loader) (on /dev/sda1) Ubuntu 15.04 using GRUB2 to manage the boot order.\nTwo ways to modify the boot order:\n 1 . recommended: $ sudo mv /etc/grub.d/30_os-prober /etc/grub.d/08-os-prober The above command is changing the name of 30_os-prober to 08_os-prober (06-09 is ok). The filename relate to Ubuntu boot are begin with \u0026ldquo;10\u0026rdquo;, so \u0026ldquo;08\u0026rdquo; is prior to the Ubuntu. At last, we have to update the grub by sudo update-grub\nThe output:\n$ sudo update-grub [sudo] password for ming: Generating grub configuration file ... Found Windows 8 (loader) on /dev/sda1 Found linux image: /boot/vmlinuz-3.19.0-10-generic Found initrd image: /boot/initrd.img-3.19.0-10-generic Found memtest86+ image: /memtest86+.elf Found memtest86+ image: /memtest86+.bin done Done, it turns out that Windows 8 is on the top.\n 2 . alternative way Open the file /etc/default/grub and change the value of GRUB_DEFAULT= from 0 to 4 ( the 5th is windows, ubuntu begin with 0\u0026rdquo;.\n$ sudo vim /etc/default/grub # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 # change it to 4 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2\u0026gt; /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT=\u0026quot;quiet splash\u0026quot; GRUB_CMDLINE_LINUX=\u0026quot;\u0026quot; ... Need to update the grub.\n$ sudo update-grub Done!\nReboot and you will find the default boot option is Windows 8.\n"
},
{
"uri": "/webpage_001/2015-03-26-small-rnas-in-bacteria/",
"title": "EOB-001: Synthetic RNA silencing in bacteria",
"tags": ["EOB", "bacteria"],
"description": "",
"content": " Synthetic RNA silencing in bacteria – antimicrobial discovery and resistance breaking Liam Good1 and James E. M. Stach2*\n1 Department of Pathology and Infectious Diseases, Royal Veterinary College, University of London, London, UK 2 School of Biology, Newcastle University, Newcastle upon Tyne, UK The increasing incidence and prevalence of antibiotic resistance in bacteria threatens the “antibiotic miracle.” Conventional antimicrobial drug development has failed to replace the armamentarium needed to combat this problem, and novel solutions are urgently required. Here we review both natural and synthetic RNA silencing and its potential to provide new antibacterials through improved target selection, evaluation, and screening. Furthermore, we focus on synthetic RNA silencers as a novel class of antibacterials and review their unique properties.\n Front. Microbiol., 12 September 2011 | doi: 10.3389/fmicb.2011.00185\n Figure 1. Natural RNA silencing in bacteria. (A) Antisense RNAs (asRNAs) that are cis-encoded share high degrees of complementarity with the target mRNA. (B) asRNAs that are trans-encoded have limited complementarity with the target mRNA and, in some species, require the an RNA chaperone (Hfq) to facilitate binding. In either case, once the asRNA is bound to the target mRNA, translation of the target gene (tarX) is silenced by inhibition of ribosome binding to the target mRNA (i); induced RNase degradation of the asRNA:mRNA hybrid (ii) or a combination of both processes. Figure 2. Abundance and stability of antisense RNA is related to the efficacy of gene silencing. (A) Linear asRNAs are subject to degradation by RNases (i) and thus, are not available to form hybrids with their target mRNA. The role of Hfq in trans-encoded asRNAs with a high degree of sequence complementarity with the target mRNA is not elucidated, however, as with natural asRNAs, Hfq may serve to protect asRNAs from degradation (ii). In situations where the abundance and stability of the linear asRNA is low, only partial gene silencing will result (iii). (B) Addition of paired-termini to the asRNA results in asRNAs that have increased abundance, likely as a result of resistance to RNase degradation (iv). The role of Hfq in PTasRNA-mediated gene silencing is unclear. The increased abundance of PTasRNAs results in a higher level of gene silencing (v). Reference\n Good L and Stach JEM (2011) Synthetic RNA silencing in bacteria – antimicrobial discovery and resistance breaking. Front. Microbio. 2:185. doi: 10.3389/fmicb.2011.00185\nURL: http://journal.frontiersin.org/article/10.3389/fmicb.2011.00185/full \n"
},
{
"uri": "/webpage_001/2015-03-20-ggplot2parallel/",
"title": "ggplot2 and parallel",
"tags": ["R", "ggplot2"],
"description": "",
"content": " Store the ggplot2 figs to a list object Q: How to create lists of ggplot?\nA: Find solutions in stackOverflow\n 1. Condition-1 I\u0026rsquo;m trying to create functions that return a list of ggplot.\nthe default class of ggplot are: gg and ggplot\nlibrary(ggplot2) p1 \u0026lt;- c(qplot(1:10, rnorm(10))) p2 \u0026lt;- qplot(1:10, rnorm(10)) attributes(p1) ## $names ## [1] \u0026quot;data\u0026quot; \u0026quot;layers\u0026quot; \u0026quot;scales\u0026quot; \u0026quot;mapping\u0026quot; \u0026quot;theme\u0026quot; ## [6] \u0026quot;coordinates\u0026quot; \u0026quot;facet\u0026quot; \u0026quot;plot_env\u0026quot; \u0026quot;labels\u0026quot; attributes(p2) ## $names ## [1] \u0026quot;data\u0026quot; \u0026quot;layers\u0026quot; \u0026quot;scales\u0026quot; \u0026quot;mapping\u0026quot; \u0026quot;theme\u0026quot; ## [6] \u0026quot;coordinates\u0026quot; \u0026quot;facet\u0026quot; \u0026quot;plot_env\u0026quot; \u0026quot;labels\u0026quot; ## ## $class ## [1] \u0026quot;gg\u0026quot; \u0026quot;ggplot\u0026quot; p[[1]] (same as p[['data']])) is supposed to be a dataframe. It usually holds the data for the plot.\np1 is a list because you used the c function.\np2 is a ggplot because that\u0026rsquo;s what qplot returns.\nSo, we can store many ggplot objects using list.\nFinalPlots \u0026lt;- list(p1, p2) Or we can save all the ggplot objects in the global env using the following function:\nAllPlots \u0026lt;- Filter(function(x) is(x, \u0026quot;ggplot\u0026quot;), mget(ls())) 2. Create \u0026gt;1000 figures using ggplot2 faster. I will store the ggplot in a list, and using parallel perform parallel computing. At last, write all the ggplot from the list to a PDF file.\nlibrary(foreach) library(doParallel) ## Loading required package: iterators ## Loading required package: parallel library(ggplot2) cl \u0026lt;- makeCluster(2) registerDoParallel(cl, cores = 2) getDoParName() ## [1] \u0026quot;doParallelSNOW\u0026quot; AllFig \u0026lt;- list() system.time( #for(i in 1:100) { AllFig \u0026lt;- foreach(i = 1:100, .packages = c(\u0026quot;ggplot2\u0026quot;)) %dopar% { fig \u0026lt;- ggplot(mtcars, aes(x = mpg, y = disp)) + geom_point() fig } ) ## user system elapsed ## 3.36 0.15 6.51 stopCluster(cl) pdf(\u0026quot;test.pdf\u0026quot;, width = 6, height = 4) for(i in 1:length(AllFig)) { print(AllFig[[i]]) } dev.off() ## png ## 2 Parallel computing in R (foreach + doParallel) URL: https://nycdatascience.com/slides/parallel_R/examples_general.html\nWe need packages: foreach, doParallel, or doSNOW\n Parallel 1: Two cores, two chunks\n library(doSNOW) ## Loading required package: snow ## ## Attaching package: 'snow' ## ## The following objects are masked from 'package:parallel': ## ## clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, ## clusterExport, clusterMap, clusterSplit, makeCluster, ## parApply, parCapply, parLapply, parRapply, parSapply, ## splitIndices, stopCluster library(foreach) library(randomForest) ## randomForest 4.6-10 ## Type rfNews() to see new features/changes/bug fixes. cores \u0026lt;- 2 cl \u0026lt;- makeCluster(cores, type = \u0026quot;SOCK\u0026quot;) registerDoSNOW(cl) ## main code, portable total.tree \u0026lt;- 2000 # B num.chunk \u0026lt;- 2 avg.tree \u0026lt;- ceiling(total.tree/num.chunk) ## foreach statement ntree: iterator .combine: speicify the way to collect ## results .packages: load the packages for workers system.time({ rf_fit \u0026lt;- foreach(ntree = rep(avg.tree, num.chunk), .combine = combine, .packages = c(\u0026quot;randomForest\u0026quot;)) %dopar% { randomForest(x = iris[, -5], y = iris[, 5], ntree = ntree) } }) ## user system elapsed ## 0.44 0.01 1.56 Parallel 2: Two cores, four chunk cores \u0026lt;- 2 cl \u0026lt;- makeCluster(cores, type = \u0026quot;SOCK\u0026quot;) registerDoSNOW(cl) total.tree \u0026lt;- 2000 num.chunk \u0026lt;- 4 avg.tree \u0026lt;- ceiling(total.tree/num.chunk) system.time({ rf_fit \u0026lt;- foreach(ntree = rep(avg.tree, num.chunk), .combine = combine, .packages = c(\u0026quot;randomForest\u0026quot;)) %dopar% { randomForest(x = iris[, -5], y = iris[, 5], ntree = ntree) } }) ## Warning: 关闭不再使用的链结6(\u0026lt;-activate.adobe.com:11647) ## Warning: 关闭不再使用的链结5(\u0026lt;-activate.adobe.com:11647) ## user system elapsed ## 0.81 0.03 1.91 stopCluster(cl) Usefull resources:\n1. vignettes of foreach. Site\n2. vignettes of Parallel. Site\n3. Simple example of doSNOW and parallel: site\n4. Example of Parallel computing using R. Site\n5. Example of ggplot2 graph. Site\n"
},
{
"uri": "/webpage_001/2015-04-13-manage-this-blog/",
"title": "Manage this blog",
"tags": [],
"description": "How to manage this blog?",
"content": " This post will describe the steps to manage the blog on Gihub.\nStart a new blog See the previous post: [URL]()\nManage this blog ##1 . Add/Del posts.\nUsing the rake command to create new posts, and git rm to delete old posts.\n# Add post rake post title=\u0026quot;name\u0026quot; # Del post git rm _post/2015-04-**_123 ##2 . Add/Del pages.\nUsing the rake command to create new pages.\nrake page name=\u0026quot;newPage\u0026quot; It will create a new folder of your input name, that contain a index.html file.\n##3 . Change the style of this blog.\nSuppose you are familiar with the directory structure of Jekyll static blogs. A basic Jekyll site usually looks something like this:\nFind more details at Jekyllrb.com\n. ├── _config.yml ├── _drafts | ├── begin-with-the-crazy-ideas.textile | └── on-simplicity-in-technology.markdown ├── _includes | ├── footer.html | └── header.html ├── _layouts | ├── default.html | └── post.html ├── _posts | ├── 2007-10-29-why-every-programmer-should-play-nethack.textile | └── 2009-04-26-barcamp-boston-4-roundup.textile ├── _data | └── members.yml ├── _site ├── assets | ├── images *images in this site. | └── themes *css files ├── pages └── index.md _config.yml Stores configuration data. Caution about the url title and name.\n_drafts The posts you do not want to publish can be placed in this folder. title.MARKUP.\n_includes Most of the theme and JB files are in this folder.\n/_includes/themes/mark-reid/ :\nsettings.yml,\ndefault.html : the default part of page/post in html format.\npage.html : the default format of pages\npost.html : the default format of posts\n/_includes/JB/\nposts_collate : return the variable include JB/posts_collate\ntags_list : return the variable include JB/tags_list %}\ncategories_list : return the variable include JB/categories_list\ncomments : return the variable include custom/comments \u0026hellip;\n_layouts These are the templates that wrap posts. The liquid tag content is used to inject content into the web page.\nThese files will be overwritted according to the changes in _include/theme/\u0026hellip;\n_posts Your dynamic content. the files must follow the format: YEAR-MONTH-DAY-title.MARKUP\n_site This is where the generated site will be placed once Jekyll is done transfroming it. It\u0026rsquo;s probably a good idea to add this to .gitignore file.\nindex.html (or index.md, Textile files) Provided that the file has a YAML Front Matter section, it will be transformed by Jekyll. (also for .html, .markdown, .md or .textile).\nassets Change the main CSS file /assets/themes/mark-reid/css/screen.css for the layout of the site.\nFrequently para: #header, #footer, pre, code \u0026hellip;\nmargin/padding: up right bottom left.\n font font-size : 14px;, with line-height: 20px; font-family : \u0026quot;Galdeano\u0026quot;,\u0026quot;Hiragino Sans GB\u0026quot;,\u0026quot;Microsoft YaHei\u0026quot;,Trebuchet,\u0026quot;Trebuchet MS\u0026quot;,Tahoma,\u0026quot;Lucida Grande\u0026quot;,\u0026quot;Lucida Sans Unicode\u0026quot;,Verdana,sans-serif; disqus \u0026amp; Google analytics pages The collection of all the pages in this blog. eg: /pages/about.md\nExamples: 1. Change the layout of header in CSS file. File: /assets/themes/mark-reid/css/screen.css\nThe html code of the header:\n\u0026lt;div id=\u0026quot;header\u0026quot;\u0026gt; \u0026lt;h1\u0026gt; \u0026lt;a href=\u0026quot;/\u0026quot; title=\u0026quot;M's Space\u0026quot;\u0026gt;M's Space\u0026lt;/a\u0026gt; \u0026lt;/h1\u0026gt; \u0026lt;ul class=\u0026quot;nav\u0026quot;\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a class=\u0026quot;home\u0026quot; href=\u0026quot;/\u0026quot;\u0026gt;Home\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a class=\u0026quot;archive\u0026quot; href=\u0026quot;/pages/archive.html\u0026quot;\u0026gt;Archive\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a class=\u0026quot;categories\u0026quot; href=\u0026quot;/pages/categories.html\u0026quot;\u0026gt;Categories\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a class=\u0026quot;links\u0026quot; href=\u0026quot;/pages/links.html\u0026quot;\u0026gt;Links\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;li\u0026gt;\u0026lt;a class=\u0026quot;about\u0026quot; href=\u0026quot;/pages/about.html\u0026quot;\u0026gt;About Me\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt; \u0026lt;/ul\u0026gt; \u0026lt;/div\u0026gt; The CSS code in file screen.css\n/* @group Header */ #header, #header a { color: #F2F2F2; border-bottom: none; } #header:hover a { text-decoration: none; } #header { position: relative; font-variant: small-caps; padding-left: 1em; border: 1px solid white; background-color: #585858; font-family: \u0026quot;Helvetica\u0026quot;,Palatino,georgia,\u0026quot;times new roman\u0026quot;,serif; } #header h1 a{ font-size: 16px; font-weight: bold; line-height: 20px; font-family: \u0026quot;Helvetica\u0026quot;,Palatino, georgia, \u0026quot;times new roman\u0026quot;, serif; } #header ul { text-align: right; position: absolute; display: inline; margin: 0; top: 0; right: 0; width: 80%; } #header ul li { display: inline; } #header ul li a { font-size: 13px; line-height: 4em; padding: 0.5em; display: inline; } #header ul li a:hover { color: #1C1C1C; background-color: white; line-height: 100%; border-bottom: none; text-decoration: none; } /* body #home #header a.home, body #archive #header a.archive, body #categories #header a.categories, body #links #header a.links, body #about #header a.about { color: #585858; background-color: white; } */ /* @end */ 2. Jekyll variables categories.path can be found in config.yml:\nJB : # These paths are to the main pages Jekyll-Bootstrap ships with. # Some JB helpers refer to these paths; change them here if needed. # archive_path: /pages/archive.html categories_path : /pages/categories.html tags_path : /pages/tags.html links_path : /pages/links.md about_path: /pages/about.md Aware about the config, site.JB.categories_path will return \u0026lsquo;/pages/categories.html\u0026rsquo;.\n*.md or *.html must be consistent with the files in /pages.\nNever mix is up.\n3. Preview the files in _draft you can run either of the following command to preview your draft as the latestt post.\njekyll serve --draft jekyll build --draft "
},
{
"uri": "/webpage_001/2015-04-11-ssh-login-without-password/",
"title": "SSh login without password [2 steps]",
"tags": [],
"description": "",
"content": "For instance, I want access to my CentOS server from my PC (Ubuntu) without input the password.\n[What] SSH from Ubuntu to CentOS without passwd.\n[How] Let the CentOS know the public rsa key of my Ubuntu.\nStep 1. On Ubuntu: Create public/private RSA key pair.\nssh-keygen -t rsa Default, it will create two files: ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.\nStep 2. Copy id_rsa.pub of Ubuntu to ~/.ssh/authorized_keys on CentOS\nscp ~/.ssh/id_rsa.pub yourname@192.168.1.30:/home/wangming/.ssh/temp.pub ## 192.168.1.30: ip of CentOS ## You need to input the passwd this time ## log in CentOS ssh yourname@192.168.1.30 # Input passwd of CentOS again cat ~/.ssh/temp.pub \u0026gt;\u0026gt; ~/.ssh/authorized_keys # copy Ubuntu public rsa key to CentOS authorized keys chmod 600 ~/.ssh/authorized_keys Finish. I can SSH to CentOS from my Ubuntu without passwd now.\nssh yourname@192.168.1.30 # no need passwd Just in the same way, I can generate and copy the public rsa key of CentOS to ~/.ssh/authorized_keys on Ubuntu to let CentOS log in Ubuntu without passwd.\n"
},
{
"uri": "/webpage_001/2015-03-29-toehold-switches/",
"title": "EOB-002: Toehold switches De-Novo-Designed Regulators of Gene Expression",
"tags": ["EOB", "small RNAs"],
"description": "",
"content": " Toehold Switches: De-Novo-Designed Regulators of Gene Expression Alexander A. Green,1 Pamela A. Silver,1,2 James J. Collins,1,3 and Peng Yin1,2,\n 1Wyss Institute for Biologically Inspired Engineering, Harvard University, Boston, MA 02115, USA\n 2Department of Systems Biology, Harvard Medical School, Boston, MA 02115, USA\n 3Howard Hughes Medical Institute, Department of Biomedical Engineering and Center of Synthetic Biology, Boston University, Boston, MA 02215, USA\n*Correspondence: py@hms.harvard.edu http://dx.doi.org/10.1016/j.cell.2014.10.002\n Highlights Toehold switches detect RNAs with arbitrary sequences, including endogenous RNAs\n A library of 26 orthogonal toehold switches provides \u0026lt;12% component crosstalk\n Rational RNA sequence design yields switches with \u0026gt;400-fold mean dynamic range\n Toehold switches can be integrated into the genome and complex genetic circuits\n Summary Efforts to construct synthetic networks in living cells have been hindered by the limited number of regulatory components that provide wide dynamic range and low crosstalk. Here, we report a class of de-novo-designed prokaryotic riboregulators called toehold switches that activate gene expression in response to cognate RNAs with arbitrary sequences. Toehold switches provide a high level of orthogonality and can be forward engineered to provide average dynamic range above 400. We show that switches can be integrated into the genome to regulate endogenous genes and use them as sensors that respond to endogenous RNAs. We exploit the orthogonality of toehold switches to regulate 12 genes independently and to construct a genetic circuit that evaluates 4-input AND logic. Toehold switches, with their wide dynamic range, orthogonality, and programmability, represent a versatile and powerful platform for regulation of translation, offering diverse applications in molecular biology, synthetic biology, and biotechnology.\n Figure 1. Toehold Switch Design and In Vivo Characterization (A and B) Design schematics of conventional riboregulators (A) and toehold switches (B). Variable sequences are shown in gray, whereas conserved or constrained sequences are represented by different colors. (A) Conventional riboregulator systems repress translation by base pairing directly to the RBS region. RNA-RNA interactions are initiated via a loop-linear or looploop interaction at the YUNR loop in an RNA hairpin. (B) Toehold switches repress translation through base pairs programmed before and after the start codon (AUG), leaving the RBS and start codon regions completely unpaired. RNA-RNA interactions are initiated via linear-linear interaction domains called toeholds. The toehold domain a binds to a complementary a* domain on the trigger RNA. Domains a and b are 12 and 18 nts, respectively. (C) Flow cytometry GFP fluorescence histograms for toehold switch number 2 compared to E. coli autofluorescence and a positive control. Autofluorescence level measured from induced cells not bearing a GFP-expressing plasmid. (D) GFP mode fluorescence levels measured for switches in their ON and OFF states in comparison to positive control constructs and autofluorescence. Error bars are the SD from at least three biological replicates. (E) ON/OFF GFP fluorescence levels obtained 3 hr after induction for 168 first-generation toehold switches. Inset: ON/OFF GFP fluorescence measured for toehold switches of varying performance levels at different time points following induction. Relative errors for the switch ON/OFF ratios were obtained by adding the relative errors of the switch ON and OFF state fluorescence measurements in quadrature. Relative errors for ON and OFF states are from the SD of at least three biological replicates. "
},
{
"uri": "/webpage_001/2015-01-23-hypergeometric-analysis--enrichment-analysis/",
"title": "超几何分析和GO富集分析",
"tags": ["GO", "KEGG"],
"description": "",
"content": " 关于超几何分布(Hypergeometric distribution)\n 超几何分布是统计学上一种离散概率分布,它描述了由有限个物件 (N) 中抽取 (n) 个物件,成功抽出制定种类物件的个数 (k) (不归还)。\n例如在有N个样品,其中m个是不及格的。超几何分布描述了在该N个样本中抽出n个,其中k个是不及格的几率。\nf(k;n,m,N) = C(m,k)*C(N-m, n-k)/C(N,n)\n若n=1,超几何分布还原为伯努利分布。 若n接近∞,超几何分布可视为二项式分布。\nFrom: Wikipedia\n 转换到生物学分析(GO)中,某样品具有GO注释的基因数 (N), 其中属于TermA的基因数目为 (M), (举例)差异表达分析后得到的基因数量为 (n),其中有 (k) 个基因属于TermA,现在需要使用超几何分析判断该TermA是否富集?!\nf(k,N,M,n) = C(k,M)*C(n-k,N-M)/C(n,N)\nN = size of population\nM = # of items in population with property \u0026ldquo;E\u0026rdquo;\nN-M = # of items in population without property \u0026ldquo;E\u0026rdquo;\nn = number of items sampled\nk = number of items in sample with property \u0026ldquo;E\u0026rdquo;\n解读为:先计算出k-1的累积可能性,再用1减去该数,即可得到获得 \u0026gt;=k 的可能性。(个人理解)\nR中的函数\n1-phyper(k-1,M,N-M,n) 关于富集性分析(Enrichment analysis) 需要知道有几种方法执行富集分析:\n1. 超几何分布(常用软件都使用该方法)。\n2. fisher\u0026rsquo;s exact test (也是使用超几何分布).\n3. chi-sauared test.\n1.《超几何分析》\nPosted by ygc on April 28, 2012\n原文链接:http://ygc.name/2008/08/20/hypergeometric-distribution/\n简单点说,超几何分布就是有限样本的无放回抽样。不同于有放回抽样的二项分布(每次贝努里试验成功概率是一样的),每次的概率不相等。 随机变量X的超几何概率分布:\nf(k,N,M,n) = C(k,M)*C(n-k,N-M)/C(n,N)\nN = size of population\nM = # of items in population with property \u0026ldquo;E\u0026rdquo;\nN-M = # of items in population without property \u0026ldquo;E\u0026rdquo;\nn = number of items sampled\nk = number of items in sample with property \u0026ldquo;E\u0026rdquo;\n这个公式可以理解为有C(n,N)种可能的样本,有C(k,M)种方法得到k个属于M的抽样、有C(n-k,N-M)种方法得到n-k个不属于M的抽样。\nX服从参数n,N,M的超几何分布记为 X~H(n,N,M).\n参考:http://en.wikipedia.org/wiki/Hypergeometric_distribution\n对于基因进行GO注释,看基因集在某个GO子类中是否富集,富集的概率服从超几何分布。 * N为GO注释的总基因数。 * M为属于某个GO子类的基因数。 * n为进行GO富集分析的基因集的数目。 * k为n中属于M的数目。 * 基因集n是否在M类中富集的概率\n1-phyper(k-1,M,N-M,n) ##R代码 或者是\nphyper(k-1,M,N-M,n, lower.tail=FALSE) 在已知总体分布下,抽样n个中出现M类的个数是k以及k以上个数的概率。\nlower.tail: logical; if TRUE (default), probabilities are P[X \u0026lt;= x], otherwise, P[X \u0026gt; x]. 2.《富集性分析》\nPosted by ygc on April 28, 2012\n原文链接: http://ygc.name/2012/04/28/enrichment-analysis/\n当我们用组学测定了一大堆分子之后,我们希望站在更高的角度去看这些分子和那些生物学过程相关。那么通常各种注释,对这些基因/蛋白进行分类,那么从分类的比例上,是不能草率下结论,正如上面有钱人学历分布的例子一样。我们需要把总体的分布考虑进去。\n和某个注释/分类是否有相关性,把基因分成属于这一类,和不属于这一类两种,这就好比经典统计学中的白球和黑球的抽样问题。也可以列一个2x2的表,进行独立性分析。\n以文章Gene Expression in Ovarian Cancer Reflects Both Morphology and Biological Behavior, Distinguishing Clear Cell from Other Poor-Prognosis Ovarian Carcinomas: URL 所鉴定的差异基因为例。\n73个差异基因的Symbol,我把它转为 entrezgene ID得到57个(漏掉的不管它,只是做为一个例子):\neg [1] #下面测试一下这些基因和化学刺激响应的相关性。 goid \u0026lt;- “GO:0042221” # response to chemical stimulus #那么做为背景,总体基因为N,属于“化学刺激响应”这个分类的基因有M个。 allgeneInCategory \u0026lt;- unique(get(goid, org.Hs.egGO2ALLEGS)) M \u0026lt;- length(allgeneInCategory) N \u0026lt;- length(mappedkeys(org.Hs.egGO)) #样本的大小是n,属于“化学刺激响应”这个分类的基因有k个。 n \u0026lt;- length(eg) k \u0026lt;- sum(eg %in% allgeneInCategory) #白球黑球问题,最简单的莫过于用二项式分布,从总体上看,要拿到一个基因属于“化学刺激响应”这个分类的概率是M/N。那么现在抽了n个基因,里面有k个基于这个分类,p值为: \u0026gt; 1-sum(sapply(0:k-1, function(i) choose(n,i) * (M/N)^i * (1-M/N)^(n-i))) [1] 8.561432e-10 #二项式分布,是有放回的抽样,你可以多次抽到同一基因,这是不符合的。所以这个计算只能说是做为近似的估计值,无放回的抽样,符合超几何分布,通过超几何分布的计算,p值为: \u0026gt; phyper(k-1,M, N-M, n, lower.tail=FALSE) [1] 7.879194e-10 #如果用2x2表做独立性分析,表如下: \u0026gt; d \u0026lt;- data.frame(gene.not.interest=c(M-k, N-M-n+k), gene.in.interest=c(k, n-k)) \u0026gt; row.names(d) \u0026lt;- c(\u0026quot;In_category\u0026quot;, \u0026quot;not_in_category\u0026quot;) \u0026gt; d gene.not.interest gene.in.interest In_category 2613 28 not_in_category 15310 29 #这个也有很多方法可以做检验,经典的有卡方检验和fisher's exact test。 如果用卡方检验来做。 \u0026gt; chisq.test(d, ) Pearson's Chi-squared test with Yates' continuity correction data: d X-squared = 51.3849, df = 1, p-value = 7.592e-13 对于2x2表来说,卡方检验通常也只能做为近似估计值,特别是当sample size或expected ell count比较小的时候,计算并不准确。 fisher\u0026rsquo;s exact test,名副其实,真的就比较exact,因为它使用的是超几何分布来计算p值。这也是为什么fisher\u0026rsquo;s exact test和超几何模式计算的p-值是一样的,\n\u0026gt; fisher.test(d) Fisher's Exact Test for Count Data data: d p-value = 7.879e-10 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.1013210 0.3089718 sample estimates: odds ratio 0.1767937 通常各种软件做GO富集性分析,都是使用超几何分布进行计算。 IPA软件则是使用fisher\u0026rsquo;s exact test来检验基因在某个网络中是否富集。\n从这个例子上看,chi-squared test的表现最差,binomial做为p值的近似估计还是不错的,因为计算较为简单。 富集性分析应用范围非常广,从Disease Ontology, Gene Ontology, KEGG, 到Reactome Pathway等等。\n"
},
{
"uri": "/webpage_001/2014-11-14-install-rna-seq-analysis-tools/",
"title": "RNA-Seq分析工具的配置",
"tags": ["R", "RNAseq"],
"description": "",
"content": "当前有很多RNA-Seq分析工具,本文主要记录在Linux + Windows下常用的软件安装注意事项。\nupdate: 2014-11-14 OS: Linux系统下一般使用 \u0026ndash;prefix将程序安装到自定义的路径。再通过修改 ~/.bash_profile 将该路径添加到 $PATH方便使用。\n python 2.7.8\n从www.python.org这里下载系统对应的python版本。\nLinux X86_64 版本: Python 2.7.8 source release Gzipped source tarball\nMD5sum: d4bca0159acb0b44a781292b5231936f\nsize: 14846119\n 安装在个人目录:$HOME/localpython/\ntar zxvf Python-2.7.8.tgz cd Python-2.7.8 ./configure --prefix=$HOME/localpython/ make make install 安装Python modules 查看当前Python的安装目录:\n$ python Python 2.7.8 (default, Nov 14 2014, 13:47:10) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type \u0026quot;help\u0026quot;, \u0026quot;copyright\u0026quot;, \u0026quot;credits\u0026quot; or \u0026quot;license\u0026quot; for more information. \u0026gt;\u0026gt;\u0026gt; import sys \u0026gt;\u0026gt;\u0026gt; sys.prefix '/home/wangming/localpython' \u0026gt;\u0026gt;\u0026gt; sys.exec_prefix '/home/wangming/localpython' 如果使用系统默认安装的python (2.6.6):\n$ /usr/bin/python Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type \u0026quot;help\u0026quot;, \u0026quot;copyright\u0026quot;, \u0026quot;credits\u0026quot; or \u0026quot;license\u0026quot; for more information. \u0026gt;\u0026gt;\u0026gt; import sys \u0026gt;\u0026gt;\u0026gt; sys.prefix '/usr' \u0026gt;\u0026gt;\u0026gt; sys.exec_prefix '/usr' 若对以上目录无写入权限,则需要安装python modules至有写入权限的路径:\npython setup.py install --prefix=$HOME/localpython/ CentOS: $PATH 备份\n Linux系统下$PATH配置:\n/usr/lib64/qt-3.3/bin /usr/kerberos/bin /usr/kerberos/sbin /usr/local/bin /usr/local/sbin /bin /sbin /usr/bin /usr/sbin $HOME/bin $HOME/.cpan $HOME/bin $HOME/bin/lib $HOME/software/R-3.1.1/bin $HOME/software/Python-2.7.8/bin $HOME/software/blast-2.2.24/bin $HOME/software/soap2.20release $HOME/software/tophat-2.0.13.Linux_x86_64 $HOME/software/samtools-1.1 $HOME/software/bowtie-1.1.1 $HOME/software/bowtie2-2.2.4 $HOME/software/bedtools2-2.21.0/bin $HOME/software/stacks-1.21/bin $HOME/software/fastx_toolkit-0.0.14/bin $HOME/software/samstat-1.5/bin $HOME/.local/bin "
},
{
"uri": "/webpage_001/2014-10-31-edit-linux-path/",
"title": "编辑Linux的$PATH",
"tags": ["bashrc"],
"description": "",
"content": "linux环境变量设置错误后,如何恢复解决方案:在命令行中输入:\nexport PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin 后回车\n/etc/profile: 此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置.\n/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.~\n/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件 仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.\n~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.\n~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.\n/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承 /etc/profile中的变量,他们是\u0026rdquo;父子\u0026rdquo;关系.~/.bash_profile 是交互式、login 方式进入 bash 运行的~/.bashrc 是交互式 non-login 方式进入 bash 运行的通常二者设置大致相同,所以通常前者会调用后者。 www.linux010.cn (来源:linux010)\n"
},
{
"uri": "/webpage_001/2014-10-29-rnaseq-analysis-using-r-and-bioconductor/",
"title": "使用R和Bioconductor进行RNASeq差异表达分析",
"tags": ["R", "RNASeq"],
"description": "",
"content": " RNA-Seq analysis using R and Bioconductor\nCount-based differential expression analysis of RNA sequencing data using R and Bioconductor Published online 22 August 2013; doi:10.1038/nprot.2013.099 nature protocols | VOL.8 NO.9 | 2013\nSee the original material: URL\n1 Summary The samples cited here can be found @ URL\nBrooks, A.N. et al. Conservation of an RNA regulatory map between Drosophila and mammals. Genome Res. 21, 193–202 (2011).\nLibrary Library Layout shortname Fastaq\nUntreated-3 PAIRED CT.PA.1 SRR031714, *15\nUntreated-4 PAIRED CT.PA.2 SRR031716, *17\nCG8144_RNAi-3 PAIRED KD.PA.3 SRR031724, *25\nCG8144_RNAi-4 PAIRED KD.PA.4 SRR031726, *27\nUntreated-1 SINGLE CT.SI.5 SRR031708, *09-13\nCG8144_RNAi-1 SINGLE KD.SI.6 SRR031718, *19-23\nUntreated-6 SINGLE CT.SI.7 SRR031728, *29\n2 Method *1 Go to work directory\nsetwd(\u0026quot;/home/wangming/work/R_bioconductor/\u0026quot;) *2 Loading sample information\nreadRDS(\u0026quot;sri.txt\u0026quot;) Start procedure\n*3 Reads quality control\n#library(\u0026quot;ShortRead\u0026quot;) #fqQC \u0026lt;- qa(dirPath=\u0026quot;reads\u0026quot;, pattern=\u0026quot;.fastq$\u0026quot;, type=\u0026quot;fastq\u0026quot;) #report(fqQC, type=\u0026quot;html\u0026quot;, dest=\u0026quot;fastqQAreport\u0026quot;) *4 Create sample table\nsri$LibraryName \u0026lt;- gsub(\u0026quot;S2_DRSC_\u0026quot;, \u0026quot;\u0026quot;, sri$LibraryName) # trim the library name samples \u0026lt;- unique(sri[, c(\u0026quot;LibraryName\u0026quot;, \u0026quot;LibraryLayout\u0026quot;)]) for(i in 1:nrow(samples)) { rw \u0026lt;- (sri$LibraryName == samples$LibraryName[i]) if(samples$LibraryLayout[i] == \u0026quot;PAIRED\u0026quot;) { samples$fastq1[i]=paste0(paste(\u0026quot;reads\u0026quot;, sri$Run[rw], sep=\u0026quot;/\u0026quot;), \u0026quot;_1.fastq\u0026quot;, collapse=\u0026quot;,\u0026quot;) samples$fastq2[i]=paste0(paste(\u0026quot;reads\u0026quot;, sri$Run[rw], sep=\u0026quot;/\u0026quot;), \u0026quot;_2.fastq\u0026quot;, collapse=\u0026quot;,\u0026quot;) } else { samples$fastq1[i]=paste0(paste(\u0026quot;reads\u0026quot;, sri$Run[rw], sep=\u0026quot;/\u0026quot;), \u0026quot;.fastq\u0026quot;, collapse=\u0026quot;,\u0026quot;) samples$fastq2[i]=\u0026quot;\u0026quot; } } *5 Add description columns\nsamples$condition \u0026lt;- \u0026quot;CTL\u0026quot; samples$condition[grep(\u0026quot;RNAi\u0026quot;, samples$LibraryName)] \u0026lt;- \u0026quot;KD\u0026quot; # Knock down samples$shortname \u0026lt;- paste(substr(samples$condition, 1, 2), substr(samples$LibraryLayout, 1, 2), seq_len(nrow(samples)), sep=\u0026quot;.\u0026quot;) *6 Inspect the table carefully\nprint out the \u0026ldquo;samples\u0026rdquo;\nhead(samples, 5) *7 Using R to create shell commands\ngtf \u0026lt;- \u0026quot;reference/Drosophila_melanogaster.BDGP5.70.gtf\u0026quot; bowtieIndex \u0026lt;- \u0026quot;reference/Dme1_BDGP5_70\u0026quot; bowtieCMD \u0026lt;- with(samples, paste(\u0026quot;tophat2 -G\u0026quot;, gtf, \u0026quot;-p 5 -o\u0026quot;, LibraryName, bowtieIndex, fastq1, fastq2)) bowtieCMD *8 Run the command in Unix terminal\nwrite.table(bowtieCMD, \u0026quot;RunBowtie2.R\u0026quot;, sep=\u0026quot;\\n\u0026quot;, row.names=FALSE, col.names=FALSE) *9 Organize the BAM files and create SAM files\nsmCMD \u0026lt;- \u0026quot;\u0026quot; for(i in 1:nrow(samples)) { lib \u0026lt;- samples$LibraryName[i] ob \u0026lt;- file.path(lib, \u0026quot;accepted_hits.bam\u0026quot;) # sort bam files by name, convert to SAM for htseq-count sm1 \u0026lt;- paste0(\u0026quot;samtools sort -n \u0026quot;, ob, \u0026quot; \u0026quot;, lib, \u0026quot;_sn\u0026quot;) sm2 \u0026lt;- paste0(\u0026quot;samtools view -o \u0026quot;, lib, \u0026quot;_sn.sam \u0026quot;, lib, \u0026quot;_sn.bam\u0026quot;) # sort by position and index for IGV sm3 \u0026lt;- paste0(\u0026quot;samtools sort \u0026quot;, ob, \u0026quot; \u0026quot;, lib, \u0026quot;_s\u0026quot;) sm4 \u0026lt;- paste0(\u0026quot;samtools index \u0026quot;, lib, \u0026quot;_s.bam\u0026quot;) smCMD[i] \u0026lt;- paste(sm1, sm2, sm3, sm4, sep=\u0026quot;\\n\u0026quot;) write.table(smCMD[i], paste0(\u0026quot;RunSm-\u0026quot;, samples$LibraryName[i], \u0026quot;.sh\u0026quot;), row.names=FALSE, col.names=FALSE) } #write.table(smCMD, \u0026quot;RunSamtools.sh\u0026quot;, sep=\u0026quot;\\n\\n\u0026quot;, row.names=FALSE, col.names=FALSE) Run the above commands in UNIX terminal.\n*10 Inspect the Alignment data using IGV D. melanogaster (dm3) genome, BAM files and GTF file.\n*11 Check the expressed transcript (Figure 3)\n*12 Select the positive and negative controls for the system from other study.\n*13 Count reads using htseq-count\nsamples$countf \u0026lt;- paste(samples$LibraryName, \u0026quot;count\u0026quot;, sep=\u0026quot;.\u0026quot;) gtf \u0026lt;- \u0026quot;reference/Drosophila_melanogaster.BDGP5.70.gtf\u0026quot; htseqCMD \u0026lt;- paste0(\u0026quot;htseq-count -s no -a 10 \u0026quot;, samples$LibraryName, \u0026quot;_sn.sam \u0026quot;, gtf, \u0026quot; \u0026gt; \u0026quot;, samples$countf) write.table(htseqCMD, \u0026quot;HTSeq-count.sh\u0026quot;, row.names=FALSE, col.names=FALSE) htseqCMD Run the above commands in UNIX terminal.\n*14 Differential expression analysis using edgeR. A. edgeR - simple B. edgeR - complex C. DESeq - simple D. DESeq - complex\n*A. edgeR - simple\n##1 Start edgeR library(\u0026quot;edgeR\u0026quot;) counts \u0026lt;- readDGE(samples$countf)$counts ##2 Filter weakly expressed and noninformative features noint \u0026lt;- rownames(counts) %in% c(\u0026quot;no_feature\u0026quot;, \u0026quot;ambiguous\u0026quot;, \u0026quot;too_low_aQual\u0026quot;, \u0026quot;alignment_not_unique\u0026quot;) cpms \u0026lt;- cpm(counts) keep \u0026lt;- rowSums(cpms \u0026gt; 1) \u0026gt;= 3 \u0026amp; ! noint counts \u0026lt;- counts[keep, ] ##2 Inspect the count table colnames(counts) \u0026lt;- samples$shortname head(counts[, order(samples$condition)], 5) ##4 Create a DGEList object. d \u0026lt;- DGEList(counts = counts, group = samples$condition) ##5 Estimate normalization factors d \u0026lt;- calcNormFactors(d) ##6 Inspect the relationships using multidimentional scaling (MDS) plot plotMDS(d, labels = samples$shortname, col = c(\u0026quot;darkgreen\u0026quot;,\u0026quot;blue\u0026quot;)[factor(samples$condition)]) ##7 Estimate tagwise dispersion (simple design) d \u0026lt;- estimateCommonDisp(d) d \u0026lt;- estimateTagwiseDisp(d) ##8 Create a visual representation of the mean-variance relationship using the ## plotMeanVar (Fig. 5a) and plotBCV (Fig. 5b) functions, as follows: plotMeanVar(d, show.tagwise.vars = TRUE, NBline = TRUE) plotBCV(d) ##9 Test for differential expression (‘classic’ edgeR), de \u0026lt;- exactTest(d, pair = c(\u0026quot;CTL\u0026quot;,\u0026quot;KD\u0026quot;)) ##10 See Step 14B(##6-##9) ##//---Step 14B(##6-##9)---## ##6 Use the topTags function to present a tabular summary of the differential ## expression statistics. tt \u0026lt;- topTags(de, n=nrow(d)) head(tt$table) ##7 Inspect the depth-adjusted reads per million for some of the top ## differentially expressed genes nc \u0026lt;- cpm(d, normalized.lib.sizes=TRUE) rn \u0026lt;- rownames(tt$table) head(nc[rn, order(samples$condition)], 5) ##8 Create a graphical summary, such as an M (log-fold) VS A (log-average) plot, ## here showing the genes selected as differentially expressed (FDR=0.05) deg \u0026lt;- rn[tt$table$FDR \u0026lt; 0.05] plotSmear(d, de.tags=deg) ##9 Save the result table as CSV file write.csv(tt$table, file=\u0026quot;toptags_edgeR.csv\u0026quot;) ##//------## *B. edgeR - complex\n##1 Follow Step 14A(##1-##6) ##2 Create a design matrix (see ‘Experimental design’ for further details) to ## specify the factors that are expected to affect expression levels: design = model.matrix( ~ LibraryLayout + condition, samples) design ##3 Estimate dispersion values, using the Cox-Reid (CR)-adjusted likelihood d2 \u0026lt;- estimateGLMTrendedDisp(d, design) d3 \u0026lt;- estimateGLMTagwiseDisp(d2, design) ##4 Given the design matrix and dispersion esitmates, fit a GLM to each feature f \u0026lt;- glmFit(d2, design) ##5 Perform a likelihood ratio test, specifying the difference of interest ## (Knockdown VS control, the 3rd column of the matrix) de \u0026lt;- glmLRT(f, coef=3) ##6 Use the topTags function to present a tabular summary of the differential ## expression statistics. tt \u0026lt;- topTags(de, n=nrow(d)) head(tt$table) ##7 Inspect the depth-adjusted reads per million for some of the top ## differentially expressed genes nc \u0026lt;- cpm(d, normalized.lib.sizes=TRUE) rn \u0026lt;- rownames(tt$table) head(nc[rn, order(samples$condition)], 5) ##8 Create a graphical summary, such as an M (log-fold) VS A (log-average) plot, ## here showing the genes selected as differentially expressed (FDR=0.05) deg \u0026lt;- rn[tt$table$FDR \u0026lt; 0.05] plotSmear(d, de.tags=deg) ##9 Save the result table as CSV file write.csv(tt$table, file=\u0026quot;toptags_edgeR.csv\u0026quot;) *C. DESeq - simple design\n##1 Create a data.frame with required data: samplesDESeq \u0026lt;- with(samples, data.frame(shortname=I(shortname), countf=I(countf), condition=condition, LibraryLayout=LibraryLayout)) ##2 Load the DESeq package and create a CountDataSet object (DESeq’s container ## for RNA-seq data) from the count tables and corresponding metadata: library(\u0026quot;DESeq\u0026quot;) cds \u0026lt;- newCountDataSetFromHTSeqCount(samplesDESeq) ##3 Estimate normalization factors cds \u0026lt;- estimateSizeFactors(cds) ##4 Inspect the size factors sizeFactors(cds) ##5 Inspect sample relationships, invoke a variance-stabilizing trasformation ## and inspect a principal component analysis (PCA) plot cdsB \u0026lt;- estimateDispersions(cds, method=\u0026quot;blind\u0026quot;) vsd \u0026lt;- varianceStabilizingTransformation(cdsB) p \u0026lt;- plotPCA(vsd, intgroup=c(\u0026quot;condition\u0026quot;, \u0026quot;LibraryLayout\u0026quot;)) ##6 Use estimateDispersions to calculate dispersion values cds \u0026lt;- estimateDispersions(cds) ##7 Inspect the estimated dispersions using the plotDispEsts function plotDispEsts(cds) ##8 Perform the test for differential expression by using nbinomTest res \u0026lt;- nbinomTest(cds,\u0026quot;CTL\u0026quot;,\u0026quot;KD\u0026quot;) ##9 Given the table of differential expression results, use plotMA to display ## differential expression (log-fold) VS expression strength (log-average) plotMA(res) ##10 Inspect the result tables of significantly upregulated and downregulated ## genes: FDR=0.1 resSig \u0026lt;- res[which(res$padj \u0026lt; 0.1), ] head(resSig[order(resSig$log2FoldChange, decreasing=TRUE), ]) head(resSig[order(resSig$log2FoldChange, decreasing=FALSE), ]) ##11 Count the number of genes with significant differential expression at ## FDR=0.1 table(res$padj \u0026lt; 0.1) ##12 Create a persistent storage of results using a CSV file write.csv(res, file=\u0026quot;res_DESeq.csv\u0026quot;) ##13 Perform a sanity check by inspecting a histogram of unadjusted P values ## for the differential expression results hist(res$pval, breaks=100) *D. DESeq - complex design\n##1 Follow Step 14C(##1-##5) ##2 Calculate the CR-adjusted profile likelihood dispersion estimates relative ## to the factors specified, developed by McCarthy et al., according to: cds \u0026lt;- estimateDispersions(cds, method = \u0026quot;pooled-CR\u0026quot;, modelFormula = count ~ LibraryLayout + condition) ##3 Test for differential expression in the GLM setting by fitting both a full ## model and reduced model (i.e., with the factor of interest taken out): fit1 \u0026lt;- fitNbinomGLMs(cds, count ~ LibraryLayout + condition) fit0 \u0026lt;- fitNbinomGLMs(cds, count ~ LibraryLayout) ##4 By using the two fitted models, compute likelihood ratio statistics and ## associated P values, as follows: pval \u0026lt;- nbinomGLMTest(fit1, fit0) ##5 Adjust the reported P values for multiple testing: padj \u0026lt;- p.adjust(pval, method = \u0026quot;BH\u0026quot;) ##6 Assemble a result table from full model fit and the raw and adjusted P ## values and print the first few upregulated and downregulated genes (FDR \u0026lt; 10%): res \u0026lt;- cbind(fit1, pval=pval, padj=padj) resSig \u0026lt;- res[which(res$padj \u0026lt; 0.1),] head(resSig[order(resSig$conditionKD, decreasing=TRUE), ]) head(resSig[order(resSig$conditionKD, decreasing=FALSE), ]) ##7 Follow Step 14C(##11-##13). ##//------## ##11 Count the number of genes with significant differential expression at ## FDR=0.1 table(res$padj \u0026lt; 0.1) ##12 Create a persistent storage of results using a CSV file write.csv(res, file=\u0026quot;res_DESeq.csv\u0026quot;) ##13 Perform a sanity check by inspecting a histogram of unadjusted P values ## for the differential expression results hist(res$pval, breaks=100) ##//------## *15. As another spot check, point the IGV genome browser (with GTF and BAM files loaded) to a handful of the top differentially expressed genes and confirm that the counting and differential expression statistics are appropriately represented.\n"
},
{
"uri": "/webpage_001/2014-10-19-github-markdown-syntax/",
"title": "Github Markdown常用语法",
"tags": ["github"],
"description": "",
"content": " 日常使用Markdown文档时所需的语法:\n1. 链接 文字-\u0026gt;URL链接\n使用 [Baidu](http://www.baidu.com) 的方式添加超级链接。 Baidu\n 图片\n使用: 格式\n 2. 格式 常规文字格式\n Headings\n在文字开头加入一个或多个 #,可控制文字大小 # Heading 1 ## Heading 2 ### Heading 3 #### Heading 4 显示效果如下:\nHeading 1 Heading 2 Heading 3 Heading 4 Styling text\n对文字格式化,语法如下: * italic * ** bold ** __bold__ ~~delete~~ 显示效果如下:\nitalic\nbold\nbold\ndelete\n Nested lists\n在list前加入两个空格可以做退格显示 1. Item 1 1. A corollary to the above item. 2. Yet another point to consider. 2. Item 2 * A corollary that does not need to be ordered. * This is indented four spaces, because it's two spaces further than the item above. * You might want to consider making a new list. 显示效果如下:\n1. Item 1\n1. A corollary to the above item.\n2. Yet another point to consider.\n2. Item 2\n* A corollary that does not need to be ordered.\n* This is indented four spaces, because it\u0026rsquo;s two spaces further than the item above.\n* You might want to consider making a new list.\n Blockquotes 加入 \u0026gt; 即可显示为引用 In the words of Abraham Lincoln: \u0026gt; Pardon my french 显示效果如下:\nIn the words of Abraham Lincoln: \u0026gt; Pardon my french\n3. Code formatting 涉及两种情况需要做代码语法标记:\n 个别单词\n在需要标记的文字前后加上一个 ` 即可。 Here's an idea: why don't we take `SuperiorProject` and turn it into `**Reasonable** Project`. 显示效果如下:\nHere\u0026rsquo;s an idea: why don\u0026rsquo;t we take SuperiorProject and turn it into **Reasonable** Project.\n 整段代码\n使用三个```标记,分离出一个断落,最好在开头处空出一行。\nCheck out this neat program I wrote:\nx = 0 x = 2 + 2 what is x ```\n 语法高亮\n 使用如下方式可以进行语法高亮标记\nCheck out this neat program I wrote: Code:\n```python x = 0 x = 2 + 2 what is x ``` Output:\nx = 0 x = 2 + 2 what is x 4. Task lists Code:\n- [x] @mentions, #refs, [links](), **formatting**, and \u0026lt;del\u0026gt;tags\u0026lt;/del\u0026gt; supported - [x] list syntax required (any unordered or ordered list supported) - [x] this is a complete item - [ ] this is an incomplete item 显示效果如下:\n- [x] @mentions, #refs, [links](), formatting, and tags supported\n- [x] list syntax required (any unordered or ordered list supported)\n- [x] this is a complete item\n- [ ] this is an incomplete item\n"
},
{
"uri": "/webpage_001/2014-10-19-add-search-box-to-blog/",
"title": "在Jekyll blog中添加搜索框",
"tags": ["Jekyll"],
"description": "",
"content": " 使用Jekyll + Github管理blog后,希望添加本地搜索功能,折腾太久依旧没有搞定。这里先记录下当前做过的尝试:\n Google custom search\n Jekyll + lunr 查阅这份repo中的相关描述。\n Tipue 官方文档中有详细说明。\n Crawler\n查阅相关blog的说明5 Steps to Creating a Search Box for Static Blogs\n 苦于仅仅菜鸟一枚,上述方法依旧没有搞定。\n我对Search box的设想是: 搜索窗口固定于页面顶部\n 输入关键词的同时即以下拉方式显示搜索结果\n 搜索范围包括:标签,分类,标题,全文\n "
},
{
"uri": "/webpage_001/2014-10-08-open-source-mirrors-in-china/",
"title": "国内可选择的开源软件镜像源",
"tags": ["ubuntu", "mirrors"],
"description": "",
"content": "国内的开源镜像,网易、搜狐和阿里的速度就很不错。\n 阿里云开源镜像站:http://mirrors.aliyun.com/\n 网易开源镜像站:http://mirrors.163.com/\n 搜狐开源镜像站:http://mirrors.sohu.com/\n 教育网提供的源也值得重点参考,只是最近在ubuntu使用bjtu的源更新软件,偶尔出现不稳定的现象(2015-03)。\n 北京交通大学开源镜像站:http://mirror.bjtu.edu.cn/\n 兰州大学开源软件镜像站:http://mirror.lzu.edu.cn/\n 厦门大学开源软件镜像站:http://mirrors.xmu.edu.cn/\n 上海交通大学开源软件镜像站:http://ftp.sjtu.edu.cn/\n 清华大学开源软件镜像站:http://mirrors.tuna.tsinghua.edu.cn/\n 天津大学开源软件镜像站:http://mirror.tju.edu.cn/\n 中国科学技术大学开源软件镜像站:http://mirrors.ustc.edu.cn/\n 东北大学开源软件镜像站:http://mirror.neu.edu.cn/\n 东软信息学院开源软件镜像站:http://mirrors.neusoft.edu.cn/\n 浙江大学开源软件镜像站:http://mirrors.zju.edu.cn 北京理工大学开源软件镜像站:http://mirror.bit.edu.cn 华中科技大学开源软件镜像站:http://mirrors.hust.edu.cn/\n 中山大学开源软件镜像站:http://mirror.sysu.edu.cn/\n 大连理工大学开源软件镜像站:http://mirror.dlut.edu.cn/\n 参考文章:\n 中国大陆开源镜像站汇总\n 国内开源镜像站点汇总\n "
},
{
"uri": "/webpage_001/2014-10-04-download-files-with-python/",
"title": "通过Python批量下载文件",
"tags": ["Python"],
"description": "",
"content": " 使用Python时,通常会遇到下载文件的需要,直接下载是最快捷的方式。以下分别介绍两种工具下载文档的方法。\nPython Python最常用的是使用urllib或者urllib2模块通过HTTP下载文档。\n以下介绍下载R文档的方法:\nimport urllib import urllib2 import requests # Test URL url = \u0026quot;http://rfunction.com/code/1202/120202.R\u0026quot; # 1. Using urllib module print \u0026quot;Begin download with urllib\u0026quot; urllib.urlretrieve(url, \u0026quot;code1.R\u0026quot;) # 2. Using urllib2 module print \u0026quot;Begin download with urllib2\u0026quot; f = urlllib2.urlopen(url) with open(\u0026quot;code2.R\u0026quot;, \u0026quot;wb\u0026quot;) as code : code.write(f.read()) # 3. Using requests print \u0026quot;Begin download with requests\u0026quot; r = requests.get(url) with open(\u0026quot;code3.R\u0026quot;, \u0026quot;wb\u0026quot;) as code : code.write(r.content) The requests library method is get, which corresponds to the HTTP GET. Then you just take the requests object and call its content property to get the data you want to write. We use the with statement because it will automatically close a file and simplifies the code. Note that just using read() for large file can be dangerous. It would be better to read it in pieces by passing read a size.\nPosted by Mike Driscoll. You can find the original post Here\n"
},
{
"uri": "/webpage_001/2014-10-04-download-files-with-r/",
"title": "通过R语言下载文档",
"tags": ["R"],
"description": "",
"content": "使用R批量下载文件\n说明\n主要是在懒得挨个链接区另存为,所以折腾了一段R代码来完成\n#1 思路\n* 1 提取一个URL下所有链接地址\n* 2 批量下载符合规则的文件\n#2 工具 * 1 download.file()\n另一个相同功能的下载函数 download()来自downloader包\ninstall.packages(\u0026quot;downloader\u0026quot;) library(downloader) #3 实践 下载二进制文件时,需要使用 mode=\u0026ldquo;wb\u0026rdquo; 参数。\n###1 下载单个PDF文件\nurl \u0026lt;- \u0026quot;http://rfunction.com/code/1202/par-120208.pdf\u0026quot; download.file(url, basename(url), mode=\u0026quot;wb\u0026quot;) ###2 下载单个MP3文件 这里以GRE词汇的录音文件为例:Links\nurl \u0026lt;- \u0026quot;http://download.dogwood.com.cn/online/grechjx/WordList01.mp3\u0026quot; download.file(url, basename(url), mode=\u0026quot;wb\u0026quot; ) **此处若缺少 mode=\u0026ldquo;wb\u0026rdquo; 参数,则下载的文档无法正常播放 **\n###3 批量下载文本文件 \u0026ldquo;R code\u0026rdquo; 文件列表详见[链接](\u0026ldquo;http://rfunction.com/code/1202/\u0026quot;)\n此处批量获取下载链接的方法引用 COS论坛 上 谢益辉 的帖子:链接\n# 批量获取链接 library(XML) listLinks = function (URL, pattern = \u0026quot;\u0026quot;, relative = FALSE) { doc = htmlParse(URL) if (is.null(grep(\u0026quot;/$\u0026quot;, URL))) URL = dirname(URL) nodes = getNodeSet(doc, \u0026quot;//a[@href]\u0026quot;) hrefs = sapply(nodes, function(x) xmlGetAttr(x, \u0026quot;href\u0026quot;)) paste(if (relative) \u0026quot;\u0026quot; else URL, hrefs[grep(pattern, hrefs)], sep = \u0026quot;\u0026quot;) } url \u0026lt;- \u0026quot;http://rfunction.com/code/1202/\u0026quot; Rfiles \u0026lt;- listLinks(url, pattern=\u0026quot;\\\\.R$\u0026quot;) destDir \u0026lt;- tempdir() # 批量下载文档 for(i in Rfiles) download.file(i, file.path(destDir, basename(i))) 顺利下载所有R文档\ntrying URL 'http://rfunction.com/code/1202/120201.R' Content type 'text/plain' length 1726 bytes opened URL downloaded 1726 bytes ... 最后,再引用 谢益辉 在COS论坛上介绍的方法,获取多级目录下的文件链接,并下载。\nlibrary(XML) downloadSite = function(URL, web.ext = c(\u0026quot;html\u0026quot;, \u0026quot;shtml\u0026quot;), pattern = \u0026quot;\u0026quot;, verbose = getOption(\u0026quot;verbose\u0026quot;)) { web.rec = tempfile() writeLines(URL, web.rec) # top directory URL.top = if (length(grep(\u0026quot;/$\u0026quot;, URL))) URL else paste(dirname(URL), \u0026quot;/\u0026quot;, sep = \u0026quot;\u0026quot;) fullInfoErrorHandler = function(msg, code, domain, line, col, level, file) { # level tells how significant the error is # These are 0, 1, 2, 3 for WARNING, ERROR, FATAL # meaning simple warning, recoverable error and fatal/unrecoverable error. # See XML:::xmlErrorLevel # # code is an error code, See the values in XML:::xmlParserErrors # XML_HTML_UNKNOWN_TAG, XML_ERR_DOCUMENT_EMPTY # # domain tells what part of the library raised this error. # See XML:::xmlErrorDomain codeMsg = switch(level, \u0026quot;warning\u0026quot;, \u0026quot;recoverable error\u0026quot;, \u0026quot;fatal error\u0026quot;) if (verbose) message(\u0026quot;(!)There was a \u0026quot;, codeMsg, \u0026quot; at line \u0026quot;, line, \u0026quot; column \u0026quot;, col, \u0026quot;\\n(!)\u0026quot;, msg, appendLF = FALSE) } listLinks = function(URL, web.ext = web.ext, pattern = pattern) { if (verbose) timestamp() URL.dir = if (length(grep(\u0026quot;/$\u0026quot;, URL))) URL else paste(dirname(URL), \u0026quot;/\u0026quot;, sep = \u0026quot;\u0026quot;) if (verbose) message(\u0026quot;Parsing \u0026quot;, URL) if (inherits(try(con \u0026lt;- url(URL, open = \u0026quot;r\u0026quot;)), \u0026quot;try-error\u0026quot;)) { if (verbose) message(\u0026quot;Found an invalid link: \u0026quot;, URL, \u0026quot;\\n\u0026quot;) return(NULL) } else { close(con) doc = htmlParse(URL, error = fullInfoErrorHandler) nodes = getNodeSet(doc, \u0026quot;//a[@href]\u0026quot;) # all links hrefs = sapply(sapply(nodes, function(x) xmlGetAttr(x, \u0026quot;href\u0026quot;)), URLdecode) if (verbose) message(\u0026quot;Found \u0026quot;, length(hrefs), \u0026quot; links in total...\u0026quot;) hrefs = gsub(\u0026quot;^[[:space:]]+|[[:space:]]+$\u0026quot;, \u0026quot;\u0026quot;, hrefs, useBytes = TRUE) # links to top URL hrefs = sub(\u0026quot;^/\u0026quot;, URL.top, hrefs, useBytes = TRUE) # remove links to other domains hrefs = hrefs[!(substr(hrefs, 1, 7) == \u0026quot;http://\u0026quot; \u0026amp; substr(hrefs, 1, nchar(URL.top)) != URL.top)] if (verbose) message(length(hrefs), \u0026quot; link(s) within the domain...\u0026quot;) # remove email links if (length(mail.idx \u0026lt;- grep(\u0026quot;mailto.*@.*\\\\..*\u0026quot;, hrefs, useBytes = TRUE))) hrefs = hrefs[-mail.idx] if (verbose) message(length(hrefs), \u0026quot; link(s) left when I removed email links...\u0026quot;) # get relative paths hrefs = gsub(URL.dir, \u0026quot;\u0026quot;, hrefs, fixed = TRUE, useBytes = TRUE) # match specified patterns hrefs = hrefs[grep(pattern, hrefs, useBytes = TRUE)] if (verbose) message(length(hrefs), \u0026quot; link(s) matched with the pattern \\\u0026quot;\u0026quot;, pattern, \u0026quot;\\\u0026quot;...\u0026quot;) # get absolute paths abs.hrefs = if (length(hrefs) == 0) NULL else { gsub(\u0026quot;\\\\.\\\\./\u0026quot;, \u0026quot;/\u0026quot;, paste(URL.dir, hrefs, sep = \u0026quot;\u0026quot;), useBytes = TRUE) } # find out links to web pages (*.html/shtml) web.idx = grep(paste(\u0026quot;\\\\.\u0026quot;, web.ext, \u0026quot;$\u0026quot;, sep = \u0026quot;\u0026quot;, collapse = \u0026quot;|\u0026quot;), hrefs, useBytes = TRUE) if (verbose) message(\u0026quot;Found \u0026quot;, length(web.idx), \u0026quot; further webpage links in the current page...\u0026quot;) old.rec = readLines(web.rec) web.addr = setdiff(abs.hrefs[web.idx], c(old.rec, \u0026quot;\u0026quot;)) cat(web.addr, file = web.rec, sep = \u0026quot;\\n\u0026quot;, append = TRUE) if (length(web.idx) == 0) { if (verbose) message(\u0026quot;No further webpage links can be found...\\n\u0026quot;) return(abs.hrefs) } else { if (verbose) { message(\u0026quot;I'll look for links in further pages...\\n\u0026quot;) flush.console() } return(c(abs.hrefs, unlist(sapply(web.addr, listLinks, web.ext = web.ext, pattern = pattern)))) } } } all.links = unique(c(URL, listLinks(URL, web.ext, pattern))) all.links } # 下载部分待续 options(verbose = TRUE) lnk = downloadSite(\u0026quot;http://www.public.iastate.edu/~pdixon/stat500/\u0026quot;) lnk = downloadSite(\u0026quot;http://www.public.iastate.edu/~dnett/S511/stat511.shtml\u0026quot;) # 不要拿太复杂的网站做测试,因为嵌套太深会让程序跑很长时间 "
},
{
"uri": "/webpage_001/2014-09-28-transform-genbank-to-fasta-using-biopython/",
"title": "使用BioPython将GenBank转换为Fasta格式",
"tags": ["Biopython"],
"description": "",
"content": " Converting GenBank files to FASTA format with Biopython\n1 Description This post will show how to extrat info from GenBank file using Biopython, and convert to FASTA file (nucleotide sequences and amino acid sequence).\n2 Purpose 1. Extract entire DNA sequence as on record.\n 2. Extract DNA sequences for each gene.\n 3. Extract amino acid sequences for each gene.\n 3 Materials Here I choose a small bacteria complete genome to show the method: Buchnera_aphidicola (NCBI NC_011833, GI:219681389). NCBI FTP site \n GenBank file: NC_011833.gbk (2251 kb)\n Genome FASTA File: NC_011833.fna (636 kb)\n Gene FASTA File: NC_011833.ffn (613 kb)\n Amino Acid File: NC_011833.faa (246 kb)\n 4 Methods \u0026amp; Results Using the module Bio.SeqIO to deal with genbank file.\n 1. Genome: GenBank -\u0026gt; FASTA\nConvert GenBank file to FASTA is simple:\n Option 1:\n\u0026gt;\u0026gt;\u0026gt; from Bio import SeqIO \u0026gt;\u0026gt;\u0026gt; SeqIO.convert(\u0026quot;NC_011833.gbk\u0026quot;, \u0026quot;genbank\u0026quot;, \u0026quot;NC_011833_cov.fna\u0026quot;, \u0026quot;fasta\u0026quot;) Option 2:\nimport Bio.SeqIO gbk_file = \u0026quot;NC_011833.gbk\u0026quot; fna_file = \u0026quot;NC_011833_cov.fna\u0026quot; input = open(gbk_file, \u0026quot;r\u0026quot;) output = open(fna_file, \u0026quot;w\u0026quot;) for seq in SeqIO.parse(input, \u0026quot;genbank\u0026quot;) : print \u0026quot;Convert %s from GenBank to FASTA format\u0026quot; % seq.id output.write(\u0026quot;\u0026gt;%s %s\\n%s\\n\u0026quot; % ( seq.id, seq.description, seq.seq)) input.close() output.close() This strain contains only one chromosome, so we can get one sequence using above code.\n 2. Protein AA: GenBank -\u0026gt; FASTA Extract the sequences of each coding sequences and convert to FASTA format.\nWe can use features to extract different information in GenBank file. import Bio.SeqIO gbk_file = \u0026quot;NC_011833.gbk\u0026quot; fna_file = \u0026quot;NC_011833_cov.fna\u0026quot; faa_file = \u0026quot;NC_011833_cov.faa\u0026quot; input = open(gbk_file, \u0026quot;r\u0026quot;) geneNC = open(fna_file, \u0026quot;w\u0026quot;) geneAA = open(faa_file, \u0026quot;w\u0026quot;) for seq in SeqIO.parse(input, \u0026quot;genbank\u0026quot;) : print \u0026quot;Dealing with GenBank file of %s, \\nOutput: \\ngene nc: %s \\ngene aa: %s\u0026quot; % ( seq.id, fna_file, faa_file) for seq_feature in seq.features : geneSeq = seq_feature.extract(seq.seq) if seq_feature.type == \u0026quot;CDS\u0026quot; : assert len(seq_feature.qualifiers['translation']) == 1 geneAA.write(\u0026quot;\u0026gt;%s %s, %s\\n%s\\n\u0026quot; % ( seq_feature.qualifiers['locus_tag'][0], seq.name, seq.description, seq_feature.qualifiers['translation'][0])) geneNC.write(\u0026quot;\u0026gt;%s %s, %s\\n%s\\n\u0026quot; % ( seq_feature.qualifiers['locus_tag'][0], seq.name, seq.description, geneSeq )) input.close() geneNC.close() geneAA.close() The result will contain FASTA record of each CDSin each GenBank record.\nNote: Not all CDS features of GenBank file contain translation. I think we can extract the sequences of each gene, and translate them to amino acid sequences.\n 3. Gene : GenBank -\u0026gt; FASTA We will use seq.extract() to get sequence. import Bio.SeqIO gbk_file = \u0026quot;NC_011833.gbk\u0026quot; fna_file = \u0026quot;NC_011833_cov.fna\u0026quot; faa_file = \u0026quot;NC_011833_cov.faa\u0026quot; input = open(gbk_file, \u0026quot;r\u0026quot;) geneNC = open(fna_file, \u0026quot;w\u0026quot;) geneAA = open(faa_file, \u0026quot;w\u0026quot;) for seq in SeqIO.parse(input, \u0026quot;genbank\u0026quot;) : print \u0026quot;Dealing with GenBank file of %s, \\nOutput: \\ngene nc: %s \\ngene aa: %s\u0026quot; % ( seq.id, fna_file, faa_file) for seq_feature in seq.features : geneSeq = seq_feature.extract(seq.seq) if seq_feature.type == \u0026quot;CDS\u0026quot; : assert len(seq_feature.qualifiers['translation']) == 1 geneNC.write(\u0026quot;\u0026gt;%s %s, %s\\n%s\\n\u0026quot; % ( seq_feature.qualifiers['locus_tag'][0], seq.name, seq.description, geneSeq )) input.close() geneNC.close() geneAA.close() Expand\n Learn Biopython Bio.SeqIO usage:\n 1. Peter cock, http://www2.warwick.ac.uk/fac/sci/moac/people/students/peter_cock/python/genbank2fasta/\n 2. Biopython cookbook, http://biopython.org/DIST/docs/tutorial/Tutorial.html\n "
},
{
"uri": "/webpage_001/2014-09-23-mobaxterm-permissions-0660-for-id_rsa-are-too-open/",
"title": "MobaXterm: Permissions 0660 for 'id_rsa' are too open",
"tags": ["Mobaxterm"],
"description": "",
"content": " Environment: MS Windows 8.1\n Cygwin 64bit\n ssh keys copied from somewhere and placed to ~/.ssh/ Problem: ssh -T git@github.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0660 for \u0026lsquo;~/.ssh/id_rsa\u0026rsquo; are too open.\nIt is required that your private key files are NOT accessible by others.\nThis private key will be ignored.\nbad permissions: ignore key: ~/.ssh/id_rsa\nDid not work: chmod 600 id_rsa\n chmod 700 .ssh\n Playing with Windows security panels\n Setting group to SYSTEM\n Everything else\n Solution: Found on Vineet Gupta\u0026rsquo;s blog http://vineetgupta.com/blog/cygwin-permissions-bug-on-windows-8\nchgrp Users id_rsa chmod 600 id_rsa Now, it works!\n"
},
{
"uri": "/webpage_001/2014-09-22-configuration-git-ssh/",
"title": "使用SSH管理Git",
"tags": ["SSH"],
"description": "",
"content": " Start Github and using Git SSH\n Create a Github account Go to Github and create your account.\n Download Git bash tool\n Download Git bash for windows on Git-scm.\n Install the Git-1.9.4-preview20140611.exe using default settings.\n Configure the SSH connection with remote github\n Start the Git Bash and create SSH keys\n ssh-keygen -t rsa -C \u0026quot;wangmcas@gmail.com\u0026quot; Create privite and public keys for the Email account\n Record the file id_rsa.pub in direcotry .ssh Setting the Github website\n Account Settings -\u0026gt; SSH keys -\u0026gt; Add SSH key\n Paste the content of id_rsa.pub to the window.\n Setting the local git\n Run the following command lines\n git config --global user.email \u0026quot;wangmcas@gmail.com\u0026quot; git config --global user.name \u0026quot;bakerwm\u0026quot; Test your SSH connection to github\n ssh -T git@github.com How to use Git Bash? Options 1: Upload local files to Github web repo Create an empty repo on Github website: [eg: test-temp]\n Initiate the git bash\n git init \\\\ Move your files to the current directory git add \u0026lt;your files\u0026gt; git commit -m 'Initial my project' git remote add origin git@github.com:bakerwm/test-temp.git git push -u origin master Options 2: Clone a Web repo to local PC Record the name of web repo: [eg: hello]\n Clone the web repo to local PC and update your files\n git clone git@github.com:bakerwm/hello.git #Create local files git add \u0026lt;local files\u0026gt; git commit -m 'add new files' git push Options 3: Update my local files cd to your directory\n update your files to web repo\n git add \u0026lt;your files\u0026gt; git commit -m 'update files' git push origin master Options 4: git pull Just try the following command:\ngit pull Create simple Gitpages Create a repo in your github website: \u0026ldquo;3Kings4Food\u0026rdquo; Clone the repo to your local PC Create a special Github Pages branch git checkout --orphan gh-pages It will create a new branch, and saying Switched to a new branch \u0026lsquo;gh-pages\u0026rsquo;\ngit checkout gh-pages It will check whether you are in the branch \u0026ldquo;gh-pages\u0026rdquo;\n push your files to the new branch for the first time\n git add files git commit -m 'update my files' git push --set-upstream origin gh-pages You can view your page at: http://bakerwm.github.io/3Kings4Food\nUse HTTP to access the website, NOT HPPTS.\n Some useful guides for creating Gitpages:\n* 1. http://www.thinkful.com/learn/a-guide-to-using-github-pages/\n* 2. http://24ways.org/2013/get-started-with-github-pages/\n"
},
{
"uri": "/webpage_001/2014-09-21-manage-multiple-account-on-github/",
"title": "管理多个Github账号",
"tags": ["github"],
"description": "",
"content": " Q: How can we manage multiple Github IDs on one PC?\nA: As far as I can see, add a file config to the dir ~/.ssh/ can solve it.\n 1 . Change your settings 1 . First of all, you have two Github IDs (ie: A \u0026amp; B).\n2 . Create the SSH rsa keys for both of the IDs.\n## For A ssh-keygen -t rsa -C \u0026quot;A_mail@gmail.com\u0026quot; ## save the key to file ~/.ssh/id_rsa_A ## For B ssh-keygen -t rsa -C \u0026quot;B_mail@gmail.com\u0026quot; ## sage the key to file ~/.ssh/id_rsa_B 3 . Config your Github account settings\nLog in Github use one of your ID (A), and go to settings -\u0026gt; SSH keys -\u0026gt; Add SSH key, then add the content of file ~/.ssh/id_rsa_A.pub to the blank.\nThe content like this:\nssh-rsa AAAABBBBCCCCDDDD... == A_mail@gmail.com Change your ID (B) on Github and repeat above steps to add keys to Github.\n4 . Create config in ~/.ssh/\n Create a empty file config in your dir ~/.ssh/\n Add the following content to config\n # account A Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa_A # account B Host B.github.com ## you can change `B` to your favorite word HostName github.com User git IdentityFile ~/.ssh/id_rsa_B 2 . Test your settings $ssh -T git@github.com Hi **A**! You’ve successfully authenticated, but GitHub does not provide shell access. $ssh -T git@B.github.com Hi **B**! You’ve successfully authenticated, but GitHub does not provide shell access. A and B will differ in your test depends on your names of the Github accounts.\n3 . Examples 1 . clone a git A to local using account A.\ngit clone git@github.com:A_name/A.git 2 . clone a git B to local using account B.\ngit clone git@B.github.com:B_name/B.git 4 . Last Using git@B.github.com instead of git@github.com to manage your files on B account.\n"
},
{
"uri": "/webpage_001/2014-09-20-jekyll+github/",
"title": "jekyll+Github",
"tags": ["github"],
"description": "",
"content": " 1.Using Jekyll + Github We need Ruby and Jekyll. You can find more details here @ http://jekyllrb.com/docs/windows/\n Install Ruby Get Ruby for windows, download (X86/X64) for your system. Install the Ruby at the default PATH, and choose the option: Add Ruby executables to your PATH.\n Install Ruby DevKit Get Ruby DevKit. Install it at default PATH, like: \u0026ldquo;C:\\RubyDevKit\\\u0026rdquo;\n Open your windows console to finish the following steps.\n Go to the RubyDevKit folder\n cd C:\\RubyDevKit\\ ## Auto-detect Ruby installations and add them to configuration file ruby dk.rb init ## Intall DevKit, binding it to Ruby installation ruby dk.rb install Now, you have Ruby installed on your PC and you can build fully functional executables using Ruby Development Kit. Ruby includes a way to install so-called gems-software packages from the command line.\n Install the Jekyll Gem\n Jekyll comes in the form of Ruby Gem, which is an easy-to-install software package. Open your windows console and execute the following commands.\n gem install jekyll it will take a while to finish the installaion.\n Highlight your code\n By default, Jekyll comes with pygments.rb, which is a syntax highlighter based on Python. To use it on Windows, you\u0026rsquo;ll need to intall Python and some extra tools.\nA nice alternative is the Ruby-based Rouge, which is faster and easier to install, but doesn\u0026rsquo;t support as many languages as Pygments.\n Install Rouge\nQuick and Pinless: open your console and enter the following command.\n gem install rouge \nThen, in your _config.yml, set Rouge as your syntax highlighter, add the following line the the file:\n highlighter: rouge \n Done!\n Make Pygments work\n If you want to use Pygments for syntax highlighting on Windows, you need to install Python, pip and finally the Python base of pygments.rb.\n* Install Python The latest working version of Python at the time of writing is v2.7.8. Python 3 will not work.\nDownload Python v2.7 Download Python\nExecute the downloaded file and make sure to click on the box next to Add python.exe to Path and select \u0026ldquo;Entire feature will be intalled on local hard drive\u0026rdquo;.\n* Install pip Pip is a tool for installing and managing Python packages, similar to Ruby Gems.\nDownload get-pip.py via the link on that site: Download pip\nNext, open your console and go to the folder where the get-pip.py is. (e.g., c:\\pip)\n cd C:\\pip Then, run the following command to automatically download and intall all required components.\n python get-pip.py * Install Python base of Pygments From the command line, run the following command to install the Python base of Pygments.\n pip install Pygments * Set Pygments as your syntax highlighter Add the following line to your _config.yml file, which will set your syntax highlighter.\n highlighter: pygments Summary\nJekyll will now use the highlighter you choose to make all your code blocks look super sleek. We\u0026rsquo;re almost finished. Let Jekyll \u0026ndash;watch Install the wdm Gem\nYou can instruct Jekyll to have an eye out for changed files to automatically rebuild your site whenever you make changes in the source. On Windows, you need to install one extra tool, or rather Gem, to enable this functionality. Simply run the following command from the command line.\n gem install wdm \n Require wdm in your Gemfile Alternatively, if you use a Gemfile, you can check if Jekyll runs on Windows and only then install the wdm Gem.\n require 'rbconfig' gem 'wdm', '~\u0026gt; 0.1.0' if Rbconfig::CONFIG['target_os'] =~ /mswin|mingw/i \n Summary\nYou\u0026rsquo;ve now installed everything you need to run Jekyll on Windows. The following minor things can make sure that your sites build smoothy and without problems. Run Jekyll without errors No BOM allowed\nIf there are BOM (Byte order marker) header characters in your UTF-8-encoded files, Jekyll will break. Make sure ther are NONE.\n Set your encoding to UTF-8\nIf you followed this guide step by step or if your versions match the ones in this guide, you shouldn\u0026rsquo;t need to use any of the following fixes.\n Set encoding option In your _config.yml file, add the following line:\n encoding: utf-8 \n Change console encoding\nAlternatively, you can change your command line tool\u0026rsquo;s encoding to UTF-8 by running the following command every time you open a new console window.\n chcp 65001 \n The End\n jekyll build jekyll build --watch jekyll build -w jekyll serve jekyll serve --watch jekyll serve -w \nYou can now run all of the above commands on your Windows machine. Congratulations! You have successfully set up Jekyll on Windows. There are several way to get help if you find the above instruction is not clear.\n Look if somebody else noticed it\n File a new issue to Github\n Visit official Jekyll website Jekyll \u0026amp; GitHub Pages\nJekyll-bootstrap quick-start Using Jekyll and GitHub Pages for Our Site\nCreate blog using Jekyll, Github Pages, and poole\nGet Started with Github Pages\n"
},
{
"uri": "/webpage_001/2014-09-20-manage-github-pages/",
"title": "创建Github blogs",
"tags": ["github"],
"description": "",
"content": " Q: Can we publish blogs using Github?\nA: Yes.\n 1. Why Github pages? Jekyll + Github can manage a Static webpage.\n Easy to manage your pages using git command.\n Also support your own domain.\n 2. What tools you need? git tools: http://windows.github.com\n jekyll followning @Julian Thilo\u0026rsquo;s instructions. 3. Start using pages Create pages for your project\n using gh-pages branch\n username.github.com/reponame Goto the settings page of your repo, and you can find Automatic page generator icon. Done.\n Generate Github pages for your own.\n have to use the name of the account.\n Only one \u0026ldquo;URL\u0026rdquo; for one Github account. name.github.com Useful links\nSuppose you are familiar with the Github, can using push and pull commands. Also you can find more details here 1 \u0026amp; here 2\n=================================\nCreate User Pages 1. Create a repo project Create a repo named \u0026ldquo;username\u0026rdquo; on github web site, and choose option: \u0026ldquo;initialize this repository with a README\u0026rdquo;\n Clone the repo to your local PC\n git clone git@github.com:username/project cd username/ git checkout --orphan gh-pages We\u0026rsquo;ll get a message saying **Switching to a new branch \u0026lsquo;gh-pages\u0026rsquo; * Make the gh-pages as the default branch\nMake a Page Create a file called index.html in project folder\n This is a demo for GitHub Pages. \n Then commit and push our changes\n git add --all . git commit -m 'test page' git push \n Done, the first page You can find the page at: http://bakerwm.github.io/MingDemo\n"
},
{
"uri": "/webpage_001/2014-09-19-manage-blog-on-github/",
"title": "在Github上管理个人blog",
"tags": ["github"],
"description": "",
"content": "This tutorial will teach you to create a blog on github step-by-step.\nMainly, 3 parts will included.\n1 Create your blog using Jekyll-bootstrap. (see Site)\n2 Change the theme. (see [Site]())\n3 Write your post. (see [Site]())\nMost of the following content come from Jekyll-bootstrap quick-start\nHere will show you step-by-step:\n1. Create your blog using Jekyll-bootstrap\n*Create a new repo on github: bakerwm.github.com (your username)\n*Install Jekyll-Bootstrap\nEnter these commands into your git terminal\ngit clone https://github.com/plusjade/jekyll-bootstrap.git USERNAME.github.com cd USERNAME.github.com git remote set-url origin git@github.com:USERNAME/USERNAME.github.com.git git push origin master *Profit\nAfter a couple mintues your blog will be publicly available at http://bakerwm.github.com\n*Check your blog locally Go to your local directory, and run the following commands\njekyll serve You need to install Jekyll on windows first.\n2. Change the theme\nInstall a theme by the url\nrake theme:install git=\u0026quot;https://github.com/jekllbootstrap/theme-the-program.git\u0026quot; Or download the zip file to ./_theme_packages,\nrake theme:install name=\u0026quot;Theme-name Switch themes\nrake theme:switch name name=\u0026quot;the-program\u0026quot; 3. Create a Post\nUsing rake to create post\nrake post title=\u0026quot;Hello-World\u0026quot; The rake task will automatically creates a file with properly formatted filename and YAML Front Matter in _post directory.\nCreate a Page:\nrake page name=\u0026quot;about.md\u0026quot; Create a nested page:\nrake page name=\u0026quot;pages/about.md\u0026quot; Create a page with a \u0026ldquo;pretty\u0026rdquo; path:\nrake page name=\u0026quot;pages/about\u0026quot; *# this will create a file: ./pages/about/index.html* Publish your blog:\ngit add . git commit -m \u0026quot;Add new content\u0026quot; git push origin master This will automatically deploy your changes to your hosted blog.\n"
},
{
"uri": "/webpage_001/2014-09-10-r-read-compressed-files/",
"title": "R语言读取压缩文档",
"tags": ["R"],
"description": "",
"content": " 使用R语言进行数据分析时,经常需要读取文档,经常会遇到压缩文档(.bz2, .gz)。\nGoal: Special cases in reading files Reading a *.bz2 file\nread.table(bzfile(\u0026quot;file.text.bz2\u0026quot;)) Reading a .gz file\nread.table(gzfile(\u0026quot;file.text.gz\u0026quot;)) Reading from a pipe\nmydata \u0026lt;- read.table(pipe(\u0026quot;awk -f filter.awk input.txt\u0026quot;)) # under Linux system Reading from a URL\nread.table(url(\u0026quot;http://www.mayin.org/ajayshah/A/demo.text\u0026quot;)) Reading from a URL directly\nread.table(\u0026quot;http://www.mayin.org/ajayshah/A/demo.text\u0026quot;) Reading a bz2 file from URL\nread.table(pipe(\u0026quot;links -source http://www.mayin.org/ajayshah/A/demo.text.bz2 | bunzip2\u0026quot;)) Reading binary files from a URL\nload(url(\u0026quot;http://www.mayin.org/ajayshah/A/nifty_weekly_returns.rda\u0026quot;)) source: http://www.mayin.org/ajayshah/KB/R/html/r8.html\n"
},
{
"uri": "/webpage_001/2014-08-27-questions-about-using-rcurl/",
"title": "RCurl的问题",
"tags": ["R", "RCurl"],
"description": "",
"content": " 最近学习 炼数成金 的网络课程 《R七种武器之网络爬虫RCurl》,对HTML完全不懂,从头学起。\n首先举个例子,利用RCurl取得网页信息。\nlibrary(RCurl) library(XML) url \u0026lt;- \u0026quot;http://tuan.baidu.com/movie\u0026quot; doc \u0026lt;- htmlTreeParse(url, useInternal=TRUE) tgComp \u0026lt;- getNodeSet(doc, \u0026quot;//a[@class='n-sitename']\u0026quot;) tgTitle \u0026lt;- getNodeSet(doc, \u0026quot;//div[@class='good-n-meta clearfix']\u0026quot;) tgPrice \u0026lt;- getNodeSet(doc, \u0026quot;//div[@class='good-n-price']\u0026quot;) ##提取相应数值 Comp \u0026lt;- iconv(xmlSApply(tgComp, xmlValue), from=\u0026quot;utf-8\u0026quot;, to=\u0026quot;\u0026quot;) Title \u0026lt;- iconv(xmlSApply(tgTitle, xmlValue), from=\u0026quot;utf-8\u0026quot;, to=\u0026quot;\u0026quot;) Price \u0026lt;- iconv(xmlSApply(tgPrice, xmlValue), from=\u0026quot;utf-8\u0026quot;, to=\u0026quot;\u0026quot;) #Delete ¥, 折等 Price \u0026lt;- gsub(\u0026quot;[^0-9. ]\u0026quot;, \u0026quot;\u0026quot;, Price) #分别提取价格等 temp \u0026lt;- sapply(Price, function(x) strsplit(x, split=\u0026quot;\\\\s+\u0026quot;, perl=TRUE)) Table \u0026lt;- do.call(rbind.data.frame, temp) #制作data.frame colnames(Table) \u0026lt;- c(\u0026quot;Blank\u0026quot;, \u0026quot;Price\u0026quot;, \u0026quot;Pre-Price\u0026quot;, \u0026quot;Discount\u0026quot;) rownames(Table) \u0026lt;- 1:nrow(Table) Table$Title \u0026lt;- Title Table$Company \u0026lt;- Comp Table$Blank \u0026lt;- NULL Table \u0026lt;- Table[c(5, 4, 1, 2, 3)] Table \u0026lt;- sapply(Table, function(x) gsub(\u0026quot;^\\\\s+|\\\\s+$\u0026quot;, \u0026quot;\u0026quot;, x)) colnames(Table) \u0026lt;- c(\u0026quot;团购网\u0026quot;, \u0026quot;团购名称\u0026quot;, \u0026quot;团购价\u0026quot;, \u0026quot;原价\u0026quot;, \u0026quot;折扣\u0026quot;) head(Table) 团购信息前几条如下:\n团购网 [1,] \u0026quot;百度糯米\u0026quot; [2,] \u0026quot;百度糯米\u0026quot; [3,] \u0026quot;百度糯米\u0026quot; [4,] \u0026quot;百度糯米\u0026quot; [5,] \u0026quot;百度糯米\u0026quot; [6,] \u0026quot;百度糯米\u0026quot; 团购名称 [1,] \u0026quot;[兜有电子商务]单人3D影票!奢华进口设备,震撼视听享受,刺激你的眼球!\u0026quot; [2,] \u0026quot;[博纳国际影城]顺义店单人影票(含3D)!全场通兑!豪华影音设备,国内外大片随心看!节假日通用!\u0026quot; [3,] \u0026quot;[耀莱成龙国际影城]慈云寺店双人影票(含3D)!盛大开业,劲爆超低价疯狂来袭,不补差价\u0026quot; [4,] \u0026quot;[通州区电影院]单人影票(含3D)!大片连连上映,精彩不容错过,期待您的到来,节假日通用!\u0026quot; [5,] \u0026quot;[魔幻岛5D影院]4人观影套票!无需预约,多人套票更超值!惊险刺激的现场画面,如亲临现场!\u0026quot; [6,] \u0026quot;[网票网]3D电影票1张!精彩大片轮番演绎,震撼银幕效果,超值享受!\u0026quot; 团购价 原价 折扣 [1,] \u0026quot;61.5\u0026quot; \u0026quot;120\u0026quot; \u0026quot;5.1\u0026quot; [2,] \u0026quot;35\u0026quot; \u0026quot;100\u0026quot; \u0026quot;3.5\u0026quot; [3,] \u0026quot;49\u0026quot; \u0026quot;160\u0026quot; \u0026quot;3.1\u0026quot; [4,] \u0026quot;26.5\u0026quot; \u0026quot;80\u0026quot; \u0026quot;3.3\u0026quot; [5,] \u0026quot;56\u0026quot; \u0026quot;120\u0026quot; \u0026quot;4.7\u0026quot; [6,] \u0026quot;62\u0026quot; \u0026quot;120\u0026quot; \u0026quot;5.2\u0026quot; 总结几个问题: 保存html页面后用XML处理,使用参数: useInternal=TRUE\n 部分中文网页遇到乱码是,可使用 iconv()进行处理,\n (原理未知。 )\n#中文乱码情况 xmlValue(tgComp[[1]]) [1] \u0026quot; 鐧惧害绯背 \u0026quot; #转换后即可正常显示中文 iconv(xmlValue(tgComp[[1]]), from=\u0026quot;utf-8\u0026quot;, to=\u0026quot;\u0026quot;) [1] \u0026quot; 百度糯米 \u0026quot; 对htmlTreeParse()进行指定encoding操作也无法获取正确的中文编码,如:GBK,GB2312\n sapply()函数\n 在此处的应用可对变量连续进行某一公式计算。\np \u0026lt;- iconv(xmlSApply(tgPrice, xmlValue), from=\u0026quot;utf-8\u0026quot;, to=\u0026quot;\u0026quot;) p[1] [1] \u0026quot; ¥61.5 ¥120 5.1折 \u0026quot; p1 \u0026lt;- sapply(p, function(x) strsplit(x, split=\u0026quot;\\\\s+\u0026quot;, perl=TRUE)) p1[[1]] [1] \u0026quot;\u0026quot; \u0026quot;¥61.5\u0026quot; \u0026quot;¥120\u0026quot; \u0026quot;5.1折\u0026quot; 将\u0026rdquo;character\u0026rdquo;分割后,得到的变量类型为\u0026rdquo;list\u0026rdquo;。\n R数据类型转换:list -\u0026gt; data.frame\n 此处使用rbind函数进行操作。\np2 \u0026lt;- do.call(rbind.data.frame, p1) head(p2) 转换后的结果如下\n\tc............................................................. ¥61.5 ¥120 5.1折 ¥35 ¥100 3.5折 ¥49 ¥160 3.1折 ¥26.5 ¥80 3.3折 ¥56 ¥120 4.7折 ¥62 ¥120 5.2折 c...61.5.....35.....49.....26.5.....56.....62.....88... ¥61.5 ¥120 5.1折 ¥61.5 ¥35 ¥100 3.5折 ¥35 ¥49 ¥160 3.1折 ¥49 ¥26.5 ¥80 3.3折 ¥26.5 ¥56 ¥120 4.7折 ¥56 ¥62 ¥120 5.2折 ¥62 c...120.....100.....160.....80.....120.....120.....150... ¥61.5 ¥120 5.1折 ¥120 ¥35 ¥100 3.5折 ¥100 ¥49 ¥160 3.1折 ¥160 ¥26.5 ¥80 3.3折 ¥80 ¥56 ¥120 4.7折 ¥120 ¥62 ¥120 5.2折 ¥120 c..5.1折....3.5折....3.1折....3.3折....4.7折....5.2折....5.9折... ¥61.5 ¥120 5.1折 5.1折 ¥35 ¥100 3.5折 3.5折 ¥49 ¥160 3.1折 3.1折 ¥26.5 ¥80 3.3折 3.3折 ¥56 ¥120 4.7折 4.7折 ¥62 ¥120 5.2折 5.2折 "
},
{
"uri": "/_footer/",
"title": "footer",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/_header/",
"title": "header",
"tags": [],
"description": "",
"content": "Bio M\n"
},
{
"uri": "/tags/api/",
"title": "Api",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/bacteria/",
"title": "Bacteria",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/bashrc/",
"title": "Bashrc",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/bioinfomatics/",
"title": "Bioinfomatics",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/biopython/",
"title": "Biopython",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/categories/",
"title": "Categories",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/ensembl/",
"title": "Ensembl",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/eob/",
"title": "Eob",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/failed/",
"title": "Failed",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/ggplot2/",
"title": "Ggplot2",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/git/",
"title": "Git",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/github/",
"title": "Github",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/go/",
"title": "Go",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/jekyll/",
"title": "Jekyll",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/kegg/",
"title": "Kegg",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/license/",
"title": "License",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/mirrors/",
"title": "Mirrors",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/mobaxterm/",
"title": "Mobaxterm",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/network/",
"title": "Network",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/python/",
"title": "Python",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/qa/",
"title": "Qa",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/r/",
"title": "R",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/rcurl/",
"title": "Rcurl",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/remote/",
"title": "Remote",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/rnaseq/",
"title": "Rnaseq",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/small-rnas/",
"title": "Small Rnas",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/ssh/",
"title": "Ssh",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/",
"title": "Tags",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/ubuntu/",
"title": "Ubuntu",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "/tags/virtualbox/",
"title": "Virtualbox",
"tags": [],
"description": "",
"content": ""
}]