annotate count_ref_length.pl @ 19:e0884a4b996b draft

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