annotate non_miRNA_reads.pl @ 0:87fe81de0931 draft default tip

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