« lib/Bio/ToolBox/Parser/ucsc/builder.pm
↑ Summary
lib/Bio/ToolBox/db_helper/alignment_callbacks.pm »
| 1 | package Bio::ToolBox::big_helper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp qw(carp cluck croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::Which; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Bio::ToolBox::db_helper qw(get_chromosome_list); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Bio::ToolBox::db_helper::config qw($BTB_CONFIG); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '2.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ### Export | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | get_bed_to_bigbed_app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | get_bigwig_to_bdg_app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | get_bigwig_to_wig_app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | get_wig_to_bigwig_app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | check_wigToBigWig_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | open_wig_to_bigwig_fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | open_bigwig_to_wig_fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | bed_to_bigbed_conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | generate_chromosome_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | wig_to_bigwig_conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ### Find Converter external applications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub get_wig_to_bigwig_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_wig_to_bigwig_app: called CC=5 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # we prefer the wigToBigWig convertor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # first check for an entry in the configuration file then environment path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | my $app = | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.wigToBigWig') || which('wigToBigWig') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.wigToBigWig") or which("wigToBigWig")
MC/DC0%0/2
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.wigToBigWig') || which('wigToBigWig') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.wigToBigWig")
which("wigToBigWig")
Truth table33%1/3
A or B
A= $Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.wigToBigWig")B= which("wigToBigWig")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $BTB_CONFIG->param('applications.wigToBigWig') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | || which('wigToBigWig') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | unless ($app) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # last attempt is to use the older Bio::DB::BigFile module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # this may not be installed and will be slower since it runs in same process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | require Bio::DB::BigFile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ( Bio::DB::BigFile->can('createBigWig') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $app = 'BioDBBigFile'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | return $app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub get_bigwig_to_wig_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_bigwig_to_wig_app: called CC=4 SCAR=19.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # first check for an entry in the configuration file then environment path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | $BTB_CONFIG->param('applications.bigWigToWig') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bigWigToWig') || which('bigWigToWig') || which('bigWigToBedGraph') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToWig") or which("bigWigToWig") or which("bigWigToBedGraph")
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToWig") or which("bigWigToWig")
MC/DC0%0/3
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bigWigToWig') || which('bigWigToWig') || which('bigWigToBedGraph') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToWig")
which("bigWigToWig")
which("bigWigToBedGraph")
Truth table25%1/4
A or B or C
A= $Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToWig")B= which("bigWigToWig")C= which("bigWigToBedGraph")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | || which('bigWigToWig') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | || which('bigWigToBedGraph') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub get_bigwig_to_bdg_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_bigwig_to_bdg_app: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # first check for an entry in the configuration file then environment path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | $BTB_CONFIG->param('applications.bigWigToBedGraph') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bigWigToBedGraph') || which('bigWigToBedGraph') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToBedGraph") or which("bigWigToBedGraph")
MC/DC0%0/2
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bigWigToBedGraph') || which('bigWigToBedGraph') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToBedGraph")
which("bigWigToBedGraph")
Truth table33%1/3
A or B
A= $Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bigWigToBedGraph")B= which("bigWigToBedGraph")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | || which('bigWigToBedGraph') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | sub get_bed_to_bigbed_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_bed_to_bigbed_app: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # first check for an entry in the configuration file then environment path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | $BTB_CONFIG->param('applications.bedToBigBed') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bedToBigBed') || which('bedToBigBed') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bedToBigBed") or which("bedToBigBed")
MC/DC0%0/2
$Bio::ToolBox::big_helper::BTB_CONFIG->param('applications.bedToBigBed') || which('bedToBigBed') || undef
$Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bedToBigBed")
which("bedToBigBed")
Truth table33%1/3
A or B
A= $Bio::ToolBox::big_helper::BTB_CONFIG->param("applications.bedToBigBed")B= which("bedToBigBed")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | || which('bedToBigBed') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ### Check the version of wigToBigWig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # older versions support reading from stdin while newer versions do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub check_wigToBigWig_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_wigToBigWig_version: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return unless $app; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return 0 if $app eq 'BioDBBigFile'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( not -e $app ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | carp " '$app' does not exist!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( not -x _ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | carp " '$app' is not executable!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( $app =~ /bedGraphToBigWig$/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # this app is not always reliable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # generally does not accept stdin pipes, but even if it's old enough to do so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # it may still complain about line seeking and/or chromosome sort order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # best just not support it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $result = qx($app 2>&1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( $result =~ /wigToBigWig \s v \s ([\d\.]+)/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return 1 if $1 eq '2.8'; # older acceptable version | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return 0 if $1 eq '2.9'; # newer unsupported version | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return 1 if $1 eq '4'; # very old, this is actually the bbi version I think | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return 0; # do not trust anything else unfortunately | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ### Wig to BigWig file conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub wig_to_bigwig_conversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wig_to_bigwig_conversion: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # Collect passed arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | unless (%args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | carp 'no arguments passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # wigfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $args{wig} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"wig"} ||= undef
MC/DC0%0/1
$args{"wig"} ||= undef
$args{"wig"}
Truth table0%0/2
A
A= $args{"wig"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | unless ( $args{wig} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | carp 'no wig file passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # Identify bigwig conversion utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my $bwapp = $args{bwapppath} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'bwapppath'} || undef
MC/DC0%0/1
$args{'bwapppath'} || undef
$args{'bwapppath'}
Truth table0%0/2
A
A= $args{'bwapppath'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | unless ($bwapp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $bwapp = get_wig_to_bigwig_app(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | unless ($bwapp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | q(Utility 'wigToBigWig' not specified and can not be found! Conversion failed!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # Generate list of chromosome sizes if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $chromfile = $args{chromo} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"chromo"} ||= undef
MC/DC0%0/1
$args{"chromo"} ||= undef
$args{"chromo"}
Truth table0%0/2
A
A= $args{"chromo"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | unless ($chromfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # a pre-generated list of chromosome sizes was not provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # need to generate one from the database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $args{db} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"db"} ||= undef
MC/DC0%0/1
$args{"db"} ||= undef
$args{"db"}
Truth table0%0/2
A
A= $args{"db"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | unless ( $args{db} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 'No requisite database or chromosome info file provided! Conversion failed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $chromfile = generate_chromosome_file( $args{db} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | unless ($chromfile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | carp 'Cannot generate chromosome info file! Conversion failed'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # Generate the bw file name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # we can substitute one of three possible names for bw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $bw_file = $args{wig}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $bw_file =~ s/\.(?: bed | bdg | bedgraph | wig) $/.bw/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Generate the bigwig file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | printf " Converting %s to %s...\n", $args{wig}, $bw_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ( $bwapp =~ /wigToBigWig$/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # include the -clip option in case there are any positions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # out of bounds of the chromosome it will just warn instead of fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ( system( $bwapp, '-clip', $args{wig}, $chromfile, $bw_file ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $c = join q( ), $bwapp, '-clip', $args{wig}, $chromfile, $bw_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | print STDERR "conversion command '$c' failed - check error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif ( $bwapp =~ /bedGraphToBigWig$/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # this doesn't have the -clip option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ( system( $bwapp, $args{wig}, $chromfile, $bw_file ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $c = join q( ), $bwapp, $args{wig}, $chromfile, $bw_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | print STDERR "conversion command '$c' failed - check error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | elsif ( $bwapp eq 'BioDBBigFile' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # this cannot be caught if it fails, it will terminate the perl process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | print " Converting with Bio::DB::BigFile - this will terminate if errors\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | Bio::DB::BigFile->createBigWig( $args{wig}, $chromfile, $bw_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # check the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( -e $bw_file and -s $bw_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $bw_file and -s $bw_file
MC/DC0%0/2
-e $bw_file and -s $bw_file
-e $bw_file
-s $bw_file
Truth table0%0/3
A and B
A= -e $bw_fileB= -s $bw_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # conversion assumed successful | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( not $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # we no longer need our temp chromosome file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | unlink $chromfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return $bw_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( -e $bw_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | unlink $bw_file; # remove any partial file | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( not $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # leave the temp chromosome file as a courtesy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | " Conversion failed. You should try manually and watch for errors\n Leaving temporary chromosome file '$chromfile'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | carp 'Conversion failed. You should try manually and watch for errors.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ### Open a file handle to wigToBigWig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub open_wig_to_bigwig_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_wig_to_bigwig_fh: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Collect passed arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | unless (%args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | carp 'no arguments passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # bigWig output file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | $args{bw} ||= $args{wig} || $args{out} || $args{file} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/11
$args{"bw"} ||= $args{"wig"} || $args{"out"} || $args{"file"} || undef
$args{'wig'} || $args{'out'} || $args{'file'} || undef
$args{"wig"} or $args{"out"} or $args{"file"}
$args{"wig"} or $args{"out"}
MC/DC0%0/4
$args{"bw"} ||= $args{"wig"} || $args{"out"} || $args{"file"} || undef
$args{"bw"}
$args{"wig"}
$args{"out"}
$args{"file"}
Truth table0%0/5
A ||= B or C or D
A= $args{"bw"}B= $args{"wig"}C= $args{"out"}D= $args{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | unless ( $args{bw} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | carp 'no output bw file name passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | unless ( $args{bw} =~ /\.bw$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $args{bw} .= '.bw'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # Identify bigwig conversion utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $bwapp = $args{bwapppath} || get_wig_to_bigwig_app() || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args{'bwapppath'} || get_wig_to_bigwig_app() || undef
$args{"bwapppath"} or get_wig_to_bigwig_app()
MC/DC0%0/2
$args{'bwapppath'} || get_wig_to_bigwig_app() || undef
$args{"bwapppath"}
get_wig_to_bigwig_app()
Truth table0%0/3
A or B
A= $args{"bwapppath"}B= get_wig_to_bigwig_app()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ($bwapp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # check the version of the utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ( not check_wigToBigWig_version($bwapp) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | " $bwapp does not support stdin file handles. Either downgrade or use wig_to_bigwig_conversion()\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | print STDERR q( Utility 'wigToBigWig' not specified and can not be found!); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Generate list of chromosome sizes if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $args{chromo} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"chromo"} ||= undef
MC/DC0%0/1
$args{"chromo"} ||= undef
$args{"chromo"}
Truth table0%0/2
A
A= $args{"chromo"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | unless ( $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # a pre-generated list of chromosome sizes was not provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # need to generate one from the database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | $args{db} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"db"} ||= undef
MC/DC0%0/1
$args{"db"} ||= undef
$args{"db"}
Truth table0%0/2
A
A= $args{"db"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | unless ( $args{db} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 'No requisite database or chromosome info file provided! Conversion failed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $args{chrskip} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"chrskip"} ||= undef
MC/DC0%0/1
$args{"chrskip"} ||= undef
$args{"chrskip"}
Truth table0%0/2
A
A= $args{"chrskip"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $args{chromo} = generate_chromosome_file( $args{db}, $args{chrskip} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | unless ( $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | carp ' Cannot generate chromosome info file! Conversion failed'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # open the filehandle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $command = sprintf "%s stdin %s %s", $bwapp, $args{chromo}, $args{bw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | my $bwfh = IO::File->new("| $command") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | or croak sprintf( "cannot open %s! $OS_ERROR", $bwapp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # wigToBigWig will always die anyway if something is wrong | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # cannot trap it with an eval, since it doesn't just error out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # but actually exits, dragging the whole Perl process with it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # printf "we have a filehandle %s\n", ref $bwfh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | croak "unable to execute command '$command'" unless ref $bwfh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # we will still get an IO::File handle back even with a failed convertor - sigh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return $bwfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ### Open a file handle from bigWigToWig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub open_bigwig_to_wig_fh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_bigwig_to_wig_fh: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # Collect passed arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | unless (%args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | cluck 'no arguments passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # bigWig output file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $args{bw} ||= $args{wig} || $args{file} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$args{"bw"} ||= $args{"wig"} || $args{"file"} || undef
$args{'wig'} || $args{'file'} || undef
$args{"wig"} or $args{"file"}
MC/DC0%0/3
$args{"bw"} ||= $args{"wig"} || $args{"file"} || undef
$args{"bw"}
$args{"wig"}
$args{"file"}
Truth table0%0/4
A ||= B or C
A= $args{"bw"}B= $args{"wig"}C= $args{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | unless ( $args{bw} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | carp 'no input bw file name passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # Identify bigwig conversion utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $bwapp = $args{bwapppath} || get_bigwig_to_wig_app() || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args{'bwapppath'} || get_bigwig_to_wig_app() || undef
$args{"bwapppath"} or get_bigwig_to_wig_app()
MC/DC0%0/2
$args{'bwapppath'} || get_bigwig_to_wig_app() || undef
$args{"bwapppath"}
get_bigwig_to_wig_app()
Truth table0%0/3
A or B
A= $args{"bwapppath"}B= get_bigwig_to_wig_app()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | unless ( defined $bwapp and $bwapp =~ /bigWigTo(?: Wig | BedGraph)$/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bwapp and $bwapp =~ /bigWigTo(?: Wig | BedGraph)$/x
MC/DC0%0/2
defined $bwapp and $bwapp =~ /bigWigTo(?: Wig | BedGraph)$/x
defined $bwapp
$bwapp =~ /bigWigTo(?: Wig | BedGraph)$/x
Truth table0%0/3
A and B
A= defined $bwappB= $bwapp =~ /bigWigTo(?: Wig | BedGraph)$/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | carp q(Utility 'bigWigToWig' not specified and can not be found!); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # open the filehandle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $command = sprintf "%s %s stdout", $bwapp, $args{bw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my $bwfh = IO::File->new("$command |") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | or croak sprintf( "cannot open %s! $OS_ERROR", $bwapp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # bigWigToWig will always die anyway if something is wrong | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # cannot trap it with an eval, since it doesn't just error out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # but actually exits, dragging the whole Perl process with it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # printf "we have a filehandle %s\n", ref $bwfh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | croak "unable to execute command '$command'" unless ref $bwfh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # we will still get an IO::File handle back even with a failed convertor - sigh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return $bwfh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ### Bed to BigBed file conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub bed_to_bigbed_conversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bed_to_bigbed_conversion: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # Collect passed arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | unless (%args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | carp 'no arguments passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # bedfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $args{bed} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"bed"} ||= undef
MC/DC0%0/1
$args{"bed"} ||= undef
$args{"bed"}
Truth table0%0/2
A
A= $args{"bed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | unless ( $args{bed} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | carp 'no bed file passed!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # identify bigbed conversion utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my $bbapp = $args{bbapppath} ||= get_bed_to_bigbed_app() || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args{"bbapppath"} ||= get_bed_to_bigbed_app() || undef
get_bed_to_bigbed_app() || undef
MC/DC0%0/2
$args{"bbapppath"} ||= get_bed_to_bigbed_app() || undef
$args{"bbapppath"}
get_bed_to_bigbed_app()
Truth table0%0/3
A ||= B
A= $args{"bbapppath"}B= get_bed_to_bigbed_app()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | unless ( defined $bbapp and $bbapp =~ / bedToBigBed $/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bbapp and $bbapp =~ / bedToBigBed $/x
MC/DC0%0/2
defined $bbapp and $bbapp =~ / bedToBigBed $/x
defined $bbapp
$bbapp =~ / bedToBigBed $/x
Truth table0%0/3
A and B
A= defined $bbappB= $bbapp =~ / bedToBigBed $/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | carp q(Utility 'bedToBigBed' not specified and can not be found!); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # Generate list of chromosome sizes if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | $args{chromo} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"chromo"} ||= undef
MC/DC0%0/1
$args{"chromo"} ||= undef
$args{"chromo"}
Truth table0%0/2
A
A= $args{"chromo"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | unless ( $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # a pre-generated list of chromosome sizes was not provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # need to generate one from the database | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $args{db} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"db"} ||= undef
MC/DC0%0/1
$args{"db"} ||= undef
$args{"db"}
Truth table0%0/2
A
A= $args{"db"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | unless ( $args{db} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | carp 'No requisite database or chromosome info file provided!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $args{chromo} = generate_chromosome_file( $args{db} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | unless ( $args{chromo} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | carp 'Cannot generate chromosome info file!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Generate the bb file name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $bb_file = $args{bed}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $bb_file =~ s/\.bed$/.bb/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # Generate the bigBed file using Jim Kent's utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | printf " converting %s to BigBed....\n", $args{bed}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | system( $bbapp, $args{bed}, $args{chromo}, $bb_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # Check the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if ( -e $bb_file and -s $bb_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $bb_file and -s $bb_file
MC/DC0%0/2
-e $bb_file and -s $bb_file
-e $bb_file
-s $bb_file
Truth table0%0/3
A and B
A= -e $bb_fileB= -s $bb_file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # conversion successful | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( $args{chromo} =~ /^chr_sizes_\w{5}/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # we no longer need our temp chromosome file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | unlink $args{chromo}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return $bb_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ( -e $bb_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | unlink $bb_file; # remove any partial file | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( $args{chromo} =~ /^chr_sizes_\w{5}/x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # leave the temp chromosome file as a courtesy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | " Conversion failed. You should try manually and watch for errors\n Leaving temporary chromosome file '$args{chromo}'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | carp 'Conversion failed. You should try manually and watch for errors.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | sub generate_chromosome_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_chromosome_file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $database = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $chr_exclude = shift || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | print " generating chromosome file....\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # generate chromosome lengths file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my @chromosomes = get_chromosome_list( $database, $chr_exclude ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | unless (@chromosomes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | carp 'no chromosome sequences identified in database!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # prepare temp file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | my $chr_fh = new File::Temp( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 'UNLINK' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 'TEMPLATE' => 'chr_sizes_XXXXX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ) or croak "unable to open chromosome temp file! $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $chromo_file = $chr_fh->filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # write out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | foreach my $chr (@chromosomes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # chromosome name and size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $chr_fh->printf( "%s\t%d\n", $chr->[0], $chr->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $chr_fh->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return $chromo_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||