comparison bed2wig.pl @ 0:07745c0958dd draft

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