annotate bed2wig.pl @ 33:09fefe8db1d0 draft default tip

Uploaded
author big-tiandm
date Sat, 15 Nov 2014 01:33:45 -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: Chentt
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
4 #Email: chentt@big.ac.cn
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2014/06/25
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 #Description: get out larger than cut off sequence
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 use File::Basename;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
13 use FileHandle;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
14
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
15 my %opts;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
16 GetOptions(\%opts,"i=s","o=s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
17 if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18 &usage;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
19 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
20
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
21 my $outputdir=$opts{'o'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
22 unless ($outputdir=~/\/$/) {$outputdir .="/";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 ##############################get cmap##################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
25 my %cmap;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26 open IN,"<$opts{i}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 $cmap{$temp[0]}=$outputdir.$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 ###########################split ma file######################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 my %handle;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 foreach (keys %cmap) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 my $name=$cmap{$_}.".sam";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 open $handle{$_},">$name";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 open IN,"<$opts{i}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 $handle{$temp[0]}-> print ($aline,"\n");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 foreach (keys %handle) {close $_;}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 sub usage{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 print <<"USAGE";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 Version $version
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55 Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 $0 -i -o
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57 options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 -i input file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59 -o output file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60 -h help
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 USAGE
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 exit(1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64