view bed2wig.pl @ 23:cad6a1dfb174 draft

Uploaded
author big-tiandm
date Wed, 05 Nov 2014 21:11:49 -0500
parents 07745c0958dd
children
line wrap: on
line source

#!/usr/bin/perl -w
#Filename:
#Author: Chentt
#Email: chentt@big.ac.cn
#Date: 2014/06/25
#Modified:
#Description: get out larger than cut off sequence
my $version=1.00;

use strict;
use Getopt::Long;
use File::Basename;
use FileHandle;

my %opts;
GetOptions(\%opts,"i=s","o=s","h");
if (!(defined $opts{i} and defined $opts{o} ) || defined $opts{h}) { #necessary arguments
&usage;
}

my $outputdir=$opts{'o'};
unless ($outputdir=~/\/$/) {$outputdir .="/";}

##############################get cmap################## 
my %cmap;
open IN,"<$opts{i}";
while (my $aline=<IN>) {
	chomp $aline;
	next if($aline=~/^\#/);
	my @temp=split/\t/,$aline;
	$cmap{$temp[0]}=$outputdir.$temp[0];
}
close IN;
###########################split ma file######################
my %handle;
foreach  (keys %cmap) {
	my $name=$cmap{$_}.".sam";
	open $handle{$_},">$name";
}
open IN,"<$opts{i}";
while (my $aline=<IN>) {
	next if($aline=~/^\#/);
	chomp $aline;
	my @temp=split/\t/,$aline;
	$handle{$temp[0]}-> print ($aline,"\n");
	
}
close IN;
foreach  (keys %handle) {close $_;}


sub usage{
print <<"USAGE";
Version $version
Usage:
$0 -i -o
options:
-i input file
-o output file
-h help
USAGE
exit(1);
}