annotate matching.pl @ 32:399d8dbdedd6 draft

Uploaded
author big-tiandm
date Sat, 15 Nov 2014 01:33:20 -0500
parents 9dcffd531c76
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
2 #Filename:
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
3 #Author: Tian Dongmei
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
4 #Email: tiandm@big.ac.cn
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2013/7/19
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
7 #Description:
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
8 my $version=1.00;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
9
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
10 use strict;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
11 use Getopt::Long;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
12
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
13 my %opts;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
14 GetOptions(\%opts,"i=s","g=s","index:s","v:i","p:i","r:s","o=s","h");
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
15 if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
16 &usage;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
17 }
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
18
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
19 my $filein=$opts{'i'};
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
20 my $fileout=$opts{'o'};
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
21 unless ($fileout=~/\/$/) {$fileout.="/";}
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
22 my $genome=$opts{'g'};
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
23 my $mis=defined $opts{'v'}? $opts{'v'} : 0;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
24 my $hits=defined $opts{'r'}? $opts{'r'} : 25;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
25 my $index=defined $opts{'index'} ? $opts{'index'} : "";
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
26 my $threads=defined $opts{'p'} ? $opts{'p'} : 1;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
27
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
28
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
29 #my $time=time();
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
30 #my $mapdir=$fileout."/genome_match_".$time;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
31 my $mapdir=$fileout."/genome_match";
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
32 mkdir $mapdir;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
33 chdir $mapdir;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
34 ###check genome index
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
35 if (-s $index.".1.ebwt") {
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
36 }else{
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
37 `bowtie-build $genome genome`;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
38 $index="genome";
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
39 }
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
40
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
41 ### genome mapping
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
42 `bowtie -v $mis -f -p $threads -m $hits -a --best --strata $index $filein --al genome_mapped.fa --un genome_not_mapped.fa > genome_mapped.bwt 2> run.log`;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
43
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
44 #`convert_bowtie_to_blast.pl genome_mapped.bwt genome_mapped.fa $genome > genome_mapped.bst`;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
45
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
46 sub usage{
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
47 print <<"USAGE";
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
48 Version $version
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
49 Usage:
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
50 $0 -i -o
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
51 options:
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
52 -i input file# input reads fasta/fastq file
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
53 -g input file# genome file
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
54 -index file-prefix #(must be indexed by bowtie-build) The parameter
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
55 string must be the prefix of the bowtie index. For instance, if
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
56 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
57 the prefix is 'h_sapiens_37_asm'.##can be null
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
58 -v <int> report end-to-end hits w/ <=v mismatches; ignore qualities,default 0;
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
59
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
60 -p/--threads <int> number of alignment threads to launch (default: 1)
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
61
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
62 -r int a read is allowed to map up to this number of positions in the genome
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
63 default is 25
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
64
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
65 -o output directory
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
66
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
67 -h help
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
68 USAGE
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
69 exit(1);
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
70 }
9dcffd531c76 Uploaded
big-tiandm
parents:
diff changeset
71