分页: 1 / 1

求解释代码

发表于 : 2011-11-06 18:56
youbatu
我是刚搞生物信息的 什么都不懂 这是一段将.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";

Re: 求解释代码

发表于 : 2011-11-06 19:20
cuihao
虽然不会perl,但强烈建议LZ加缩进。

代码: 全选

[code]代码
[/code]

Re: 求解释代码

发表于 : 2011-11-07 15:44
ChenFengyuan
看到在用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.

Re: 求解释代码

发表于 : 2011-11-15 21:20
tangboyun
这段代码我如果没弄错的话,应该是将序列转为大写,然后计数序列数的,一般.seq就是fasta格式的。而fasta也并不强制大小写规范。

不过这代码写的很那啥,对输入做了太多假设。因为fasta格式只保证序列头一定是在一行内并以回车结束的,但并没有保证序列数据本身一定是在一行的。具体可以参考Fasta格式的Wiki页。一般数序列,还是直接计数'>'或者'#'起始的行数比较有保证的。

另:刚入行的话,推荐两本《Beginning Perl For Bioinformatics》《Learning Perl》

Re: 求解释代码

发表于 : 2011-11-15 22:50
xw_y_am
ee大神何在???

Re: 求解释代码

发表于 : 2011-11-16 10:04
eexpress
学术的,找 ChenFengyuan

我只实用主义。你要啥功能,如果适合的,我写出来。

Re: 求解释代码

发表于 : 2011-11-16 14:42
xiaoyafeng
这是谁写的? 写得也太烂了吧?