+ -
当前位置:首页 → 问答吧 → perl生物信息高手来围观了啊。

perl生物信息高手来围观了啊。

时间:2011-03-22

来源:互联网

本帖最后由 aids260 于 2011-03-22 08:58 编辑

use strict;
use warnings;

use Bio::SeqIO;
open(FH,">>reverse_exact_out.txt");


my $seqi = Bio::SeqIO->new(-file => 'exact_out.txt', -format=>'fasta');

while ( my $seq = $seqi->next_seq) {
my $id = $seq->id;
my $sseq=$seq->revcom ;
  print "$id\n";
  print FH "$sseq\n";    # This is what you need
  
}
close FH;   


高手帮我看下这个提取反向互补序列的程序问题出在哪里了啊???





文件附件里,将它反向输出,格式不变!请各位指点迷津!

t.rar (12.13 KB)

下载次数:11

2011-03-22 08:58

作者: aids260   发布时间: 2011-03-22

本人不是高手

$seq->revcom是干活的,建立一个新的object。
$sseq是它的引用,而不是序列阿...
再把序列提出来,程序内添加my $out=$sseq->seq;


#!/usr/bin/perl
use strict;
use warnings;

use Bio::SeqIO;
#use IO::String;
open(FH,">>reverse_exact_out.txt");


my $seqi = Bio::SeqIO->new(-file => 'exact_out.txt', -format=>'fasta');

while ( my $seq = $seqi->next_seq) {
my $id = $seq->id;
my $sseq=$seq->revcom;
my $out=$sseq->seq;
  print "$id\n";
  print FH "$out\n";
}
close FH;

作者: chenhao392   发布时间: 2011-03-22

本帖最后由 aef25u 于 2011-03-22 08:39 编辑

回复 aids260

以后兄弟问问题时能否将测试数据摘个片断做个附件发上来啊。没人会为了帮人再去找测试的数据的。也给想学perl生物信息处理的人一个方便。

作者: aef25u   发布时间: 2011-03-22

回复 aef25u


    好的,兄弟你说的很对!我记住了啊

作者: aids260   发布时间: 2011-03-22

楼上说的对,我还得自己找个fasta格式的文件测试...还好电脑里到处都是...

作者: chenhao392   发布时间: 2011-03-22

本帖最后由 chenhao392 于 2011-03-22 10:14 编辑

楼主,短消息看不见你的附件,另外,post出来这样大家都能看见,说不定对后人也有帮助..


楼主说,

2011-03-22

aids260 2011-03-22 09:00
你好,我输出之后格式都变了!  成了一行了
里边有很多行的
fasta格式,在附件里,麻烦帮我看看!



我回复:

这一行是不是很长啊?
你每隔多少个序列加个换行符,把它切了就是了.....



又及,
我看到附件了,可惜是rar格式的,ubuntu打不开。
想帮帮忙只是以前得到过许多人的帮助,现在有机会,回报CU一下而已,不带这样的,切个序列还要我写..
我吃晚饭去了...

作者: chenhao392   发布时间: 2011-03-22

本帖最后由 aef25u 于 2011-03-22 11:27 编辑

回复 aids260
001Rev.pl
  1. #!/usr/bin/perl
  2. use Bio::SeqIO;
  3. $in  = Bio::SeqIO->new(-format => 'fasta', -file =>'t.fa');
  4. $out = Bio::SeqIO->new(-format => 'fasta', -file =>'>out.fa');
  5.   while(my $seq = $in->next_seq) {
  6.      my $re_seq=$seq->revcom;
  7.      $out->write_seq($re_seq);
  8.   }
复制代码
002用命令行运行模式:perl 002Rev.pl fasta fasta t.fa >out.fa
002Rev.pl
  1. #!/usr/bin/perl
  2. my ( $format1, $format2, $fin ) = ( $ARGV[0], $ARGV[1], $ARGV[2] )
  3.   || die "[Usage: perl Rev.pl format1 format2  input >output]";

  4. use Bio::SeqIO;
  5. $in = Bio::SeqIO->new( -format => $format1, -file => $fin );
  6. $out = Bio::SeqIO->new( -format => $format2 );
  7. while ( my $seq = $in->next_seq ) {
  8.     my $re_seq = $seq->revcom;
  9.     $out->write_seq($re_seq);
  10. }
复制代码

作者: aef25u   发布时间: 2011-03-22

回复 chenhao392


    呵呵,不好意思不知道你用的是unbuntu.

作者: aids260   发布时间: 2011-03-22

回复 aids260
  1. #!/usr/bin/perl -w
  2. use strict;

  3. use Bio::Seq;
  4. use Bio::SeqIO;

  5. my $seq_obj=Bio::SeqIO->new(
  6.                 -file=>'t.fa',
  7.                 -format=>"fasta");

  8. my $out_obj=Bio::SeqIO->new(
  9.                 -format=>"fasta");

  10. while(my $seq=$seq_obj->next_seq){

  11.     my $out=Bio::Seq->new(
  12.             -display_id=>$seq->id,
  13.             -seq=> $seq->revcom->seq
  14.         );

  15.     $out_obj->write_seq($out);
  16. }
复制代码
perl recvom.pl >out.fa

作者: masylichu   发布时间: 2011-03-22