comparison count_ref_length.pl @ 50:7b5a48b972e9 draft

Uploaded
author big-tiandm
date Fri, 05 Dec 2014 00:11:02 -0500
parents
children
comparison
equal deleted inserted replaced
49:f008ab2cadc6 50:7b5a48b972e9
1 #!/usr/bin/perl -w
2 #Filename:
3 #Author: Tian Dongmei
4 #Email: tiandm@big.ac.cn
5 #Date: 2009-05-06
6 #Modified:
7 #Description: ɾ³ýmatched reads
8 my $version=1.00;
9
10 use strict;
11 use Getopt::Long;
12
13 my %opts;
14 GetOptions(\%opts,"i=s","o=s","h");
15 if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
16 &usage;
17 }
18
19 my $filein=$opts{'i'};
20 my $fileout=$opts{'o'};
21
22 open IN,"<$filein"; #input file
23 open OUT,">$fileout"; #output file
24
25 my ($name,$seq);
26 while (my $aline=<IN>) {
27 chomp $aline;
28 if ($aline=~/^>(\S+)/) {
29 $name=$1;
30 while (my $new=<IN>) {
31 chomp $new;
32 if ($new=~/^>(\S+)/) {
33 print OUT $name,"\t",length($seq),"\n";
34 $seq ="";
35 $name=$1;
36 next;
37 }
38 else{$seq .=$new;}
39 }
40 }
41 print OUT $name,"\t",length($seq),"\n";
42 }
43
44 close IN;
45 close OUT;
46 sub usage{
47 print <<"USAGE";
48 Version $version
49 Usage:
50 $0 -i -o
51 options:
52 -i input file
53 -o output file
54 -h help
55 USAGE
56 exit(1);
57 }
58