|||
举例:根据File:1文件中的名字提取File:2中同名的基因序列。
File:1 ####是一个基因名字的文件####
Ugene0073824
Ugene0113607
Ugene0047940
Ugene0082186
Ugene0112679
File:2 #### 是一个fasta 文件####
>Ugene0113607
AACGGTTAAAAAACAACTAAAAAGTTTTTCATTAGGTGTTTTTAAATTTCAAAAAAGGTC
ATCATTTTTAAGTTACCATTTTCTTTTTCTTTTAGAACTCAAAAGGCTGGTAGCTGAGAT
CGTCTTTCTCCGGTTTCCACATTGTTTTTGTTTTTCGCAGTTAATACAAGATGGCTGATG
GTGAGGATATTCAACCACTTGTCTGCGACAATGGAACTGGAATGGTCAAG
... ...
>Ugene0047939
GACATAAGATCCTTTTTTGCAATTACATTTAGTTTTTAAACTTCATAACTTGGAGTTATA
GCTTTATTTTATTTTCCCTTCTTCTTCTGGGTAAAATTGGTGTCATAGTTCTTTGGTTAA
TTTCATTAAGACTGCATCTGGTTTTTAACTTAAACTTCAAGTAACAGCAACCCTGTTGTC
AGGCACAAAATGACAAGGGATTTGA
>Ugene0047940
AACGGTTAAAAAACAACTAAAAAGTTTTTCATTAGGTGTTTTTAAATTTCAAAAAAGGTC
ATCATTTTTAAGTTACCATTTTCTTTTTCTTTTAGAACTCAAAAGGCTGGTAGCTGAGAT
CGTCTTTCTCCGGTTTCCACATTGTTTTTGTTTTTCGCAGTTAATACAAGATGGCTGATG
GTGAGGATATTCAACCACTTGTCTGCGACAATGGAACTGGAATGGTCAAG
>Ugene0000002
GACATAAGATCCTTTTTTGCAATTACATTTAGTTTTTAAACTTCATAACTTGGAGTTATA
GCTTTATTTTATTTTCCCTTCTTCTTCTGGGTAAAATTGGTGTCATAGTTCTTTGGTTAA
TTTCATTAAGACTGCATCTGGTTTTTAACTTAAACTTCAAGTAACAGCAACCCTGTTGTC
AGGCACAAAATGACAAGGGATTTGA
Perl program:####sequence.pl####
#!/usr/bin/perl -w
open $in1,"<File1" or die;
open $in2,"<File2" or die;
while($input1=<$in1>){
if($input1=~m/>(\w+)/) {$a=$1;}
$b{$a}.=$input1;
}
while($input2=<$in2>){
if ($input2=~m/(\w+)/){$d.=$b{$1};}
}
print "$d";
将该程序文件输入命令行中,如 $:sequence.pl > 路径out.txt 就可以得到结果。虽然写的很烂,但很实用。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-21 19:51
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社