annotate count_ref_length.pl @ 53:f5a2e8308836 draft default tip

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