comparison count_ref_length.pl @ 0:07745c0958dd draft

Uploaded
author big-tiandm
date Thu, 18 Sep 2014 21:40:25 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:07745c0958dd
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