annotate non_miRNA_reads.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: 2013/7/19
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
7 #Description:
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","fa=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{'fa'};
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 my (%fa,%seq);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
24 while (my $aline=<IN>){
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
25 chomp $aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
26 $aline=~s/^>//;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
27 my $seq=<IN>;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
28 chomp $seq;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
29 #$seq{$seq}=$aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
30 $fa{$aline}=$seq;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
31 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
32 close IN;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
33
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
34 open IN,"<$opts{i}";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
35 while(my $aline=<IN>){
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
36 chomp $aline;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
37 if($aline=~/^\S+_x\d+/){
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
38 $aline=~/^(\S+_x\d+)/;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
39 my $name=$1;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
40 delete($fa{$name});
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
41 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
42 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
43 close IN;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
44
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
45 open OUT,">$fileout"; #output file
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
46 foreach my $key (keys %fa) {
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
47 print OUT ">$key\n$fa{$key}\n";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
48 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
49 close OUT;
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
50 sub usage{
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
51 print <<"USAGE";
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
52 Version $version
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
53 Usage:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
54 $0 -i -o
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
55 options:
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
56 -i input file
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
57 -o output file
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
58 -h help
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
59 USAGE
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
60 exit(1);
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
61 }
7b5a48b972e9 Uploaded
big-tiandm
parents:
diff changeset
62