Bio-ToolBox
view release on metacpan or search on metacpan
scripts/bam2wig.pl view on Meta::CPAN
# Command line options
GetOptions(
'i|in=s' => \@bamfiles, # one or more bam files
'o|out=s' => \$outfile, # name of output file
's|start!' => \$use_start, # record start point
'd|mid!' => \$use_mid, # record mid point
'a|span!' => \$use_span, # record span
'cspan!' => \$use_cspan, # record center span
'e|extend!' => \$use_extend, # extend read
'smartcov!' => \$use_smartpe, # smart paired coverage
'ends!' => \$use_ends, # record paired-end endpoints
'coverage!' => \$use_coverage, # calculate coverage
'position=s' => \$position, # legacy option
'l|splice|split!' => \$splice, # split splices
'p|pe!' => \$paired, # paired-end alignments
'P|fastpe!' => \$fastpaired, # fast paired-end alignments
'I|shift!' => \$shift, # shift coordinates 3'
'H|shiftval=i' => \$shift_value, # value to shift coordinates
'x|extval=i' => \$extend_value, # value to extend reads
'chrom=i' => \$chr_number, # number of chromosomes to sample
'minr=f' => \$correlation_min, # R minimum value for shift
scripts/bam2wig.pl view on Meta::CPAN
if ( $shift and $splice ) {
print
" WARNING: enabling both shift and splices is currently not allowed. Pick one.\n";
exit 1;
}
if ( $shift and $paired ) {
print " WARNING: disabling shift with paired reads\n";
undef $shift;
}
if ( $use_ends and $shift ) {
print " WARNING: disabling shift when recording paired endpoints\n";
undef $shift;
}
if ( $use_ends and $splice ) {
print " WARNING: disabling splices when recording paired endpoints\n";
undef $splice;
}
# check to shift position or not
if ( $shift or $use_extend ) {
# set parameters for calculating shift value
unless ( $shift_value or $extend_value ) {
# not provided by user, empirical calculation required
scripts/bam2wig.pl view on Meta::CPAN
elsif ( $paired and not $do_strand and $use_smartpe ) {
$callback = \&smart_pe;
print " Recording smart paired-end coverage\n";
}
elsif ( $paired and $do_strand and $use_smartpe ) {
$callback = \&smart_stranded_pe;
print " Recording stranded, smart paired-end coverage\n";
}
elsif ( $paired and not $do_strand and $use_ends ) {
$callback = \&pe_ends;
print " Recording paired-end fragment endpoints\n";
}
elsif ( $paired and $do_strand and $use_ends ) {
$callback = \&pe_strand_ends;
print " Recording stranded, paired-end fragment endpoints\n";
}
else {
die "programmer error!\n" unless $shift; # special exception
}
# summary of wig file being written
if ($do_bedgraph) {
print " Writing bedGraph format in $bin_size bp increments\n";
}
elsif ($do_varstep) {
scripts/bam2wig.pl view on Meta::CPAN
# we continue but this will silently fail the low level fetch below
# but at least an empty temp file will be written allowing program to finish
}
my $seq_length = $seq_name2length{$seq_id};
# walk through the chromosome in 1 kb increments
my $chrom_data;
for ( my $start = 0; $start < $seq_length; $start += $coverage_dump ) {
# set endpoint
my $end = $start + $coverage_dump;
$end = $seq_length if $end > $seq_length;
# using the low level interface for a little more performance
my $coverage = low_level_bam_coverage( $sam, $tid, $start, $end );
# record the coverage
&{$coverage_sub}( $coverage, \$chrom_data );
}
scripts/bam2wig.pl view on Meta::CPAN
Required options:
-i --in <filename.bam> repeat if multiple bams, or comma-delimited list
Reporting options (pick one):
-s --start record at 5' position
-d --mid record at midpoint of alignment or pair
-a --span record across entire alignment or pair
-e --extend extend alignment (record predicted fragment)
--cspan record a span centered on midpoint
--smartcov record paired coverage without overlaps, splices
--ends record paired endpoints
--coverage raw alignment coverage
Alignment reporting options:
-l --splice split alignment at N splices
-t --strand record separate strands as two wig files
--flip flip the strands for convenience
Paired-end alignments:
-p --pe process paired-end alignments, both are checked
-P --fastpe process paired-end alignments, only F are checked
scripts/bam2wig.pl view on Meta::CPAN
or fragment (paired-end) midpoint will be recorded in the wig file.
The span is defined by the extension value.
=item --smartcov
Smart alignment coverage of paired-end alignments without
double-counting overlaps or recording gaps (intron splices).
=item --ends
Record both endpoints of paired-end fragments, i.e. the outermost
or 5' ends of properly paired fragments. This may be useful with
ATAC-Seq, Cut&Run-Seq, or other cleavage experiments where you want
to record the locations of cutting yet retain the ability to filter
paired-end fragment sizes.
=item --coverage
Specify that the raw alignment coverage be calculated and reported
in the wig file. This utilizes a special low-level operation and
precludes any alignment filtering or post-normalization methods.
scripts/get_gene_regions.pl view on Meta::CPAN
=item --stop E<lt>integerE<gt>
=item --end E<lt>integerE<gt>
Optionally specify adjustment values to adjust the reported start and
end coordinates of the collected regions. A negative value is shifted
upstream (5' direction), and a positive value is shifted downstream.
Adjustments are made relative to the feature's strand, such that
a start adjustment will always modify the feature's 5'end, either
the feature startpoint or endpoint, depending on its orientation.
=back
=head2 General options
=over 4
=item --bed
Automatically convert the output file to a BED file.
( run in 0.409 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )