我是刚搞生物信息的 什么都不懂 这是一段将.seq转化为.fasta的代码 有好心人帮我解释下吗?我地一句就看不懂了 @ARGV ,谢谢各位了
#! /usr/bin/perl
#function: transfer *.seq to *.fasta, and combine them.
#usage: perl ptransfer <input folder's pathway> <output filename>
#time: 2011-11-04
use strict;
use warnings;
if(@ARGV != 2){
print "warning!$!\nusage:perl ptransfer <input folder's pathway> <output filename> ";
}
my($dir,$out)=@ARGV;
open(OUT,">$out");
opendir(DH,"$dir");
my(@total,$i);
$i=0;
foreach (readdir DH){
$total[$i]=$_;
$i++;
}
closedir DH;
my($num,);
$num=0;
foreach(@total){
my($filename);
$filename=$_;
open(OR,"$dir/$filename");
$filename=substr($filename,0,-4);
while(<OR>){
my($line);
$line=$_;
chomp($line);
if($line=~/^[ATCG][ATCG]/i){
$line=uc($line);
print OUT ">$filename\n$line\n";
$num++;
}
}
close OR;
}
close OUT;
print "$num\nall done!\n";
求解释代码
- cuihao
- 帖子: 4793
- 注册时间: 2008-07-24 11:33
- 来自: 郑州
- 联系:
- ChenFengyuan
- 帖子: 770
- 注册时间: 2008-03-23 0:39
Re: 求解释代码
看到在用perl很高兴。
ARGV The special filehandle that iterates over command-line filenames in @ARGV. Usually written as the
null filehandle in the angle operator "<>". Note that currently "ARGV" only has its magical
effect within the "<>" operator; elsewhere it is just a plain filehandle corresponding to the
last file opened by "<>". In particular, passing "\*ARGV" as a parameter to a function that
expects a filehandle may not cause your function to automatically read the contents of all the
files in @ARGV.
ARGV The special filehandle that iterates over command-line filenames in @ARGV. Usually written as the
null filehandle in the angle operator "<>". Note that currently "ARGV" only has its magical
effect within the "<>" operator; elsewhere it is just a plain filehandle corresponding to the
last file opened by "<>". In particular, passing "\*ARGV" as a parameter to a function that
expects a filehandle may not cause your function to automatically read the contents of all the
files in @ARGV.
- tangboyun
- 帖子: 701
- 注册时间: 2009-07-25 1:57
- 联系:
Re: 求解释代码
这段代码我如果没弄错的话,应该是将序列转为大写,然后计数序列数的,一般.seq就是fasta格式的。而fasta也并不强制大小写规范。
不过这代码写的很那啥,对输入做了太多假设。因为fasta格式只保证序列头一定是在一行内并以回车结束的,但并没有保证序列数据本身一定是在一行的。具体可以参考Fasta格式的Wiki页。一般数序列,还是直接计数'>'或者'#'起始的行数比较有保证的。
另:刚入行的话,推荐两本《Beginning Perl For Bioinformatics》《Learning Perl》
不过这代码写的很那啥,对输入做了太多假设。因为fasta格式只保证序列头一定是在一行内并以回车结束的,但并没有保证序列数据本身一定是在一行的。具体可以参考Fasta格式的Wiki页。一般数序列,还是直接计数'>'或者'#'起始的行数比较有保证的。
另:刚入行的话,推荐两本《Beginning Perl For Bioinformatics》《Learning Perl》
https://github.com/tangboyun
http://tangboyun.is-programmer.com/
提问的智慧————Eric Steven Raymond
回答的智慧————Andrew Clarke
吾尝终日而思矣,不如须臾之所学也;吾尝跂而望矣,不如登高之博见也。
急急急标题什么的,最讨厌了!
急急复急急,急急何其多,我生待急急,万事急急急。
http://tangboyun.is-programmer.com/
提问的智慧————Eric Steven Raymond
回答的智慧————Andrew Clarke
吾尝终日而思矣,不如须臾之所学也;吾尝跂而望矣,不如登高之博见也。
急急急标题什么的,最讨厌了!
急急复急急,急急何其多,我生待急急,万事急急急。
- xw_y_am
- 帖子: 3333
- 注册时间: 2009-05-08 14:18
- 系统: Arch
- 来自: 河南新乡
- 联系:
Re: 求解释代码
ee大神何在???
Linux 相关链接大杂烩
代码: 全选
if(read) {
if(practise) return g☘☘d;
else return w☘☘d;
} else {
return t☘☘d;
}
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
-
- 帖子: 56
- 注册时间: 2009-10-13 22:58
Re: 求解释代码
这是谁写的? 写得也太烂了吧?