comparison rfam.pl @ 21:9dcffd531c76 draft

Uploaded
author big-tiandm
date Wed, 05 Nov 2014 21:09:35 -0500
parents
children
comparison
equal deleted inserted replaced
20:2ed1e1728299 21:9dcffd531c76
1 #!/usr/bin/perl -w
2 #Filename:
3 #Author: Tian Dongmei
4 #Email: tiandm@big.ac.cn
5 #Date: 2013/7/19
6 #Modified:
7 #Description:
8 my $version=1.00;
9
10 use strict;
11 use Getopt::Long;
12 use File::Basename;
13
14 my %opts;
15 GetOptions(\%opts,"i=s","ref=s","index:s","v:i","p:i","o=s","h");
16 if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
17 &usage;
18 }
19
20 my $filein=$opts{'i'};
21 my $fileout=$opts{'o'};
22 unless ($fileout=~/\/$/) {$fileout.="/";}
23 my $rfam=$opts{'ref'};
24 my $mis=defined $opts{'v'}? $opts{'v'} : 0;
25 my $index=defined $opts{'index'} ? $opts{'index'} : "";
26 my $threads=defined $opts{'p'} ? $opts{'p'} : 1;
27
28
29 #my $time=time();
30
31 #my $mapdir=$fileout."/rfam_match_".$time;
32 my $mapdir=$fileout."/rfam_match";
33 mkdir $mapdir;
34 chdir $mapdir;
35 ###check genome index
36 if (-s $index.".1.ebwt") {
37 }else{
38 &checkACGT($rfam);
39 `bowtie-build $rfam rfam`;
40 $index="rfam";
41 }
42
43 #chdir "rfam_match_1397022331";
44 ### genome mapping
45 `bowtie -v $mis -f -p $threads -k 1 $index $filein --al rfam_mapped.fa --un rfam_not_mapped.fa > rfam_mapped.bwt 2> run.log`;
46
47 sub checkACGT{
48 my $string;
49 open IN,"<$rfam";
50 while (my $aline=<IN>) {
51 if ($aline!~/^>/) {
52 $aline=~s/U/T/gi;
53 }
54 $string .=$aline;
55 }
56 close IN;
57 $rfam=basename($rfam);
58 open OUT, ">$rfam";
59 print OUT $string;
60 close OUT;
61 }
62
63 sub usage{
64 print <<"USAGE";
65 Version $version
66 Usage:
67 $0 -i -o
68 options:
69 -i input file# input reads fasta/fastq file
70 -ref input file# rfam file, which do not contain miRNAs
71 -index file-prefix #(must be indexed by bowtie-build) The parameter
72 string must be the prefix of the bowtie index. For instance, if
73 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
74 the prefix is 'h_sapiens_37_asm'.##can be null
75 -v <int> report end-to-end hits w/ <=v mismatches; ignore qualities,default 0;
76
77 -p/--threads <int> number of alignment threads to launch (default: 1)
78
79 -o output directory
80
81 -h help
82 USAGE
83 exit(1);
84 }
85