fasta-unique-names.txt
来自「EM算法的改进」· 文本 代码 · 共 124 行
TXT
124 行
#!@WHICHPERL@## $Id: fasta-unique-names.txt 1339 2006-09-21 19:46:28Z tbailey $# $Log$# Revision 1.1 2005/07/28 23:55:12 nadya# Initial revision### AUTHOR: Timothy L. Bailey# CREATE DATE: 3-22-99$PGM = $0; # name of program$PGM =~ s#.*/##; # remove part up to last slash@args = @ARGV; # arguments to program$| = 1; # flush after all prints$SIG{'INT'} = 'cleanup'; # interrupt handler# Note: so that interrupts work, always use for system calls:# if ($status = system($command)) {&cleanup($status)}# requirespush(@INC, split(":", $ENV{'PATH'})); # look in entire path# defaults$usage = <<USAGE; # usage message USAGE: $PGM [-r <name>] [-r <name>] read and replace named file Copy a FASTA sequence file changing any duplicate sequence names to insure there are no duplicates. This is done by appending "_i", where "i" is the copy number, to any names which are duplicates. Also replaces any cntrl-As with spaces. Reads standard input. Writes standard output. Copyright (1999) The Regents of the University of California. All Rights Reserved. Author: Timothy L. BaileyUSAGE$nargs = 0; # number of required argsif ($#ARGV+1 < $nargs) { &print_usage("$usage", 1); }# get input argumentswhile ($#ARGV >= 0) { $_ = shift; if ($_ eq "-h") { # help &print_usage("$usage", 0); } elsif ($_ eq "-r") { # replace $file = shift; } else { &print_usage("$usage", 1); }}# open input and outputif ($file) { $in = "$file"; $out = "$PGM.$$.tmp";} else { $in = "-"; $out = "-";}open(IN, "<$in") || die("Unable to open file $in : $!\n");open(OUT, ">$out") || die("Unable to open file $out : $!\n");while (<IN>) { s/\x01/ /g; # remove pesky ^As if (/^>(\S+)/) { # id line $name = $1; $cnt = ++$cnt{$name}; # count occurences of name if ($cnt > 1) { # duplicate name s/^>$name/>${name}_$cnt/; # append _i to name } } print OUT "$_";};if ($file) { rename($out, $file); }# cleanup files&cleanup($status); ################################################################################# Subroutines ################################################################################# ################################################################################## print_usage## Print the usage message and exit.#################################################################################sub print_usage { local ($usage, $status) = @_; if (-c STDOUT) { # standard output is a terminal open(C, "| more"); print C $usage; close C; } else { # standard output not a terminal print STDERR $usage; } exit $status;} ################################################################################# cleanup## cleanup stuff#################################################################################sub cleanup { local($status, $msg) = @_; if ($status && "$msg") {print STDERR "$msg: $status\n";} if ($file && -e $out) { unlink $out; } exit($status);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?