annotate new/bismark_methylation_extractor @ 7:fcadce4d9a06 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
author bgruening
date Sat, 06 May 2017 13:18:09 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1 #!/usr/bin/perl
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2 use warnings;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3 use strict;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4 $|++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5 use Getopt::Long;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6 use Cwd;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7 use Carp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8 use FindBin qw($Bin);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9 use lib "$Bin/../lib";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
11 ## This program is Copyright (C) 2010-15, Felix Krueger (felix.krueger@babraham.ac.uk)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
12
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
13 ## This program is free software: you can redistribute it and/or modify
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
14 ## it under the terms of the GNU General Public License as published by
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
15 ## the Free Software Foundation, either version 3 of the License, or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
16 ## (at your option) any later version.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
17
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
18 ## This program is distributed in the hope that it will be useful,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
19 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
20 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
21 ## GNU General Public License for more details.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
22
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
23 ## You should have received a copy of the GNU General Public License
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
24 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
25
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
26 my @filenames; # input files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
27 my %counting;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
28 my $parent_dir = getcwd();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
29
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
30 my %fhs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
31
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
32 my $version = 'v0.14.3';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
33 my ($ignore,$genomic_fasta,$single,$paired,$full,$report,$no_overlap,$merge_non_CpG,$vanilla,$output_dir,$no_header,$bedGraph,$remove,$coverage_threshold,$counts,$cytosine_report,$genome_folder,$zero,$CpG_only,$CX_context,$split_by_chromosome,$sort_size,$samtools_path,$gzip,$ignore_r2,$mbias_off,$mbias_only,$gazillion,$ample_mem,$ignore_3prime,$ignore_3prime_r2,$multicore) = process_commandline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
34
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
35
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
36 ### only needed for bedGraph output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
37 my @sorting_files; # if files are to be written to bedGraph format, these are the methylation extractor output files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
38 my @methylcalls = qw (0 0 0); # [0] = methylated, [1] = unmethylated, [2] = total
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
39 my @bedfiles;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
40
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
41 ### only needed for genome-wide cytosine methylation report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
42 my %chromosomes;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
43
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
44 my %mbias_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
45 my %mbias_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
46
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
47
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
48 ##############################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
49 ### Summarising Run Parameters
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
50 ##############################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
51
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
52 ### METHYLATION EXTRACTOR
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
53
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
54 warn "Summarising Bismark methylation extractor parameters:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
55 warn '='x63,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
56
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
57 if ($single){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
58 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
59 warn "Bismark single-end vanilla format specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
60 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
61 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
62 warn "Bismark single-end SAM format specified (default)\n"; # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
63 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
64 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
65 elsif ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
66 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
67 warn "Bismark paired-end vanilla format specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
68 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
69 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
70 warn "Bismark paired-end SAM format specified (default)\n"; # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
71 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
72 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
73
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
74 warn "Number of cores to be used: $multicore\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
75
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
76 if ($single){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
77 if ($ignore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
78 warn "First $ignore bp will be disregarded when processing the methylation call string\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
79 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
80 if ($ignore_3prime){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
81 warn "Last $ignore_3prime bp will be disregarded when processing the methylation call string\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
82 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
83
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
84 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
85 else{ ## paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
86 if ($ignore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
87 warn "First $ignore bp will be disregarded when processing the methylation call string of Read 1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
88 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
89 if ($ignore_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
90 warn "First $ignore_r2 bp will be disregarded when processing the methylation call string of Read 2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
91 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
92
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
93 if ($ignore_3prime){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
94 warn "Last $ignore_3prime bp will be disregarded when processing the methylation call string of Read 1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
95 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
96 if ($ignore_3prime_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
97 warn "Last $ignore_3prime_r2 bp will be disregarded when processing the methylation call string of Read 2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
98 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
99
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
101 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
102
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
103
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
104 if ($full){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
105 warn "Strand-specific outputs will be skipped. Separate output files for cytosines in CpG, CHG and CHH context will be generated\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
106 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
107 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
108 warn "Merge CHG and CHH context to non-CpG context specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
109 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
110 ### output directory
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
111 if ($output_dir eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
112 warn "Output will be written to the current directory ('$parent_dir')\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
113 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
114 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
115 warn "Output path specified as: $output_dir\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
116 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
117
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
118
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
119 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
120
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
121 ### BEDGRAPH
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
122
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
123 if ($bedGraph){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
124 warn "\n\nSummarising bedGraph parameters:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
125 warn '='x63,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
126
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
127 if ($counts){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
128 warn "Generating additional output in bedGraph and coverage format\nbedGraph format:\t<Chromosome> <Start Position> <End Position> <Methylation Percentage>\ncoverage format:\t<Chromosome> <Start Position> <End Position> <Methylation Percentage> <count methylated> <count non-methylated>\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
129 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
130 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
131 warn "Generating additional sorted output in bedGraph format (output format: <Chromosome> <Start Position> <End Position> <Methylation Percentage>)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
132 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
133
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
134 ### Zero-based coordinates
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
135 if ($zero){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
136 warn "Writing out an additional coverage file (ending in zero.cov) with 0-based start and 1-based end genomic coordinates (zero-based, half-open; user-defined)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
137 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
138
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
139 warn "Using a cutoff of $coverage_threshold read(s) to report cytosine positions\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
140
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
141 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
142 warn "Reporting and sorting methylation information for all cytosine context (sorting may take a long time, you have been warned ...)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
143 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
144 else{ # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
145 $CpG_only = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
146 warn "Reporting and sorting cytosine methylation information in CpG context only (default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
147 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
148
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
149 if ($remove){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
150 warn "White spaces in read ID names will be removed prior to sorting\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
151 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
152
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
153 if ($ample_mem){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
154 warn "Sorting chromosomal postions for the bedGraph step using arrays instead of using UNIX sort\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
155 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
156 elsif (defined $sort_size){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
157 warn "The bedGraph UNIX sort command will use the following memory setting:\t'$sort_size'. Temporary directory used for sorting is the output directory\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
158 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
159 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
160 warn "Setting a default memory usage for the bedGraph UNIX sort command to 2GB\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
161 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
162
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
163
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
164
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
165 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
166
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
167 if ($cytosine_report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
168 warn "\n\nSummarising genome-wide cytosine methylation report parameters:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
169 warn '='x63,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
170 warn "Generating comprehensive genome-wide cytosine report\n(output format: <Chromosome> <Position> <Strand> <count methylated> <count non-methylated> <C-context> <trinucleotide context> )\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
171
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
172
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
173 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
174 warn "Reporting methylation for all cytosine contexts. Be aware that this will generate enormous files\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
175 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
176 else{ # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
177 $CpG_only = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
178 warn "Reporting cytosine methylation in CpG context only (default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
179 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
180
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
181 if ($split_by_chromosome){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
182 warn "Splitting the cytosine report output up into individual files for each chromosome\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
183 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
184
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
185 ### Zero-based coordinates
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
186 if ($zero){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
187 warn "Using zero-based start and 1-based end genomic coordinates (zero-based, half-open; user-defined)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
188 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
189 else{ # default, 1-based coords
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
190 warn "Using 1-based genomic coordinates (default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
191 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
192
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
193 ### GENOME folder
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
194 if ($genome_folder){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
195 unless ($genome_folder =~/\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
196 $genome_folder =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
197 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
198 warn "Genome folder was specified as $genome_folder\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
199 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
200 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
201 $genome_folder = '/data/public/Genomes/Mouse/NCBIM37/';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
202 warn "Using the default genome folder /data/public/Genomes/Mouse/NCBIM37/\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
203 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
204 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
205 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
206 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
207
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
208 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
209 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
210
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
211 ######################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
212 ### PROCESSING FILES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
213 ######################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
214
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
215 foreach my $filename (@filenames){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
216 # resetting counters and filehandles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
217 %fhs = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
218 %counting =(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
219 total_meCHG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
220 total_meCHH_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
221 total_meCpG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
222 total_unmethylated_CHG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
223 total_unmethylated_CHH_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
224 total_unmethylated_CpG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
225 sequences_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
226 methylation_call_strings => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
227 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
228
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
229 @sorting_files = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
230 @bedfiles = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
231
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
232 %mbias_1 = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
233 %mbias_2 = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
234
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
235
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
236 ### performing a quick check to see if a paired-end SAM file has been sorted by positions which does interfere with the logic used by the extractor
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
237 unless ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
238 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
239 test_positional_sorting($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
240 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
241 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
242
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
243 my ($pid,$pids,$report_basename) = process_Bismark_results_file($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
244
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
245 if ($pid == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
246 warn "Finished processing child process. Exiting..\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
247
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
248 # ### Closing all filehandles of the child process so that the Bismark methylation extractor output doesn't get truncated due to buffering issues
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
249 # foreach my $fh (keys %fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
250 # if ($fh =~ /^[1230]$/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
251 # foreach my $context (keys %{$fhs{$fh}}) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
252 # $fhs{$fh}->{$context}->flush;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
253 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
254 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
255 # else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
256 # $fhs{$fh}->flush;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
257 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
258 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
259 exit 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
260 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
261
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
262 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
263 if ($pid and $multicore > 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
264 warn "Now waiting for all child processes to complete\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
265 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
266
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
267 ### we need to ensure that we wait for all child processes to be finished before continuing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
268 # warn "here are the child IDs: @$pids\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
269 # warn "Looping through the child process IDs:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
270
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
271 foreach my $id (@$pids){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
272 # print "$id\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
273 my $kid = waitpid ($id,0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
274 # print "Returned: $kid\nExit status: $?\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
275 unless ($? == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
276 warn "\nChild process terminated with exit signal: '$?'\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
278 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
279 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
280
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
281 ### Closing all filehandles so that the Bismark methylation extractor output doesn't get truncated due to buffering issues
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
282 foreach my $fh (keys %fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
283 if ($fh =~ /^[1230]$/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
284 foreach my $context (keys %{$fhs{$fh}}) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
285 close $fhs{$fh}->{$context} or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
286 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
287 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
288 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
289 close $fhs{$fh} or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
290 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
291 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
292
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
293 ### We need to stitch together a main splitting report from all individual parent/child processes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
294 if ($multicore > 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
295 merge_individual_splitting_reports($report_basename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
296 print_splitting_report();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
297
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
298 merge_individual_mbias_reports($report_basename); # this updates the main %mbias_1 and %mbias_2 data structures so we can proceed normally
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
299
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
300 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
301
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
302 unless ($mbias_off){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
303 ### printing out all M-Bias data
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
304 produce_mbias_plots ($filename); produce_mbias_plots ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
305
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
306 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
307
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
308 unless ($mbias_only){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
309 delete_unused_files();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
310 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
311
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
312 if ($bedGraph){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
313
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
314 my $out = (split (/\//,$filename))[-1]; # extracting the filename if a full path was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
315 $out =~ s/gz$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
316 $out =~ s/sam$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
317 $out =~ s/bam$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
318 $out =~ s/txt$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
319 $out =~ s/$/bedGraph/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
320
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
321 my $bedGraph_output = $out;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
322 my @args;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
323
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
324 if ($remove){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
325 push @args, '--remove';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
326 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
327 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
328 push @args, '--CX_context';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
329 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
330 if ($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
331 push @args, '--no_header';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
332 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
333 if ($gazillion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
334 push @args, '--gazillion';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
335 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
336 if ($ample_mem){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
337 push @args, '--ample_memory';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
338 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
339 if ($zero){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
340 push @args, "--zero";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
341 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
342
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
343 # if ($counts){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
344 # push @args, "--counts";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
345 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
346
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
347 push @args, "--buffer_size $sort_size";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
348 push @args, "--cutoff $coverage_threshold";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
349 push @args, "--output $bedGraph_output";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
350 push @args, "--dir '$output_dir'";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
351
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
352 ### adding all files to be sorted to @args
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
353 foreach my $f (@sorting_files){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
354 push @args, $f;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
355 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
356
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
357 # print join "\t",@args,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
358
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
359 system ("$Bin/bismark2bedGraph @args");
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
360
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
361 warn "Finished BedGraph conversion ...\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
362 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
363
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
364 # open (OUT,'>',$output_dir.$bedGraph_output) or die "Problems with the bedGraph output filename detected: file path: '$output_dir'\tfile name: '$bedGraph_output' $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
365 # warn "Writing bedGraph to file: $bedGraph_output\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
366 # process_bedGraph_output();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
367 # close OUT or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
368
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
369 ### genome-wide cytosine methylation report requires bedGraph processing anyway
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
370 if ($cytosine_report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
371
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
372 @args = (); # resetting @args
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
373 my $cytosine_out = $out;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
374 $cytosine_out =~ s/bedGraph$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
375
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
376 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
377 $cytosine_out =~ s/$/CX_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
378 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
379 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
380 $cytosine_out =~ s/$/CpG_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
381 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
382
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
383 push @args, "--output $cytosine_out";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
384 push @args, "--dir '$output_dir'";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
385 push @args, "--genome '$genome_folder'";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
386 push @args, "--parent_dir '$parent_dir'";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
387
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
388 if ($zero){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
389 push @args, "--zero";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
390 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
391 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
392 push @args, '--CX_context';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
393 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
394 if ($split_by_chromosome){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
395 push @args, '--split_by_chromosome';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
396 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
397
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
398 my $coverage_output = $bedGraph_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
399 $coverage_output =~ s/bedGraph$/bismark.cov/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
400
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
401 push @args, $output_dir . $coverage_output; # this will be the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
402
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
403 system ("$Bin/coverage2cytosine @args");
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
404 # generate_genome_wide_cytosine_report($bedGraph_output,$cytosine_out);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
405 warn "\n\nFinished generating genome-wide cytosine report\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
406 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
407 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
408 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
409
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
410 sub merge_individual_splitting_reports{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
411
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
412 my $report_basename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
413
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
414 my @splitting_reports; # only needed in multi-core mode to generate an overall report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
415 foreach my $ext (1..$multicore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
416 push @splitting_reports, "$report_basename.$ext";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
417 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
418 warn "\nMerging individual splitting reports into overall report: '$report_basename'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
419 warn "Merging from these individual files:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
420 print join ("\n",@splitting_reports),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
421 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
422
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
423 ##########
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
424 # resetting the counter first
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
425 %counting =(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
426 total_meCHG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
427 total_meCHH_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
428 total_meCpG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
429 total_unmethylated_CHG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
430 total_unmethylated_CHH_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
431 total_unmethylated_CpG_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
432 sequences_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
433 methylation_call_strings => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
434 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
435
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
436 # repopulating the merged counter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
437 foreach my $file (@splitting_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
438 open (IR,$file) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
439 while (<IR>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
440 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
441 my ($context,$count) = (split /\t/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
442 if ($context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
443 if ($context =~ /^Total C to T conversions in CpG context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
444 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
445 $counting{total_unmethylated_CpG_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
446 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
447 elsif ($context =~ /^Total C to T conversions in CHG context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
448 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
449 $counting{total_unmethylated_CHG_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
450 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
451 elsif ($context =~ /^Total C to T conversions in CHH context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
452 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
453 $counting{total_unmethylated_CHH_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
454 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
455 elsif ($context =~ /^Total methylated C\'s in CpG context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
456 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
457 $counting{total_meCpG_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
458 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
459 elsif ($context =~ /^Total methylated C\'s in CHG context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
460 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
461 $counting{total_meCHG_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
462 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
463 elsif ($context =~ /^Total methylated C\'s in CHH context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
464 # warn "context: $context\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
465 $counting{total_meCHH_count} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
466 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
467 elsif ($context =~ /^line count/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
468 # warn "Line count\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
469 $counting{sequences_count} = $count; # always the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
470 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
471 elsif ($context =~ /^meth call strings/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
472 # warn "Meth call strings\ncount: $count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
473 $counting{methylation_call_strings} += $count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
474 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
475 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
476 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
477 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
478
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
479 # deleting the individual reports afterwards
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
480 foreach my $file (@splitting_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
481 unlink $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
482 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
483 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
484
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
485
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
486 sub merge_individual_mbias_reports{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
487
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
488 my $report_basename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
489
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
490 my @mbias_reports; # only needed in multi-core mode to generate an overall report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
491 foreach my $ext (1..$multicore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
492 push @mbias_reports, "$report_basename.${ext}.mbias";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
493 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
494 warn "\nMerging individual M-bias reports into overall M-bias statistics from these $multicore individual files:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
495 print join ("\n",@mbias_reports),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
496
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
497
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
498 ##########
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
499 # resetting the counters first, then repopulating them
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
500 %mbias_1 = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
501 %mbias_2 = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
502
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
503 # repopulating the merged counter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
504 foreach my $file (@mbias_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
505 open (IR,$file) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
506
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
507 my $context;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
508 my $read;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
509
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
510 while (<IR>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
511 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
512 # warn "$_\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
513 if ($_ =~ /context/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
514 $context = $1 if ($_ =~ /(\D{3}) context/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
515 # warn "Context set as $context\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
516
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
517 if ($_ =~ /R2/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
518 $read = 'R2';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
519 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
520 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
521 $read = 'R1';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
522 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
523 # warn "Setting read identity to '$read'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
524
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
525 # reading in 2 additional lines (===========, and header line)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
526 $_ = <IR>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
527 #warn "discarding line $_\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
528 $_ = <IR>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
529 #warn "discarding line $_\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
530 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
531 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
532 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
533
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
534 if ($_ eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
535 # empty line, only occurs after a context has finished and before a new context starts
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
536 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
537 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
538
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
539 my ($pos,$meth,$unmeth) = (split /\t/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
540 # warn "$pos\t$meth\t$unmeth\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
541 if ($read eq 'R1'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
542 $mbias_1{$context}->{$pos}->{meth} += $meth;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
543 $mbias_1{$context}->{$pos}->{un} += $unmeth;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
544 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
545 elsif ($read eq 'R2'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
546 $mbias_2{$context}->{$pos}->{meth} += $meth;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
547 $mbias_2{$context}->{$pos}->{un} += $unmeth;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
548 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
549 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
550 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
551 close IR or warn "Had trouble closing filehandle for $file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
552 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
553
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
554 # deleting the individual reports afterwards
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
555 foreach my $file (@mbias_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
556 unlink $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
557 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
558 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
559
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
560
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
561 sub delete_unused_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
562
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
563 warn "Deleting unused files ...\n\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
564
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
565 my $index = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
566
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
567 while ($index <= $#sorting_files){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
568 if ($sorting_files[$index] =~ /gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
569 open (USED,"zcat $sorting_files[$index] |") or die "Failed to read from methylation extractor output file $sorting_files[$index]: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
570 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
571 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
572 open (USED,$sorting_files[$index]) or die "Failed to read from methylation extractor output file $sorting_files[$index]: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
573 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
574
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
575 my $used = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
576
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
577 while (<USED>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
578 next if (/^Bismark/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
579 if ($_){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
580 $used = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
581 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
582 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
583 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
584
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
585 if ($used){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
586 warn "$sorting_files[$index] contains data ->\tkept\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
587 ++$index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
588 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
589 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
590
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
591 my $delete = unlink $sorting_files[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
592
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
593 if ($delete){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
594 warn "$sorting_files[$index] was empty ->\tdeleted\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
595 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
596 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
597 warn "$sorting_files[$index] was empty, however deletion was unsuccessful: $!\n"
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
598 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
599
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
600 ### we also need to remove the element from @sorting_files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
601 splice @sorting_files, $index, 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
602 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
603 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
604 warn "\n\n"; ## can't close the piped filehandles at this point because it will die (unfortunately)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
605 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
606
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
607 sub produce_mbias_plots{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
608
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
609 my $filename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
610
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
611 my $mbias = (split (/\//,$filename))[-1]; # extracting the filename if a full path was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
612 $mbias =~ s/gz$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
613 $mbias =~ s/sam$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
614 $mbias =~ s/bam$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
615 $mbias =~ s/txt$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
616 my $mbias_graph_1 = my $mbias_graph_2 = $mbias;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
617 $mbias_graph_1 = $output_dir . $mbias_graph_1 . 'M-bias_R1.png';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
618 $mbias_graph_2 = $output_dir . $mbias_graph_2 . 'M-bias_R2.png';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
619
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
620 $mbias =~ s/$/M-bias.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
621
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
622 open (MBIAS,'>',"$output_dir$mbias") or die "Failed to open file for the M-bias data\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
623
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
624 # determining maximum read length
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
625 my $max_length_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
626 my $max_length_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
627
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
628 foreach my $context (keys %mbias_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
629 foreach my $pos (sort {$a<=>$b} keys %{$mbias_1{$context}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
630 $max_length_1 = $pos unless ($max_length_1 >= $pos);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
631 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
632 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
633 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
634 foreach my $context (keys %mbias_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
635 foreach my $pos (sort {$a<=>$b} keys %{$mbias_2{$context}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
636 $max_length_2 = $pos unless ($max_length_2 >= $pos);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
637 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
638 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
639 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
640
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
641 if ($single){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
642 warn "Determining maximum read length for M-Bias plot\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
643 warn "Maximum read length of Read 1: $max_length_1\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
644 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
645 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
646 warn "Determining maximum read lengths for M-Bias plots\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
647 warn "Maximum read length of Read 1: $max_length_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
648 warn "Maximum read length of Read 2: $max_length_2\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
649 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
650 # sleep(3);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
651
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
652 my @mbias_read1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
653 my @mbias_read2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
654
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
655 #Check whether the module GD::Graph:lines is installed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
656 my $gd_graph_installed = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
657 eval{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
658 require GD::Graph::lines;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
659 GD::Graph::lines->import();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
660 };
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
661
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
662 unless($@) { # syntax or routine error variable, set if something goes wrong in the last eval{ require ...}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
663 $gd_graph_installed = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
664
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
665 #Check whether the module GD::Graph::colour is installed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
666 eval{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
667 require GD::Graph::colour;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
668 GD::Graph::colour->import(qw(:colours :lists :files :convert));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
669 };
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
670
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
671 if ($@) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
672 warn "Perl module GD::Graph::colour not found, skipping drawing M-bias plots (only writing out M-bias plot table)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
673 sleep(2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
674 $gd_graph_installed = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
675 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
676
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
677
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
678 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
679 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
680 warn "Perl module GD::Graph::lines is not installed, skipping drawing M-bias plots (only writing out M-bias plot table)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
681 sleep(2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
682 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
683
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
684
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
685 my $graph_title;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
686 my $graph1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
687 my $graph2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
688
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
689 if ( $gd_graph_installed){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
690 $graph1 = GD::Graph::lines->new(800,600);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
691 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
692 $graph2 = GD::Graph::lines->new(800,600);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
693 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
694 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
695
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
696 foreach my $context (qw(CpG CHG CHH)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
697 @{$mbias_read1[0]} = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
698
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
699 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
700 print MBIAS "$context context (R1)\n================\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
701 $graph_title = 'M-bias (Read 1)';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
702 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
703 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
704 print MBIAS "$context context\n===========\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
705 $graph_title = 'M-bias';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
706 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
707 print MBIAS "position\tcount methylated\tcount unmethylated\t% methylation\tcoverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
708
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
709 foreach my $pos (1..$max_length_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
710
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
711 unless (defined $mbias_1{$context}->{$pos}->{meth}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
712 $mbias_1{$context}->{$pos}->{meth} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
713 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
714 unless (defined $mbias_1{$context}->{$pos}->{un}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
715 $mbias_1{$context}->{$pos}->{un} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
716 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
717
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
718 my $percent = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
719 if (($mbias_1{$context}->{$pos}->{meth} + $mbias_1{$context}->{$pos}->{un}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
720 $percent = sprintf("%.2f",$mbias_1{$context}->{$pos}->{meth} * 100/ ( $mbias_1{$context}->{$pos}->{meth} + $mbias_1{$context}->{$pos}->{un}) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
721 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
722 my $coverage = $mbias_1{$context}->{$pos}->{un} + $mbias_1{$context}->{$pos}->{meth};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
723
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
724 print MBIAS "$pos\t$mbias_1{$context}->{$pos}->{meth}\t$mbias_1{$context}->{$pos}->{un}\t$percent\t$coverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
725 push @{$mbias_read1[0]},$pos;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
726
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
727 if ($context eq 'CpG'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
728 push @{$mbias_read1[1]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
729 push @{$mbias_read1[4]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
730 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
731 elsif ($context eq 'CHG'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
732 push @{$mbias_read1[2]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
733 push @{$mbias_read1[5]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
734 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
735 elsif ($context eq 'CHH'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
736 push @{$mbias_read1[3]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
737 push @{$mbias_read1[6]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
738 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
739 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
740 print MBIAS "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
741 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
742
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
743 if ( $gd_graph_installed){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
744
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
745 add_colour(nice_blue => [31,120,180]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
746 add_colour(nice_orange => [255,127,0]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
747 add_colour(nice_green => [51,160,44]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
748 add_colour(pale_blue => [153,206,227]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
749 add_colour(pale_orange => [253,204,138]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
750 add_colour(pale_green => [191,230,207]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
751
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
752 $graph1->set(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
753 x_label => 'position (bp)',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
754 y1_label => '% methylation',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
755 y2_label => '# methylation calls',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
756 title => $graph_title,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
757 line_width => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
758 x_max_value => $max_length_1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
759 x_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
760 y_tick_number => 10,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
761 y_label_skip => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
762 y1_max_value => 100,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
763 y1_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
764 y_label_skip => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
765 y2_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
766 x_label_skip => 5,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
767 x_label_position => 0.5,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
768 x_tick_offset => -1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
769 bgclr => 'white',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
770 transparent => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
771 two_axes => 1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
772 use_axis => [1,1,1,2,2,2],
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
773 legend_placement => 'RC',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
774 legend_spacing => 6,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
775 legend_marker_width => 24,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
776 legend_marker_height => 18,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
777 dclrs => [ qw(nice_blue nice_orange nice_green pale_blue pale_orange pale_green)],
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
778 ) or die $graph1->error;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
779
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
780 $graph1->set_legend('CpG methylation','CHG methylation','CHH methylation','CpG total calls','CHG total calls','CHH total calls');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
781
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
782 ### Failure to plot the MBIAS graph will now generate a warning instead of dieing (previous version below. Suggested by Andrew DeiRossi, 05 June 2014)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
783 if (my $gd1 = $graph1->plot(\@mbias_read1)) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
784 open (MBIAS_G1,'>',$mbias_graph_1) or die "Failed to write to file for M-bias plot 1: $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
785 binmode MBIAS_G1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
786 print MBIAS_G1 $gd1->png;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
787 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
788 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
789 warn "WARNING: Cannot generate read 1 M-bias plot: " , $graph1->error , "\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
790 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
791
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
792 # my $gd1 = $graph1->plot(\@mbias_read1) or die $graph1->error;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
793 # open (MBIAS_G1,'>',$mbias_graph_1) or die "Failed to write to file for M-bias plot 1: $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
794 # binmode MBIAS_G1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
795 # print MBIAS_G1 $gd1->png;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
796 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
797
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
798 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
799
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
800 foreach my $context (qw(CpG CHG CHH)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
801 @{$mbias_read2[0]} = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
802
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
803 print MBIAS "$context context (R2)\n================\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
804 print MBIAS "position\tcount methylated\tcount unmethylated\t% methylation\tcoverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
805 foreach my $pos (1..$max_length_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
806
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
807 unless (defined $mbias_2{$context}->{$pos}->{meth}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
808 $mbias_2{$context}->{$pos}->{meth} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
809 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
810 unless (defined $mbias_2{$context}->{$pos}->{un}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
811 $mbias_2{$context}->{$pos}->{un} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
812 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
813
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
814 my $percent = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
815 if (($mbias_2{$context}->{$pos}->{meth} + $mbias_2{$context}->{$pos}->{un}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
816 $percent = sprintf("%.2f",$mbias_2{$context}->{$pos}->{meth} * 100/ ($mbias_2{$context}->{$pos}->{meth} + $mbias_2{$context}->{$pos}->{un}) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
817 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
818 my $coverage = $mbias_2{$context}->{$pos}->{un} + $mbias_2{$context}->{$pos}->{meth};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
819
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
820 print MBIAS "$pos\t$mbias_2{$context}->{$pos}->{meth}\t$mbias_2{$context}->{$pos}->{un}\t$percent\t$coverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
821
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
822 push @{$mbias_read2[0]},$pos;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
823
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
824 if ($context eq 'CpG'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
825 push @{$mbias_read2[1]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
826 push @{$mbias_read2[4]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
827 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
828 elsif ($context eq 'CHG'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
829 push @{$mbias_read2[2]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
830 push @{$mbias_read2[5]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
831 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
832 elsif ($context eq 'CHH'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
833 push @{$mbias_read2[3]},$percent;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
834 push @{$mbias_read2[6]},$coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
835 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
836 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
837 print MBIAS "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
838 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
839
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
840 if ( $gd_graph_installed){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
841
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
842 add_colour(nice_blue => [31,120,180]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
843 add_colour(nice_orange => [255,127,0]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
844 add_colour(nice_green => [51,160,44]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
845 add_colour(pale_blue => [153,206,227]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
846 add_colour(pale_orange => [253,204,138]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
847 add_colour(pale_green => [191,230,207]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
848
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
849 $graph2->set(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
850 x_label => 'position (bp)',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
851 line_width => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
852 x_max_value => $max_length_1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
853 x_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
854 y_tick_number => 10,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
855 y_label_skip => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
856 y1_max_value => 100,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
857 y1_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
858 y_label_skip => 2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
859 y2_min_value => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
860 x_label_skip => 5,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
861 x_label_position => 0.5,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
862 x_tick_offset => -1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
863 bgclr => 'white',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
864 transparent => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
865 two_axes => 1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
866 use_axis => [1,1,1,2,2,2],
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
867 legend_placement => 'RC',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
868 legend_spacing => 6,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
869 legend_marker_width => 24,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
870 legend_marker_height => 18,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
871 dclrs => [ qw(nice_blue nice_orange nice_green pale_blue pale_orange pale_green)],
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
872 x_label => 'position (bp)',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
873 y1_label => '% methylation',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
874 y2_label => '# calls',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
875 title => 'M-bias (Read 2)',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
876 ) or die $graph2->error;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
877
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
878 $graph2->set_legend('CpG methylation','CHG methylation','CHH methylation','CpG total calls','CHG total calls','CHH total calls');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
879
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
880 ### Failure to plot the MBIAS graph will now generate a warning instead of dieing (previous version below. Suggested by Andrew DeiRossi, 05 June 2014)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
881 if (my $gd2 = $graph2->plot(\@mbias_read2)) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
882 open (MBIAS_G2,'>',$mbias_graph_2) or die "Failed to write to file for M-bias plot 2: $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
883 binmode MBIAS_G2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
884 print MBIAS_G2 $gd2->png;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
885 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
886 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
887 warn "WARNING: Cannot generate Read 2 M-bias plot: " , $graph2->error , "\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
888 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
889
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
890 # my $gd2 = $graph2->plot(\@mbias_read2) or die $graph2->error;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
891 # open (MBIAS_G2,'>',$mbias_graph_2) or die "Failed to write to file for M-bias plot 2: $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
892 # binmode MBIAS_G2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
893 # print MBIAS_G2 $gd2->png;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
894
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
895 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
896 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
897 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
898
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
899 sub process_commandline{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
900 my $help;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
901 my $single_end;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
902 my $paired_end;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
903 my $ignore;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
904 my $ignore_r2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
905 my $genomic_fasta;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
906 my $full;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
907 my $report;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
908 my $extractor_version;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
909 my $no_overlap;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
910 my $merge_non_CpG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
911 my $vanilla;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
912 my $output_dir;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
913 my $no_header;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
914 my $bedGraph;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
915 my $coverage_threshold = 1; # Minimum number of reads covering before calling methylation status
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
916 my $remove;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
917 my $counts;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
918 my $cytosine_report;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
919 my $genome_folder;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
920 my $zero;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
921 my $CpG_only;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
922 my $CX_context;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
923 my $split_by_chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
924 my $sort_size;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
925 my $samtools_path;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
926 my $gzip;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
927 my $mbias_only;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
928 my $mbias_off;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
929 my $gazillion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
930 my $ample_mem;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
931 my $include_overlap;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
932 my $ignore_3prime;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
933 my $ignore_3prime_r2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
934 my $multicore;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
935
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
936 my $command_line = GetOptions ('help|man' => \$help,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
937 'p|paired-end' => \$paired_end,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
938 's|single-end' => \$single_end,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
939 'fasta' => \$genomic_fasta,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
940 'ignore=i' => \$ignore,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
941 'ignore_r2=i' => \$ignore_r2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
942 'comprehensive' => \$full,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
943 'report' => \$report,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
944 'version' => \$extractor_version,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
945 'no_overlap' => \$no_overlap,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
946 'merge_non_CpG' => \$merge_non_CpG,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
947 'vanilla' => \$vanilla,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
948 'o|output=s' => \$output_dir,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
949 'no_header' => \$no_header,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
950 'bedGraph' => \$bedGraph,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
951 "cutoff=i" => \$coverage_threshold,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
952 "remove_spaces" => \$remove,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
953 "counts" => \$counts,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
954 "cytosine_report" => \$cytosine_report,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
955 'g|genome_folder=s' => \$genome_folder,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
956 "zero_based" => \$zero,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
957 "CX|CX_context" => \$CX_context,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
958 "split_by_chromosome" => \$split_by_chromosome,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
959 "buffer_size=s" => \$sort_size,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
960 'samtools_path=s' => \$samtools_path,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
961 'gzip' => \$gzip,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
962 'mbias_only' => \$mbias_only,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
963 'mbias_off' => \$mbias_off,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
964 'gazillion|scaffolds' => \$gazillion,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
965 'ample_memory' => \$ample_mem,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
966 'include_overlap' => \$include_overlap,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
967 'ignore_3prime=i' => \$ignore_3prime,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
968 'ignore_3prime_r2=i' => \$ignore_3prime_r2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
969 'multicore=i' => \$multicore,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
970 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
971
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
972 ### EXIT ON ERROR if there were errors with any of the supplied options
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
973 unless ($command_line){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
974 die "Please respecify command line options\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
975 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
976
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
977 ### HELPFILE
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
978 if ($help){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
979 print_helpfile();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
980 exit;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
981 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
982
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
983 if ($extractor_version){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
984 print << "VERSION";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
985
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
986
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
987 Bismark Methylation Extractor
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
988
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
989 Bismark Extractor Version: $version
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
990 Copyright 2010-15 Felix Krueger, Babraham Bioinformatics
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
991 www.bioinformatics.babraham.ac.uk/projects/bismark/
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
992
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
993
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
994 VERSION
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
995 exit;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
996 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
997
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
998
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
999 ### no files provided
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1000 unless (@ARGV){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1001 die "You need to provide one or more Bismark files to create an individual C methylation output. Please respecify!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1002 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1003 @filenames = @ARGV;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1004
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1005 warn "\n *** Bismark methylation extractor version $version ***\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1007 ### M-BIAS ONLY
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1008 if ($mbias_only){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1009
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1010 if ($mbias_off){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1011 die "Options '--mbias_only' and '--mbias_off' are not compatible. Just pick one, mkay?\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1012 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1013 if ($bedGraph){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1014 die "Option '--mbias_only' skips all sorts of methylation extraction, including the bedGraph generation. Please respecify!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1015 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1016 if ($cytosine_report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1017 die "Option '--mbias_only' skips all sorts of methylation extraction, including the genome-wide cytosine methylation report generation. Please respecify!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1018 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1019 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1020 warn "Option '--mbias_only' skips all sorts of methylation extraction, thus '--merge' won't have any effect\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1021 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1022 if ($full){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1023 warn "Option '--mbias_only' skips all sorts of methylation extraction, thus '--comprehensive' won't have any effect\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1024 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1025 sleep(3);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1026 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1027
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1028 ### PRINT A REPORT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1029 unless ($report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1030 $report = 1; # making this the default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1031 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1032
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1033 ### OUTPUT DIR PATH
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1034 if ($output_dir){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1035 unless ($output_dir =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1036 $output_dir =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1037 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1038 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1039 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1040 $output_dir = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1041 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1042
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1043 ### NO HEADER
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1044 unless ($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1045 $no_header = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1046 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1047
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1048 ### OLD (VANILLA) OUTPUT FORMAT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1049 unless ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1050 $vanilla = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1051 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1052
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1053 if ($single_end){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1054 $paired_end = 0; ### SINGLE END ALIGNMENTS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1055 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1056 elsif ($paired_end){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1057 $single_end = 0; ### PAIRED-END ALIGNMENTS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1058 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1059 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1060
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1061 ### we will try to determine whether the input file was a single-end or paired-end sequencing run from the SAM header
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1062
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1063 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1064 die "Please specify whether the supplied file(s) are in Bismark single-end or paired-end format with '-s' or '-p'\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1065 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1066 else{ # SAM/BAM format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1067
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1068 my $file = $filenames[0];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1069 warn "Trying to determine the type of mapping from the SAM header line of file $file\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1070
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1071 ### if the user did not specify whether the alignment file was single-end or paired-end we are trying to get this information from the @PG header line in the SAM/BAM file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1072 if ($file =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1073 open (DETERMINE,"zcat $file |") or die "Unable to read from gzipped file $file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1074 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1075 elsif ($file =~ /\.bam$/ || isBam($file) ){ ### this would allow to read BAM files that do not end in *.bam
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1076 open (DETERMINE,"samtools view -h $file |") or die "Unable to read from BAM file $file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1077 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1078 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1079 open (DETERMINE,$file) or die "Unable to read from $file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1080 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1081
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1082 while (<DETERMINE>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1083 last unless (/^\@/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1084 if ($_ =~ /^\@PG/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1085 # warn "found the \@PG line:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1086 # warn "$_";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1087
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1088 if ($_ =~ /\s+-1\s+/ and $_ =~ /\s+-2\s+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1089 warn "Treating file(s) as paired-end data (as extracted from \@PG line)\n\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1090 $paired_end = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1091 $single_end = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1092 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1093 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1094 warn "Treating file(s) as single-end data (as extracted from \@PG line)\n\n"; sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1095 $paired_end = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1096 $single_end = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1097 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1098 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1101 # close DETERMINE or warn $!; # this always throws an error anyway...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1102
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1103 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1104 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1105
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1106 ### IGNORING <INT> 5' END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1107 # bases at the start of the read when processing the methylation call string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1108 unless ($ignore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1109 $ignore = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1110 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1111
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1112 if (defined $ignore_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1113 die "You can only specify --ignore_r2 for paired-end result files\n" unless ($paired_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1114 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1115 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1116 $ignore_r2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1117 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1118
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1119 ### IGNORING <INT> 3' END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1120 # bases at the end of the read when processing the methylation call string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1121 unless ($ignore_3prime){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1122 $ignore_3prime = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1124
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1125 if (defined $ignore_3prime_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1126 die "You can only specify --ignore_3prime_r2 for paired-end result files\n" unless ($paired_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1127 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1128 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1129 $ignore_3prime_r2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1130 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1132
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1133 ### NO OVERLAP
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1134 ### --no_overlap is the default (as of version 0.12.6), unless someone explicitly asks to include overlaps
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1135 if ($include_overlap){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1136 die "The option '--include_overlap' can only be specified for paired-end input!\n" unless ($paired_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1137 warn "Setting option '--inlcude_overlap' for paired-end data (user-defined)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1138 $no_overlap = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1139 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1140 else{ # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1141 if ($paired_end){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1142 warn "Setting option '--no_overlap' since this is (normally) the right thing to do for paired-end data\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1143 $no_overlap = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1144 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1145 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1146
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1147 ### COMPREHENSIVE OUTPUT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1148 unless ($full){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1149 $full = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1150 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1151
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1152 ### MERGE NON-CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1153 unless ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1154 $merge_non_CpG = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1155 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1156
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1157 ### remove white spaces in read ID (needed for sorting using the sort command
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1158 unless ($remove){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1159 $remove = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1160 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1161
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1162 ### COVERAGE THRESHOLD FOR bedGraph OUTPUT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1163 if (defined $coverage_threshold){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1164 unless ($coverage_threshold > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1165 die "Please select a coverage greater than 0 (positive integers only)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1166 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1167 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1168 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1169 $coverage_threshold = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1170 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1171
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1172 ### SORT buffer size
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1173 if (defined $sort_size){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1174 unless ($sort_size =~ /^\d+\%$/ or $sort_size =~ /^\d+(K|M|G|T)$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1175 die "Please select a buffer size as percentage (e.g. --buffer_size 20%) or a number to be multiplied with K, M, G, T etc. (e.g. --buffer_size 20G). For more information on sort type 'info sort' on a command line\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1176 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1177 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1178 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1179 $sort_size = '2G';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1180 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1181
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1182 if ($zero){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1183 die "Option '--zero' is only available if '--bedGraph' or '--cytosine_report' are specified as well. Please respecify\n" unless ($cytosine_report or $bedGraph);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1184 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1185
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1186 if ($CX_context){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1187 die "Option '--CX_context' is only available if '--bedGraph' or '--cytosine_report' are specified as well. Please respecify\n" unless ($cytosine_report or $bedGraph);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1188 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1189 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1190 $CX_context = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1191 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1192
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1193 unless ($counts){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1194 $counts = 1; # counts will always be set
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1195 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1196
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1197 if ($cytosine_report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1198
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1199 ### GENOME folder
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1200 if ($genome_folder){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1201 unless ($genome_folder =~/\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1202 $genome_folder =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1203 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1204 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1205 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1206 die "Please specify a genome folder to proceed (full path only)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1207 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1208
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1209 unless ($bedGraph){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1210 warn "Setting the option '--bedGraph' since this is required for the genome-wide cytosine report\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1211 $bedGraph = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1212 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1213 unless ($counts){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1214 # warn "Setting the option '--counts' since this is required for the genome-wide cytosine report\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1215 $counts = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1216 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1217 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1218 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1219
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1220 ### PATH TO SAMTOOLS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1221 if (defined $samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1222 # if Samtools was specified as full command
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1223 if ($samtools_path =~ /samtools$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1224 if (-e $samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1225 # Samtools executable found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1226 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1227 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1228 die "Could not find an installation of Samtools at the location $samtools_path. Please respecify\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1230 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1231 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1232 unless ($samtools_path =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1233 $samtools_path =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1234 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1235 $samtools_path .= 'samtools';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1236 if (-e $samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1237 # Samtools executable found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1238 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1239 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1240 die "Could not find an installation of Samtools at the location $samtools_path. Please respecify\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1241 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1242 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1243 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1244 # Check whether Samtools is in the PATH if no path was supplied by the user
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1245 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1246 if (!system "which samtools >/dev/null 2>&1"){ # STDOUT is binned, STDERR is redirected to STDOUT. Returns 0 if Samtools is in the PATH
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1247 $samtools_path = `which samtools`;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1248 chomp $samtools_path;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1249 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1250 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1251
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1252 unless (defined $samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1253 $samtools_path = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1254 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1255
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1256
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1257 if ($gazillion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1258 if ($ample_mem){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1259 die "You can't currently select '--ample_mem' together with '--gazillion'. Make your pick!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1260 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1261 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1262
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1263 if (defined $multicore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1264 unless ($multicore > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1265 die "Core usage needs to be set to 1 or more (currently selected $multicore). Please respecify!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1266 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1267 if ($multicore > 20){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1268 warn "Core usage currently set to more than 20 threads. Let's see how this goes... (set value: $multicore)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1269 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1270 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1271 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1272 $multicore = 1; # default. Single-thread mode
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1273 warn "Setting core usage to single-threaded (default). Consider using --multicore <int> to speed up the extraction process.\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1274 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1275
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1276 return ($ignore,$genomic_fasta,$single_end,$paired_end,$full,$report,$no_overlap,$merge_non_CpG,$vanilla,$output_dir,$no_header,$bedGraph,$remove,$coverage_threshold,$counts,$cytosine_report,$genome_folder,$zero,$CpG_only,$CX_context,$split_by_chromosome,$sort_size,$samtools_path,$gzip,$ignore_r2,$mbias_off,$mbias_only,$gazillion,$ample_mem,$ignore_3prime,$ignore_3prime_r2,$multicore);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1278
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1280 sub test_positional_sorting{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1281
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1282 my $filename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1283
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1284 print "\nNow testing Bismark result file $filename for positional sorting (which would be bad...)\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1285 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1286
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1287 if ($filename =~ /\.gz$/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1288 open (TEST,"zcat $filename |") or die "Can't open gzipped file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1289 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1290 elsif ($filename =~ /bam$/ || isBam($filename) ){ ### this would allow to read BAM files that do not end in *.bam
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1291 if ($samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1292 open (TEST,"$samtools_path view -h $filename |") or die "Can't open BAM file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1293 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1294 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1295 die "Sorry couldn't find an installation of Samtools. Either specifiy an alternative path using the option '--samtools_path /your/path/', or use a SAM file instead\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1296 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1297 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1298 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1299 open (TEST,$filename) or die "Can't open file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1300 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1301
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1302 my $count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1303
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1304 while (<TEST>) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1305 if (/^\@/) { # testing header lines if they contain the @SO flag (for being sorted)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1306 if (/^\@SO/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1307 die "SAM/BAM header line '$_' indicates that the Bismark aligment file has been sorted by chromosomal positions which is is incompatible with correct methylation extraction. Please use an unsorted file instead\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1308 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1309 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1310 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1311 $count++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1312
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1313 last if ($count > 100000); # else we test the first 100000 sequences if they start with the same read ID
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1314
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1315 my ($id_1) = (split (/\t/));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1316
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1317 ### reading the next line which should be read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1318 $_ = <TEST>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1319 my ($id_2) = (split (/\t/));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1320 last unless ($id_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1321 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1322
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1323 if ($id_1 eq $id_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1324 ### ids are the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1325 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1326 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1327 else{ ### in previous versions of Bismark we appended /1 and /2 to the read IDs for easier eyeballing which read is which. These tags need to be removed first
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1328 my $id_1_trunc = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1329 $id_1_trunc =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1330 my $id_2_trunc = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1331 $id_2_trunc =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1332
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1333 unless ($id_1_trunc eq $id_2_trunc){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1334 die "The IDs of Read 1 ($id_1) and Read 2 ($id_2) are not the same. This might be a result of sorting the paired-end SAM/BAM files by chromosomal position which is not compatible with correct methylation extraction. Please use an unsorted file instead\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1335 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1336 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1337 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1338 # close TEST or die $!; somehow fails on our cluster...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1339 ### If it hasen't died so far then it seems the file is in the correct Bismark format (read 1 and read 2 of a pair directly following each other)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1340 warn "...passed!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1341 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1342
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1343 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1344
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1345 sub process_Bismark_results_file{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1346
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1347 my $filename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1348 my $report_filename = open_output_filehandles($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1349
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1350 ### disabling buffering so we don't run into problems with half written out lines...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1351 foreach my $fh (keys %fhs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1352 if ($fh =~ /^[1230]$/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1353 foreach my $context (keys %{$fhs{$fh}}) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1354 select($fhs{$fh}->{$context});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1355 $|++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1356 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1357 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1358 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1359 select($fhs{$fh});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1360 $|++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1361 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1362 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1363 select(STDOUT);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1364
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1365 ################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1366 ################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1367 ### multi-process handling
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1368 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1369
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1370 my $offset = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1371 my $process_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1372 my @pids;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1373 if ($multicore > 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1374
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1375 until ($offset == $multicore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1376 # warn "multicore: $multicore\noffset: $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1377 my $fork = fork;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1378
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1379 if (defined $fork){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1380 if ($fork != 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1381 $process_id = $fork;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1382 push @pids, $process_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1383 if ($offset < $multicore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1384 ++$offset;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1385 # warn "I am the parent process, child pid: $fork\nIncrementing offset counter to: $offset\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1386 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1387 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1388 # warn "Reached the number of maximum multicores. Proceeeding to processing...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1389 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1390 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1391 elsif ($fork == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1392 # warn "I am a child process, pid: $fork\nOffset counter is: $offset\nProceeding to processing...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1393 $process_id = $fork;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1394 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1395 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1396 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1397 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1398 die "Forking unsuccessful. Proceeding using a single thread only\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1399 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1400 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1401
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1402 # warn "\nThe thread identity\n===================\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1403 if ($process_id){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1404 # print "I am the parent process. My children are called:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1405 # print join ("\t",@pids),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1406 # print "I am going to process the following line count: $offset\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1407 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1408 elsif($process_id == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1409 # warn "I am a child process: Process ID: $process_id\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1410 # warn "I am going to process the following line count: $offset\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1411 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1412 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1413 die "Process ID was: $process_id\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1414 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1415 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1416 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1417 # warn "Single-core mode: setting pid to 1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1418 $process_id = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1419 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1420
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1421 ################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1422 ################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1423 if ($process_id){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1424 warn "Now reading in Bismark result file $filename\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1425 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1426 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1427 warn "\nNow reading in Bismark result file $filename\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1428 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1429
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1430 if ($filename =~ /\.gz$/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1431 open (IN,"zcat $filename |") or die "Can't open gzipped file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1432 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1433 elsif ($filename =~ /bam$/ || isBam($filename) ){ ### this would allow to read BAM files that do not end in *.bam
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1434 if ($samtools_path){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1435 open (IN,"$samtools_path view -h $filename |") or die "Can't open BAM file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1436 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1437 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1438 die "Sorry couldn't find an installation of Samtools. Either specifiy an alternative path using the option '--samtools_path /your/path/', or use a SAM file instead\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1439 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1441 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1442 open (IN,$filename) or die "Can't open file $filename: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1443 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1444
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1445 ### Vanilla and SAM output need to read different numbers of header lines
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1446 if ($vanilla) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1447 my $bismark_version = <IN>; ## discarding the Bismark version info
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1448 chomp $bismark_version;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1449 $bismark_version =~ s/\r//; # replaces \r line feed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1450 $bismark_version =~ s/Bismark version: //;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1451 if ($bismark_version =~ /^\@/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1452 warn "Detected \@ as the first character of the version information. Is it possible that the file is in SAM format?\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1453 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1454 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1455
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1456 unless ($version eq $bismark_version){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1457 die "The methylation extractor and Bismark itself need to be of the same version!\n\nVersions used:\nmethylation extractor: '$version'\nBismark: '$bismark_version'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1458 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1459 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1460 # If the read is in SAM format (default) it can either start with @ header lines or start with alignments directly.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1461 # We are reading from it further down
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1462 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1463
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1464 my $methylation_call_strings_processed = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1465 my $line_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1466
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1467 ### proceeding differently now for single-end or paired-end Bismark files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1468
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1469 ### PROCESSING SINGLE-END RESULT FILES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1470 if ($single) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1471
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1472 ### also proceeding differently now for SAM format or vanilla Bismark format files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1473 if ($vanilla) { # old vanilla Bismark output format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1474 while (<IN>) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1475 ++$line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1476 warn "Processed lines: $line_count\n" if ($line_count%500000==0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1477
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1478 if ( ($line_count - $offset)%$multicore == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1479 # warn "line count: $line_count\noffset: $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1480 # warn "Modulus: ",($line_count - $offset)%$multicore,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1481 # warn "processing this line $line_count (processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1482 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1483 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1484 # warn "skipping line $line_count for processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1485 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1486 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1487
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1488 ### $seq here is the chromosomal sequence (to use for the repeat analysis for example)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1489 my ($id,$strand,$chrom,$start,$seq,$meth_call,$read_conversion,$genome_conversion) = (split("\t"))[0,1,2,3,6,7,8,9];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1490
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1491 ### we need to remove 2 bp of the genomic sequence as we were extracting read + 2bp long fragments to make a methylation call at the first or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1492 ### last position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1493 chomp $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1494
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1495 my $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1496 if ($meth_call) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1497
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1498 if ($read_conversion eq 'CT' and $genome_conversion eq 'CT') { ## original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1499 $index = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1500 } elsif ($read_conversion eq 'GA' and $genome_conversion eq 'CT') { ## complementary to original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1501 $index = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1502 } elsif ($read_conversion eq 'CT' and $genome_conversion eq 'GA') { ## original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1503 $index = 3;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1504 } elsif ($read_conversion eq 'GA' and $genome_conversion eq 'GA') { ## complementary to original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1505 $index = 2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1506 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1507 die "Unexpected combination of read and genome conversion: '$read_conversion' / '$genome_conversion'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1508 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1509
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1510 ### Clipping off the first <int> number of bases from the methylation call string as specified with --ignore <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1511 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1512 $meth_call = substr($meth_call,$ignore,length($meth_call)-$ignore);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1513
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1514 ### If we are clipping off some bases at the start we need to adjust the start position of the alignments accordingly!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1515 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1516 $start += $ignore;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1517 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1518 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1519 $start += length($meth_call)-1; ## $meth_call is already shortened!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1520 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1521 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1522 die "Alignment did not have proper strand information: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1523 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1524 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1525
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1526 ### Clipping off the last <int> number of bases from the methylation call string as specified with --ignore_3prime <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1527 if ($ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1528
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1529 $meth_call = substr($meth_call,0, (length($meth_call)) - $ignore_3prime);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1530
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1531 ### If we are clipping off some bases at the end we need to adjust the end position of the alignments accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1532 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1533 # clipping the 3' end does not affect the starting position # ignore 5' has already been taken care of, if relevant at all
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1534 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1535 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1536 # here we need to discriminate if the start has been adjusted because of --ignore or not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1537 if ($ignore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1538 # position adjusted already, and because of this 3' trimming is irrelevant for the start position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1539 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1540 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1541 # Here we need to add the length ignore_3prime to the read starting position, adjustment of the start position will take place later in the methylation extraction step
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1542 $start += $ignore_3prime;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1543 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1544 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1545 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1546 die "Alignment did not have proper strand information: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1547 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1548 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1549 ### just as a comment, if --ignore has not been specified the starting position of reverse reads is adjusted later at the methylation extraction stage
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1550
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1551 ### printing out the methylation state of every C in the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1552 print_individual_C_methylation_states_single_end($meth_call,$chrom,$start,$id,$strand,$index);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1553
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1554 ++$methylation_call_strings_processed; # 1 per single-end result
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1555 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1556 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1557 } else { # processing single-end SAM format (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1558 while (<IN>) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1559 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1560 ### SAM format can either start with header lines (starting with @) or start with alignments directly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1561 if (/^\@/) { # skipping header lines (starting with @)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1562 warn "skipping SAM header line:\t$_\n" unless ($process_id == 0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1563 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1564 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1565
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1566 ++$line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1567 # warn "$line_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1568 warn "Processed lines: $line_count\n" if ($line_count%500000 == 0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1569
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1570 if ( ($line_count - $offset)%$multicore == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1571 # warn "line count: $line_count\noffset: $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1572 # warn "Modulus: ",($line_count - $offset)%$multicore,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1573 # warn "processing this line $line_count (processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1574 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1575 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1576 # warn "skipping line $line_count for processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1577 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1578 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1579
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1580 # example read in SAM format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1581 # 1_R1/1 67 5 103172224 255 40M = 103172417 233 AATATTTTTTTTATTTTAAAATGTGTATTGATTTAAATTT IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII NM:i:4 XX:Z:4T1T24TT7 XM:Z:....h.h........................hh....... XR:Z:CT XG:Z:CT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1582 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1583
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1584 # < 0.7.6 my ($id,$chrom,$start,$meth_call,$read_conversion,$genome_conversion) = (split("\t"))[0,2,3,13,14,15];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1585 # < 0.7.6 $meth_call =~ s/^XM:Z://;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1586 # < 0.7.6 $read_conversion =~ s/^XR:Z://;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1587 # < 0.7.6 $genome_conversion =~ s/^XG:Z://;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1588
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1589 my ($id,$chrom,$start,$cigar) = (split("\t"))[0,2,3,5];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1590
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1591 ### detecting the following SAM flags in case the SAM entry was shuffled by CRAM or Goby compression/decompression
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1592 my $meth_call; ### Thanks to Zachary Zeno for this solution
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1593 my $read_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1594 my $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1595
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1596 while ( /(XM|XR|XG):Z:([^\t]+)/g ) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1597 my $tag = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1598 my $value = $2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1599
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1600 if ($tag eq "XM") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1601 $meth_call = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1602 $meth_call =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1603 } elsif ($tag eq "XR") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1604 $read_conversion = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1605 $read_conversion =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1606 } elsif ($tag eq "XG") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1607 $genome_conversion = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1608 $genome_conversion =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1609 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1610 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1611
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1612 my $strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1613 # warn "$meth_call\n$read_conversion\n$genome_conversion\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1614
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1615 my $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1616 if ($meth_call) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1617 if ($read_conversion eq 'CT' and $genome_conversion eq 'CT') { ## original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1618 $index = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1619 $strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1620 } elsif ($read_conversion eq 'GA' and $genome_conversion eq 'CT') { ## complementary to original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1621 $index = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1622 $strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1623 } elsif ($read_conversion eq 'GA' and $genome_conversion eq 'GA') { ## complementary to original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1624 $index = 2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1625 $strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1626 } elsif ($read_conversion eq 'CT' and $genome_conversion eq 'GA') { ## original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1627 $index = 3;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1628 $strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1629 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1630 die "Unexpected combination of read and genome conversion: '$read_conversion' / '$genome_conversion'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1631 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1632
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1633 ### If the read is in SAM format we need to reverse the methylation call if the read has been reverse-complemented for the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1634 if ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1635 $meth_call = reverse $meth_call;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1636 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1637 # warn "\n$meth_call\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1638
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1639 ### IGNORE 5 PRIME: Clipping off the first <int> number of bases from the methylation call string as specified with --ignore <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1640 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1641 # warn "\n\n$meth_call\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1642 $meth_call = substr($meth_call,$ignore,length($meth_call)-$ignore);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1643 # warn "$meth_call\n";sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1644
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1645 ### If we are ignoring a part of the sequence we also need to adjust the cigar string accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1646
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1647 my @len = split (/\D+/,$cigar); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1648 my @ops = split (/\d+/,$cigar); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1649 shift @ops; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1650 die "CIGAR string contained a non-matching number of lengths and operations\n" unless (scalar @len == scalar @ops);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1651
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1652 my @comp_cigar; # building an array with all CIGAR operations
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1653 foreach my $index (0..$#len) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1654 foreach (1..$len[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1655 # print "$ops[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1656 push @comp_cigar, $ops[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1657 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1658 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1659 # print "original CIGAR: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1660 # print "original CIGAR: @comp_cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1661
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1662 ### If we are clipping off some bases at the start we need to adjust the start position of the alignments accordingly!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1663 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1664
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1665 my $D_count = 0; # counting all deletions that affect the ignored genomic position, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1666 my $I_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1667
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1668 for (1..$ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1669 my $op = shift @comp_cigar; # adjusting composite CIGAR string by removing $ignore operations from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1670 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1671
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1672 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1673 $D_count++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1674 $op = shift @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1675 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1676 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1677 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1678 $I_count++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1679 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1680 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1681 $start += $ignore + $D_count - $I_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1682 # print "start $start\t ignore: $ignore\t D count: $D_count I_count: $I_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1683 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1684 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1685
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1686 for (1..$ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1687 my $op = pop @comp_cigar; # adjusting composite CIGAR string by removing $ignore operations, here the last value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1688 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1689 $op = pop @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1690 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1691 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1692
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1693 ### For reverse strand alignments we need to determine the number of matching bases (M) or deletions (D) in the read from the CIGAR
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1694 ### string to be able to work out the starting position of the read which is on the 3' end of the sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1695 my $MD_count = 0; # counting all operations that affect the genomic position, i.e. M and D. Insertions do not affect the start position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1696 foreach (@comp_cigar) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1697 ++$MD_count if ($_ eq 'M' or $_ eq 'D');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1698 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1699 $start += $MD_count - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1700 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1701
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1702 ### reconstituting shortened CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1703 my $new_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1704 my $count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1705 my $last_op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1706 # print "ignore adjusted: @comp_cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1707 foreach my $op (@comp_cigar) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1708 unless (defined $last_op){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1709 $last_op = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1710 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1711 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1712 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1713 if ($last_op eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1714 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1715 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1716 $new_cigar .= "$count$last_op";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1717 $last_op = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1718 $count = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1719 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1720 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1721 $new_cigar .= "$count$last_op"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1722 $cigar = $new_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1723 # print "ignore adjusted scalar: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1724 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1725
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1726 #######################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1727 ### INGORE 3' END ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1728 #######################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1729
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1730 # Clipping off the last <int> number of bases from the methylation call string as specified with --ignore_3prime <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1731 if ($ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1732 # warn "$meth_call\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1733 $meth_call = substr($meth_call,0, (length($meth_call)) - $ignore_3prime);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1734 # warn "$meth_call\n";sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1735
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1736 ### If we are ignoring a part of the sequence we also need to adjust the cigar string accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1737
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1738 my @len = split (/\D+/,$cigar); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1739 my @ops = split (/\d+/,$cigar); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1740 shift @ops; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1741 die "CIGAR string contained a non-matching number of lengths and operations\n" unless (scalar @len == scalar @ops);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1742
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1743 my @comp_cigar; # building an array with all CIGAR operations
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1744 foreach my $index (0..$#len) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1745 foreach (1..$len[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1746 # print "$ops[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1747 push @comp_cigar, $ops[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1748 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1749 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1750
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1751 # print "original CIGAR: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1752 # print join ("",@comp_cigar),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1753
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1754 ### If we are clipping off some bases at the end we might have to adjust the start position of the alignments accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1755 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1756
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1757 ### clipping the 3' end does not affect the starting position of forward strand alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1758 # ignore 5' has already been taken care of at this stage, if relevant at all
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1759
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1760 for (1..$ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1761 my $op = pop @comp_cigar; # adjusting composite CIGAR string by removing $ignore_3prime operations from the end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1762 # print join ("",@comp_cigar),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1763 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1764 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1765 $op = pop @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1766 # print join ("",@comp_cigar),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1767 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1768 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1770 # print "Final truncated CIGAR string:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1771 # print join ("",@comp_cigar),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1772 # $start += $ignore + $D_count - $I_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1773 # print "start $start\t ignore_3prime: $ignore_3prime\t D count: $D_count I_count: $I_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1774 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1775 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1776
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1777 my $D_count = 0; # counting all deletions that affect the ignored genomic position, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1778 my $I_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1779
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1780 for (1..$ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1781 my $op = shift @comp_cigar; # adjusting composite CIGAR string by removing $ignore_3prime operations, here the first value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1782 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1783 $D_count++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1784 $op = shift @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1785 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1786 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1787 $I_count++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1788 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1789
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1790 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1791
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1792 # here we need to discriminate if the start has been adjusted because of --ignore or not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1793 if ($ignore){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1794 # the start position has already been modified for --ignore already, so we don't have to adjust the position again now
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1795 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1796 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1797 # Here we need to add the length ignore_3prime to the read starting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1798 # adjustment of the true starting position of this reverse read will take place later in the methylation extraction step
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1799 $start += $ignore_3prime + $D_count - $I_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1800 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1801
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1802 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1803
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1804 ### reconstituting shortened CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1805 my $new_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1806 my $count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1807 my $last_op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1808 # print "ignore_3prime adjusted:\n"; print join ("",@comp_cigar),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1809 foreach my $op (@comp_cigar) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1810 unless (defined $last_op){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1811 $last_op = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1812 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1813 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1814 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1815 if ($last_op eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1816 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1817 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1818 $new_cigar .= "$count$last_op";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1819 $last_op = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1820 $count = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1821 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1822 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1823 $new_cigar .= "$count$last_op"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1824 $cigar = $new_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1825 # print "ignore_3prime adjusted scalar: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1826 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1827 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1828 ### printing out the methylation state of every C in the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1829 print_individual_C_methylation_states_single_end($meth_call,$chrom,$start,$id,$strand,$index,$cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1830
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1831 ++$methylation_call_strings_processed; # 1 per single-end result
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1832 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1833 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1834 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1835
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1836 ### PROCESSING PAIRED-END RESULT FILES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1837 elsif ($paired) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1838
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1839 ### proceeding differently now for SAM format or vanilla Bismark format files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1840 if ($vanilla) { # old vanilla Bismark paired-end output format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1841 while (<IN>) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1842 ++$line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1843 warn "processed line: $line_count\n" if ($line_count%500000 == 0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1844
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1845 if ( ($line_count - $offset)%$multicore == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1846 # warn "line count: $line_count\noffset: $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1847 # warn "Modulus: ",($line_count - $offset)%$multicore,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1848 # warn "processing this line $line_count (processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1849 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1850 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1851 # warn "skipping line $line_count for processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1852 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1853 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1854
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1855 ### $seq here is the chromosomal sequence (to use for the repeat analysis for example)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1856 my ($id,$strand,$chrom,$start_read_1,$end_read_2,$seq_1,$meth_call_1,$seq_2,$meth_call_2,$first_read_conversion,$genome_conversion) = (split("\t"))[0,1,2,3,4,6,7,9,10,11,12,13];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1857
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1858 my $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1859 chomp $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1860
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1861 if ($first_read_conversion eq 'CT' and $genome_conversion eq 'CT') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1862 $index = 0; ## this is OT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1863 } elsif ($first_read_conversion eq 'GA' and $genome_conversion eq 'GA') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1864 $index = 2; ## this is CTOB!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1865 } elsif ($first_read_conversion eq 'GA' and $genome_conversion eq 'CT') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1866 $index = 1; ## this is CTOT!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1867 } elsif ($first_read_conversion eq 'CT' and $genome_conversion eq 'GA') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1868 $index = 3; ## this is OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1869 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1870 die "Unexpected combination of read and genome conversion: $first_read_conversion / $genome_conversion\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1871 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1872
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1873 if ($meth_call_1 and $meth_call_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1874 ### Clipping off the first <int> number of bases from the methylation call strings as specified with '--ignore <int>'
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1875
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1876 ### IGNORE FROM 5' END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1877 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1878 $meth_call_1 = substr($meth_call_1,$ignore,length($meth_call_1)-$ignore);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1879
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1880 ### we also need to adjust the start and end positions of the alignments accordingly if '--ignore' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1881 $start_read_1 += $ignore;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1882 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1883 if ($ignore_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1884 $meth_call_2 = substr($meth_call_2,$ignore_r2,length($meth_call_2)-$ignore_r2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1885
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1886 ### we also need to adjust the start and end positions of the alignments accordingly if '--ignore_r2' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1887 $end_read_2 -= $ignore_r2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1888 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1889
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1890 ### IGNORE 3' END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1891
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1892 ### Clipping off the last <int> number of bases from the methylation call string of Read 1 as specified with --ignore_3prime <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1893 if ($ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1894 $meth_call_1 = substr($meth_call_1,0, length($meth_call_1) - $ignore_3prime);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1895 # we don't have to adjust the position now since the shortened methylation call will be fine, see below
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1896 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1897 ### Clipping off the last <int> number of bases from the methylation call string of Read 2 as specified with --ignore_3prime_r2 <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1898 if ($ignore_3prime_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1899 $meth_call_2 = substr($meth_call_2,0, length($meth_call_2) - $ignore_3prime_r2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1900 # we don't have to adjust the position now since the shortened methylation call will be fine, see below
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1901 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1902
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1903 my $end_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1904 my $start_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1905
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1906 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1907
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1908 $end_read_1 = $start_read_1 + length($meth_call_1) - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1909 $start_read_2 = $end_read_2 - length($meth_call_2) + 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1910
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1911 ## we first pass the first read which is in + orientation on the forward strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1912 print_individual_C_methylation_states_paired_end_files($meth_call_1,$chrom,$start_read_1,$id,'+',$index,0,0,undef,1); # the last two values are CIGAR string and read identity
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1913
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1914 # we next pass the second read which is in - orientation on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1915 ### if --no_overlap was specified we also pass the end of read 1. If read 2 starts to overlap with read 1 we can stop extracting methylation calls from read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1916 print_individual_C_methylation_states_paired_end_files($meth_call_2,$chrom,$end_read_2,$id,'-',$index,$no_overlap,$end_read_1,undef,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1917 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1918 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1919
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1920 $end_read_1 = $start_read_1+length($meth_call_2)-1; # read 1 is the second reported read!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1921 $start_read_2 = $end_read_2-length($meth_call_1)+1; # read 2 is the first reported read!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1922
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1923 ## we first pass the first read which is in - orientation on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1924 print_individual_C_methylation_states_paired_end_files($meth_call_1,$chrom,$end_read_2,$id,'-',$index,0,0,undef,1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1925
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1926 # we next pass the second read which is in + orientation on the forward strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1927 ### if --no_overlap was specified we also pass the end of read 2. If read 2 starts to overlap with read 1 we will stop extracting methylation calls from read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1928 print_individual_C_methylation_states_paired_end_files($meth_call_2,$chrom,$start_read_1,$id,'+',$index,$no_overlap,$start_read_2,undef,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1929 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1930
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1931 $methylation_call_strings_processed += 2; # paired-end = 2 methylation calls
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1932 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1933 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1934 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1935 else { # Bismark paired-end BAM/SAM output format (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1936 while (<IN>) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1937 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1938 ### SAM format can either start with header lines (starting with @) or start with alignments directly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1939 if (/^\@/) { # skipping header lines (starting with @)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1940 warn "skipping SAM header line:\t$_\n" unless ($process_id == 0); # no additional warnings for child procesess
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1941 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1942 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1943
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1944 ++$line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1945 warn "Processed lines: $line_count\n" if ($line_count%500000==0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1946
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1947 if ( ($line_count - $offset)%$multicore == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1948 # warn "line count: $line_count\noffset: $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1949 # warn "Modulus: ",($line_count - $offset)%$multicore,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1950 # warn "processing this line $line_count (processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1951 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1952 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1953 # warn "skipping line $line_count for processID: $process_id with \$offset $offset)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1954 $_ = <IN>; # reading and skipping another line since this is the paired-end read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1955 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1956 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1957
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1958 # example paired-end reads in SAM format (2 consecutive lines)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1959 # 1_R1/1 67 5 103172224 255 40M = 103172417 233 AATATTTTTTTTATTTTAAAATGTGTATTGATTTAAATTT IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII NM:i:4 XX:Z:4T1T24TT7 XM:Z:....h.h........................hh....... XR:Z:CT XG:Z:CT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1960 # 1_R1/2 131 5 103172417 255 40M = 103172224 -233 TATTTTTTTTTAGAGTATTTTTTAATGGTTATTAGATTTT IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII NM:i:6 XX:Z:T5T1T9T9T7T3 XM:Z:h.....h.h.........h.........h.......h... XR:Z:GA XG:Z:CT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1961
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1962 my ($id_1,$chrom,$start_read_1,$cigar_1) = (split("\t"))[0,2,3,5]; ### detecting the following SAM flags in case the SAM entry was shuffled by CRAM or Goby compression/decompression
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1963 my $meth_call_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1964 my $first_read_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1965 my $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1966
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1967 while ( /(XM|XR|XG):Z:([^\t]+)/g ) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1968 my $tag = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1969 my $value = $2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1970
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1971 if ($tag eq "XM") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1972 $meth_call_1 = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1973 $meth_call_1 =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1974 } elsif ($tag eq "XR") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1975 $first_read_conversion = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1976 $first_read_conversion =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1977 } elsif ($tag eq "XG") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1978 $genome_conversion = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1979 $genome_conversion =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1980 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1981 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1982
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1983 $_ = <IN>; # reading in the paired read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1984 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1985
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1986 my ($id_2,$start_read_2,$cigar_2) = (split("\t"))[0,3,5]; ### detecting the following SAM flags in case the SAM entry was shuffled by CRAM or Goby compression/decompression
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1987
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1988 my $meth_call_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1989 my $second_read_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1990
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1991 while ( /(XM|XR):Z:([^\t]+)/g ) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1992 my $tag = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1993 my $value = $2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1994
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1995 if ($tag eq "XM") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1996 $meth_call_2 = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1997 $meth_call_2 =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1998 } elsif ($tag eq "XR") {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1999 $second_read_conversion = $value;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2000 $second_read_conversion = s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2001 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2002 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2003
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2004 # < version 0.7.6 $genome_conversion =~ s/^XG:Z://;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2005 # chomp $genome_conversion; # in case it captured a new line character # already removed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2007 # print join ("\t",$meth_call_1,$meth_call_2,$first_read_conversion,$second_read_conversion,$genome_conversion),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2008
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2009 my $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2010 my $strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2012 if ($first_read_conversion eq 'CT' and $genome_conversion eq 'CT') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2013 $index = 0; ## this is OT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2014 $strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2015 } elsif ($first_read_conversion eq 'GA' and $genome_conversion eq 'CT') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2016 $index = 1; ## this is CTOT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2017 $strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2018 } elsif ($first_read_conversion eq 'GA' and $genome_conversion eq 'GA') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2019 $index = 2; ## this is CTOB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2020 $strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2021 } elsif ($first_read_conversion eq 'CT' and $genome_conversion eq 'GA') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2022 $index = 3; ## this is OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2023 $strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2024 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2025 die "Unexpected combination of read and genome conversion: $first_read_conversion / $genome_conversion\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2026 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2027
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2028 ### reversing the methylation call of the read that was reverse-complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2029 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2030 $meth_call_2 = reverse $meth_call_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2031 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2032 $meth_call_1 = reverse $meth_call_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2033 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2034 # warn "\n$meth_call_1\n$meth_call_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2035
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2036 if ($meth_call_1 and $meth_call_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2037
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2038 my $end_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2039
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2040 ### READ 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2041 my @len_1 = split (/\D+/,$cigar_1); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2042 my @ops_1 = split (/\d+/,$cigar_1); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2043 shift @ops_1; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2044
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2045 die "CIGAR string contained a non-matching number of lengths and operations: $cigar_1\n".join(" ",@len_1)."\n".join(" ",@ops_1)."\n" unless (scalar @len_1 == scalar @ops_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2046
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2047 my @comp_cigar_1; # building an array with all CIGAR operations
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2048 foreach my $index (0..$#len_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2049 foreach (1..$len_1[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2050 # print "$ops_1[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2051 push @comp_cigar_1, $ops_1[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2052 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2053 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2054 # print "original CIGAR read 1: $cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2055 # print "original CIGAR read 1: @comp_cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2056
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2057 ### READ 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2058 my @len_2 = split (/\D+/,$cigar_2); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2059 my @ops_2 = split (/\d+/,$cigar_2); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2060 shift @ops_2; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2061 die "CIGAR string contained a non-matching number of lengths and operations\n" unless (scalar @len_2 == scalar @ops_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2062 my @comp_cigar_2; # building an array with all CIGAR operations for read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2063 foreach my $index (0..$#len_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2064 foreach (1..$len_2[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2065 # print "$ops_2[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2066 push @comp_cigar_2, $ops_2[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2067 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2068 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2069 # print "original CIGAR read 2: $cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2070 # print "original CIGAR read 2: @comp_cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2071
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2072 ##################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2073 ### IGNORE BASES FROM 5' END ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2074 ##################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2075
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2076 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2077 ### Clipping off the first <int> number of bases from the methylation call string as specified with '--ignore <int>' for read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2078 ### the methylation calls have already been reversed where necessary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2079
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2080 if ( (length($meth_call_1) - $ignore) <= 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2081 # next; # skipping this read entirely if the read is shorter than the portion to be ignored
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2082 $meth_call_1 = undef; # will skip this read entirely since the read is shorter than the portion to be ignored
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2083 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2084 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2085 $meth_call_1 = substr($meth_call_1,$ignore,length($meth_call_1)-$ignore);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2086
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2087 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2088
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2089 ### if the (read 1) strand information is '+', read 1 needs to be trimmed from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2090 my $D_count_1 = 0; # counting all deletions that affect the ignored genomic position for read 1, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2091 my $I_count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2092
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2093 for (1..$ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2094 my $op = shift @comp_cigar_1; # adjusting composite CIGAR string of read 1 by removing $ignore operations from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2095 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2096
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2097 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2098 $D_count_1++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2099 $op = shift @comp_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2100 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2101 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2102 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2103 $I_count_1++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2104 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2105 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2106
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2107 $start_read_1 += $ignore + $D_count_1 - $I_count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2108 # print "start read 1 $start_read_1\t ignore: $ignore\t D count 1: $D_count_1\tI_count 1: $I_count_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2109
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2110 # the start position of reads mapping to the reverse strand is being adjusted further below
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2111 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2112 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2113
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2114 ### if the (read 1) strand information is '-', read 1 needs to be trimmed from the back
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2115 for (1..$ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2116 my $op = pop @comp_cigar_1; # adjusting composite CIGAR string by removing $ignore operations, here the last value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2117 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2118 $op = pop @comp_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2119 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2120 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2121 # the start position of reads mapping to the reverse strand is being adjusted further below
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2122
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2124 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2125 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2126
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2127 if ($ignore_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2128 ### Clipping off the first <int> number of bases from the methylation call string as specified with '--ignore_r2 <int>' for read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2129 ### the methylation calls have already been reversed where necessary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2130
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2131 if ( (length($meth_call_2) - $ignore_r2) <= 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2132 # next; # skipping this read entirely if the read is shorter than the portion to be ignored # this would skip the entire read pair!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2133 $meth_call_2 = undef; # will skip this read entirely since the read is shorter than the portion to be ignored
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2134 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2135 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2136 $meth_call_2 = substr($meth_call_2,$ignore_r2,length($meth_call_2)-$ignore_r2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2137
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2138 ### If we are ignoring a part of the sequence we also need to adjust the cigar string accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2139
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2140 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2141
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2142 ### if the (read 1) strand information is '+', read 2 needs to be trimmed from the back
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2143
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2144 for (1..$ignore_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2145 my $op = pop @comp_cigar_2; # adjusting composite CIGAR string by removing $ignore operations, here the last value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2146 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2147 $op = pop @comp_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2148 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2149 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2150 # the start position of reads mapping to the reverse strand is being adjusted further below
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2151 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2152 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2153
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2154 ### if the (read 1) strand information is '-', read 2 needs to be trimmed from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2155 my $D_count_2 = 0; # counting all deletions that affect the ignored genomic position for read 2, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2156 my $I_count_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2157
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2158 for (1..$ignore_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2159 my $op = shift @comp_cigar_2; # adjusting composite CIGAR string of read 2 by removing $ignore operations from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2160 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2161
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2162 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2163 $D_count_2++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2164 $op = shift @comp_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2165 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2166 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2167 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2168 $I_count_2++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2169 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2170 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2171
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2172 $start_read_2 += $ignore_r2 + $D_count_2 - $I_count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2173 # print "start read 2 $start_read_2\t ignore R2: $ignore_r2\t D count 2: $D_count_2\tI_count 2: $I_count_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2174 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2175 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2176 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2177
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2178 if ($ignore and $meth_call_1){ # if the methylation call string is undefined at this position we don't need any new CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2179
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2180 ### reconstituting shortened CIGAR string 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2181 my $new_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2182 my $count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2183 my $last_op_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2184 # print "ignore adjusted CIGAR 1: @comp_cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2185 foreach my $op (@comp_cigar_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2186 unless (defined $last_op_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2187 $last_op_1 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2188 ++$count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2189 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2190 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2191 if ($last_op_1 eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2192 ++$count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2193 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2194 $new_cigar_1 .= "$count_1$last_op_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2195 $last_op_1 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2196 $count_1 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2197 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2198 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2199 $new_cigar_1 .= "$count_1$last_op_1"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2200 $cigar_1 = $new_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2201 # print "ignore adjusted CIGAR 1 scalar: $cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2202 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2203
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2204 if ($ignore_r2 and $meth_call_2){ # if the methylation call string is undefined at this point we don't need any new CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2205
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2206 ### reconstituting shortened CIGAR string 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2207 my $new_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2208 my $count_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2209 my $last_op_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2210 # print "ignore adjusted CIGAR 2: @comp_cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2211 foreach my $op (@comp_cigar_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2212 unless (defined $last_op_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2213 $last_op_2 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2214 ++$count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2215 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2216 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2217 if ($last_op_2 eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2218 ++$count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2219 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2220 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2221 $new_cigar_2 .= "$count_2$last_op_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2222 $last_op_2 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2223 $count_2 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2224 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2225 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2226 $new_cigar_2 .= "$count_2$last_op_2"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2227 $cigar_2 = $new_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2228 # print "ignore_r2 adjusted CIGAR 2 scalar: $cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2230
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2231 ###########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2232 ### END IGNORE 5' END ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2233 ###########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2234
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2235 ##################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2236 ### IGNORE BASES FROM 3' END ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2237 ##################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2238
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2239 # print "CIGAR string before truncating 3' end (Read 1)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2240 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2241
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2242 if ($ignore_3prime and $meth_call_1) { # if the methylation call string is undefined at this point we don't need to process the read any further
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2243
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2244 ### Clipping off the last <int> number of bases from the methylation call string as specified with '--ignore_3prime <int>' for read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2245 ### the methylation calls have already been reversed where necessary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2246
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2247 if ( (length($meth_call_1) - $ignore_3prime) <= 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2248 $meth_call_1 = undef; # will skip this read entirely since the read is shorter than the portion to be ignored
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2249 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2250 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2251 $meth_call_1 = substr($meth_call_1,0,length($meth_call_1) - $ignore_3prime);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2252 # warn "truncated meth_call 1:\n$meth_call_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2253
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2254 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2255
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2256 ### if the (read 1) strand information is '+', clipping the 3' end does not affect the starting position of forward strand alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2257 # ignore 5' has already been taken care of at this stage, if relevant at all
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2258
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2259 for (1..$ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2260 my $op = pop @comp_cigar_1; # adjusting composite CIGAR string of read 1 by removing $ignore_3prime operations from the end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2261 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2262 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2263
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2264 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2265 $op = pop @comp_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2266 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2267 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2268 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2269 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2270
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2271 # print "Final truncated CIGAR string (Read 1):\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2272 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2273
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2274 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2275 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2276
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2277 my $D_count_1 = 0; # counting all deletions that affect the ignored genomic position for read 1, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2278 my $I_count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2280 ### if the (read 1) strand information is '-', the read 1 CIGAR string needs to be trimmed from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2281 for (1..$ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2282 my $op = shift @comp_cigar_1; # adjusting composite CIGAR string by removing $ignore_3prime operations, here the first value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2283 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2284
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2285 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2286 $D_count_1++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2287 $op = shift @comp_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2288 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2289 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2290
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2291 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2292 $I_count_1++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2293 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2294 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2295
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2296 # print "Final truncated CIGAR string reverse_read:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2297 # print join ("",@comp_cigar_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2298
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2299 # Here we need to add the length ignore_3prime to the read starting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2300 # adjustment of the true start position of this reverse read will take place later in the methylation extraction step
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2301 $start_read_1 += $ignore_3prime + $D_count_1 - $I_count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2302
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2303 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2304 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2305 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2306
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2307 if ($ignore_3prime_r2 and $meth_call_2) { # if the methylation call string is undefined at this point we don't need to process the read any further
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2308
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2309 ### Clipping off the last <int> number of bases from the methylation call string as specified with '--ignore_3prime_r2 <int>' for read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2310 ### the methylation calls have already been reversed where necessary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2311
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2312 if ( (length($meth_call_2) - $ignore_3prime_r2) <= 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2313 $meth_call_2 = undef; # will skip this read entirely since the read is shorter than the portion to be ignored
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2314 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2315 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2316 $meth_call_2 = substr($meth_call_2,0,length($meth_call_2) - $ignore_3prime_r2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2317 # warn "truncated meth_call 2:\n$meth_call_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2318
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2319 ### If we are ignoring a part of the sequence we also need to adjust the cigar string and the positions accordingly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2320
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2321 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2322
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2323 ### if the (read 1) strand information is '+', clipping the 3' end of read 2 does potentially affect the starting position of read 2 (reverse strand alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2324 ### if the (read 1) strand information is '+', read 2 needs to be trimmed from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2325
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2326 my $D_count_2 = 0; # counting all deletions that affect the ignored genomic position for read 2, i.e. Deletions and insertions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2327 my $I_count_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2328
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2329 for (1..$ignore_3prime_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2330 my $op = shift @comp_cigar_2; # adjusting composite CIGAR string by removing $ignore operations, here the first value of the array
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2331 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2332 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2333
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2334 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2335 $D_count_2++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2336 $op = shift @comp_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2337 # print "$_ deleted $op from 3' end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2338 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2339 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2340
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2341 if ($op eq 'I') { # adjusting the genomic position for insertions (I)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2342 $I_count_2++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2343 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2344 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2345
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2346 # print "Final truncated CIGAR string 2 (+ alignment):\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2347 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2348
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2349 # Here we need to add the length ignore_3prime_r2 to the read starting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2350 # adjustment of the true start position of this reverse read will take place later in the methylation extraction step
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2351 $start_read_2 += $ignore_3prime_r2 + $D_count_2 - $I_count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2352
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2353 # print "start read 2 $start_read_2\t ignore R2: $ignore_r2\t D count 2: $D_count_2\tI_count 2: $I_count_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2354 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2355 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2356 ### if the (read 1) strand information is '-', clipping the 3' end of read 2 does not affect its starting position (forward strand alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2357 ### ignore_r2 5' has already been taken care of at this stage, if relevant at all
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2358
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2359 ### if the (read 1) strand information is '-', read 2 needs to be trimmed from the end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2360
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2361 for (1..$ignore_3prime_r2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2362 my $op = pop @comp_cigar_2; # adjusting composite CIGAR string of read 2 by removing $ignore operations from the start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2363 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2364 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2365
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2366 while ($op eq 'D') { # repeating this for deletions (D)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2367 $op = pop @comp_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2368 # print "$_ deleted $op\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2369 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2370 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2371 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2372
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2373 # print "Final truncated CIGAR string 2 (- alignment):\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2374 # print join ("",@comp_cigar_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2375
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2376 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2377 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2378 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2379
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2380 if ($ignore_3prime and $meth_call_1){ # if the methylation call string is undefined at this point we don't need any new CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2381
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2382 ### reconstituting shortened CIGAR string 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2383 my $new_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2384 my $count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2385 my $last_op_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2386 # print "ignore_3prime adjusted CIGAR 1: @comp_cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2387 foreach my $op (@comp_cigar_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2388 unless (defined $last_op_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2389 $last_op_1 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2390 ++$count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2391 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2392 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2393 if ($last_op_1 eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2394 ++$count_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2395 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2396 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2397 $new_cigar_1 .= "$count_1$last_op_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2398 $last_op_1 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2399 $count_1 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2400 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2401 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2402 $new_cigar_1 .= "$count_1$last_op_1"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2403 $cigar_1 = $new_cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2404 # warn "ignore_3prime adjusted CIGAR 1 scalar: $cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2405 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2406
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2407 if ($ignore_3prime_r2 and $meth_call_2){ # if the methylation call string is undefined at this point we don't need any new CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2408
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2409 ### reconstituting shortened CIGAR string 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2410 my $new_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2411 my $count_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2412 my $last_op_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2413 # print "ignore_3prime_r2 adjusted CIGAR 2: @comp_cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2414 foreach my $op (@comp_cigar_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2415 unless (defined $last_op_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2416 $last_op_2 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2417 ++$count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2418 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2419 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2420 if ($last_op_2 eq $op) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2421 ++$count_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2423 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2424 $new_cigar_2 .= "$count_2$last_op_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2425 $last_op_2 = $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2426 $count_2 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2427 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2428 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2429 $new_cigar_2 .= "$count_2$last_op_2"; # appending the last operation and count
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2430 $cigar_2 = $new_cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2431 # warn "ignore_3prime_r2 adjusted CIGAR 2 scalar: $cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2432 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2433
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2434 ###########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2435 ### END IGNORE 3' END ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2436 ###########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2437
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2438
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2439 ### Adjusting CIGAR string and starting position of reads in reverse orientation which we will pass to the extraction subroutine later on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2440
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2441 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2442 ### adjusting the start position for all reads mapping to the reverse strand, in this case read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2443 @comp_cigar_2 = reverse@comp_cigar_2; # the CIGAR string needs to be reversed for all reads aligning to the reverse strand, too
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2444 # print "reverse: @comp_cigar_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2445
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2446 my $MD_count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2447 foreach (@comp_cigar_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2448 ++$MD_count_1 if ($_ eq 'M' or $_ eq 'D'); # Matching bases or deletions affect the genomic position of the 3' ends of reads, insertions don't
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2449 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2450
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2451 my $MD_count_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2452 foreach (@comp_cigar_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2453 ++$MD_count_2 if ($_ eq 'M' or $_ eq 'D'); # Matching bases or deletions affect the genomic position of the 3' ends of reads, insertions don't
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2454 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2455
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2456 $end_read_1 = $start_read_1 + $MD_count_1 - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2457 $start_read_2 += $MD_count_2 - 1; ## Passing on the start position on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2458 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2459 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2460 ### adjusting the start position for all reads mapping to the reverse strand, in this case read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2461
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2462 @comp_cigar_1 = reverse@comp_cigar_1; # the CIGAR string needs to be reversed for all reads aligning to the reverse strand, too
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2463 # print "reverse: @comp_cigar_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2464
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2465 my $MD_count_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2466 foreach (@comp_cigar_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2467 ++$MD_count_1 if ($_ eq 'M' or $_ eq 'D'); # Matching bases or deletions affect the genomic position of the 3' ends of reads, insertions don't
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2468 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2469
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2470 $end_read_1 = $start_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2471 $start_read_1 += $MD_count_1 - 1; ### Passing on the start position on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2472 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2473
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2474 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2475 ## we first pass the first read which is in + orientation on the forward strand; the last value is the read identity
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2476 print_individual_C_methylation_states_paired_end_files($meth_call_1,$chrom,$start_read_1,$id_1,'+',$index,0,0,$cigar_1,1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2477
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2478 # we next pass the second read which is in - orientation on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2479 ### if --no_overlap was specified we also pass the end of read 1. If read 2 starts to overlap with read 1 we can stop extracting methylation calls from read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2480 print_individual_C_methylation_states_paired_end_files($meth_call_2,$chrom,$start_read_2,$id_2,'-',$index,$no_overlap,$end_read_1,$cigar_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2481 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2482 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2483 ## we first pass the first read which is in - orientation on the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2484 print_individual_C_methylation_states_paired_end_files($meth_call_1,$chrom,$start_read_1,$id_1,'-',$index,0,0,$cigar_1,1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2485
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2486 # we next pass the second read which is in + orientation on the forward strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2487 ### if --no_overlap was specified we also pass the end of read 1. If read 2 starts to overlap with read 1 we will stop extracting methylation calls from read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2488 print_individual_C_methylation_states_paired_end_files($meth_call_2,$chrom,$start_read_2,$id_2,'+',$index,$no_overlap,$end_read_1,$cigar_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2489 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2490
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2491 $methylation_call_strings_processed += 2; # paired-end = 2 methylation call strings
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2492 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2493 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2494 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2495 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2496 die "Single-end or paired-end reads not specified properly\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2497 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2498
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2499 $counting{sequences_count} = $line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2500 $counting{methylation_call_strings} = $methylation_call_strings_processed;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2501
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2502 if ($multicore == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2503 print_splitting_report ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2504 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2505 elsif ($multicore > 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2506 print_splitting_report_multicore($report_filename,$offset,$line_count,$methylation_call_strings_processed);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2507 print_mbias_report_multicore($report_filename,$offset,$line_count,$methylation_call_strings_processed);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2508 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2509
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2510 return ($process_id,\@pids,$report_filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2511
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2512 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2513
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2514
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2515
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2516 sub print_splitting_report{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2517
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2518 ### Calculating methylation percentages if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2519 warn "\nProcessed $counting{sequences_count} lines in total\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2520 warn "Total number of methylation call strings processed: $counting{methylation_call_strings}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2521 if ($report) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2522 print REPORT "\nProcessed $counting{sequences_count} lines in total\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2523 print REPORT "Total number of methylation call strings processed: $counting{methylation_call_strings}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2524 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2525
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2526 my $percent_meCpG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2527 if (($counting{total_meCpG_count}+$counting{total_unmethylated_CpG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2528 $percent_meCpG = sprintf("%.1f",100*$counting{total_meCpG_count}/($counting{total_meCpG_count}+$counting{total_unmethylated_CpG_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2529 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2530
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2531 my $percent_meCHG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2532 if (($counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2533 $percent_meCHG = sprintf("%.1f",100*$counting{total_meCHG_count}/($counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2534 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2535
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2536 my $percent_meCHH;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2537 if (($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2538 $percent_meCHH = sprintf("%.1f",100*$counting{total_meCHH_count}/($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2539 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2540
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2541 my $percent_non_CpG_methylation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2542 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2543 if ( ($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}+$counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2544 $percent_non_CpG_methylation = sprintf("%.1f",100* ( $counting{total_meCHH_count}+$counting{total_meCHG_count} ) / ( $counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}+$counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count} ) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2545 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2546 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2547
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2548 if ($report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2549 ### detailed information about Cs analysed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2550 print REPORT "Final Cytosine Methylation Report\n",'='x33,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2551
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2552 my $total_number_of_C = $counting{total_meCHG_count}+$counting{total_meCHH_count}+$counting{total_meCpG_count}+$counting{total_unmethylated_CHG_count}+$counting{total_unmethylated_CHH_count}+$counting{total_unmethylated_CpG_count};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2553 print REPORT "Total number of C's analysed:\t$total_number_of_C\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2554
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2555 print REPORT "Total methylated C's in CpG context:\t$counting{total_meCpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2556 print REPORT "Total methylated C's in CHG context:\t$counting{total_meCHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2557 print REPORT "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2558
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2559 print REPORT "Total C to T conversions in CpG context:\t$counting{total_unmethylated_CpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2560 print REPORT "Total C to T conversions in CHG context:\t$counting{total_unmethylated_CHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2561 print REPORT "Total C to T conversions in CHH context:\t$counting{total_unmethylated_CHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2562
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2563 ### calculating methylated CpG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2564 if ($percent_meCpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2565 print REPORT "C methylated in CpG context:\t${percent_meCpG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2566 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2567 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2568 print REPORT "Can't determine percentage of methylated Cs in CpG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2569 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2570
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2571 ### 2-Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2572 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2573 if ($percent_non_CpG_methylation){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2574 print REPORT "C methylated in non-CpG context:\t${percent_non_CpG_methylation}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2575 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2576 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2577 print REPORT "Can't determine percentage of methylated Cs in non-CpG context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2578 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2579 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2580
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2581 ### 3 Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2582 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2583 ### calculating methylated CHG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2584 if ($percent_meCHG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2585 print REPORT "C methylated in CHG context:\t${percent_meCHG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2586 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2587 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2588 print REPORT "Can't determine percentage of methylated Cs in CHG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2589 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2590
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2591 ### calculating methylated CHH percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2592 if ($percent_meCHH){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2593 print REPORT "C methylated in CHH context:\t${percent_meCHH}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2594 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2595 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2596 print REPORT "Can't determine percentage of methylated Cs in CHH context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2597 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2598 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2599 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2600
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2601 ### detailed information about Cs analysed for on-screen report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2602 warn "Final Cytosine Methylation Report\n",'='x33,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2603
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2604 my $total_number_of_C = $counting{total_meCHG_count}+$counting{total_meCHH_count}+$counting{total_meCpG_count}+$counting{total_unmethylated_CHG_count}+$counting{total_unmethylated_CHH_count}+$counting{total_unmethylated_CpG_count};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2605 warn "Total number of C's analysed:\t$total_number_of_C\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2606
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2607 warn "Total methylated C's in CpG context:\t$counting{total_meCpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2608 warn "Total methylated C's in CHG context:\t$counting{total_meCHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2609 warn"Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2610
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2611 warn "Total C to T conversions in CpG context:\t$counting{total_unmethylated_CpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2612 warn "Total C to T conversions in CHG context:\t$counting{total_unmethylated_CHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2613 warn"Total C to T conversions in CHH context:\t$counting{total_unmethylated_CHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2614
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2615 ### printing methylated CpG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2616 if ($percent_meCpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2617 warn "C methylated in CpG context:\t${percent_meCpG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2618 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2619 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2620 warn "Can't determine percentage of methylated Cs in CpG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2621 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2622
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2623 ### 2-Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2624 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2625 if ($percent_non_CpG_methylation){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2626 warn "C methylated in non-CpG context:\t${percent_non_CpG_methylation}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2627 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2628 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2629 warn "Can't determine percentage of methylated Cs in non-CpG context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2630 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2631 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2632
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2633 ### 3-Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2634 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2635 ### printing methylated CHG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2636 if ($percent_meCHG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2637 warn "C methylated in CHG context:\t${percent_meCHG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2638 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2639 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2640 warn "Can't determine percentage of methylated Cs in CHG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2641 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2642
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2643 ### printing methylated CHH percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2644 if ($percent_meCHH){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2645 warn "C methylated in CHH context:\t${percent_meCHH}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2646 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2647 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2648 warn "Can't determine percentage of methylated Cs in CHH context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2649 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2650 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2651 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2652
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2653 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2654
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2655 sub print_splitting_report_multicore{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2656
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2657 my ($report_filename,$offset,$line_count,$meth_call_strings) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2658
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2659 # warn "\$report_filename is $report_filename\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2660 my $special_report = $report_filename.".$offset";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2661
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2662 open (SPECIAL_REPORT,'>',$special_report) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2663 # warn "line count\t$line_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2664 # warn "meth call strings\t$meth_call_strings\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2665
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2666 print SPECIAL_REPORT "line count\t$line_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2667 print SPECIAL_REPORT "meth call strings\t$meth_call_strings\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2668
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2669 ### Calculating methylation percentages if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2670 my $percent_meCpG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2671 if (($counting{total_meCpG_count}+$counting{total_unmethylated_CpG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2672 $percent_meCpG = sprintf("%.1f",100*$counting{total_meCpG_count}/($counting{total_meCpG_count}+$counting{total_unmethylated_CpG_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2673 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2674
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2675 my $percent_meCHG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2676 if (($counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2677 $percent_meCHG = sprintf("%.1f",100*$counting{total_meCHG_count}/($counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2678 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2679
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2680 my $percent_meCHH;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2681 if (($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2682 $percent_meCHH = sprintf("%.1f",100*$counting{total_meCHH_count}/($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2683 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2684
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2685 my $percent_non_CpG_methylation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2686 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2687 if ( ($counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}+$counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2688 $percent_non_CpG_methylation = sprintf("%.1f",100* ( $counting{total_meCHH_count}+$counting{total_meCHG_count} ) / ( $counting{total_meCHH_count}+$counting{total_unmethylated_CHH_count}+$counting{total_meCHG_count}+$counting{total_unmethylated_CHG_count} ) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2689 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2690 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2691
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2692 if ($report){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2693
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2694 ### detailed information about Cs analysed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2695 print SPECIAL_REPORT "Final Cytosine Methylation Report\n",'='x33,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2696
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2697 my $total_number_of_C = $counting{total_meCHG_count}+$counting{total_meCHH_count}+$counting{total_meCpG_count}+$counting{total_unmethylated_CHG_count}+$counting{total_unmethylated_CHH_count}+$counting{total_unmethylated_CpG_count};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2698 print SPECIAL_REPORT "Total number of C's analysed:\t$total_number_of_C\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2699
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2700 print SPECIAL_REPORT "Total methylated C's in CpG context:\t$counting{total_meCpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2701 print SPECIAL_REPORT "Total methylated C's in CHG context:\t$counting{total_meCHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2702 print SPECIAL_REPORT "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2703
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2704 print SPECIAL_REPORT "Total C to T conversions in CpG context:\t$counting{total_unmethylated_CpG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2705 print SPECIAL_REPORT "Total C to T conversions in CHG context:\t$counting{total_unmethylated_CHG_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2706 print SPECIAL_REPORT "Total C to T conversions in CHH context:\t$counting{total_unmethylated_CHH_count}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2707
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2708 ### calculating methylated CpG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2709 if ($percent_meCpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2710 print SPECIAL_REPORT "C methylated in CpG context:\t${percent_meCpG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2711 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2712 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2713 print SPECIAL_REPORT "Can't determine percentage of methylated Cs in CpG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2714 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2715
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2716 ### 2-Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2717 if ($merge_non_CpG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2718 if ($percent_non_CpG_methylation){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2719 print SPECIAL_REPORT "C methylated in non-CpG context:\t${percent_non_CpG_methylation}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2720 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2721 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2722 print SPECIAL_REPORT "Can't determine percentage of methylated Cs in non-CpG context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2723 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2724 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2725
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2726 ### 3 Context Output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2727 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2728 ### calculating methylated CHG percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2729 if ($percent_meCHG){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2730 print SPECIAL_REPORT "C methylated in CHG context:\t${percent_meCHG}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2731 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2732 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2733 print SPECIAL_REPORT "Can't determine percentage of methylated Cs in CHG context if value was 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2734 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2735
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2736 ### calculating methylated CHH percentage if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2737 if ($percent_meCHH){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2738 print SPECIAL_REPORT "C methylated in CHH context:\t${percent_meCHH}%\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2739 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2740 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2741 print SPECIAL_REPORT "Can't determine percentage of methylated Cs in CHH context if value was 0\n\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2742 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2743 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2744 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2745 close SPECIAL_REPORT or warn "Failed to close filehandle for individual report $special_report\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2746 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2747
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2748
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2749 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2750
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2751 ### INDIVIDUAL M-BIAS REPORTS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2752
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2753 sub print_mbias_report_multicore{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2754
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2755 my ($report_filename,$offset,$line_count,$meth_call_strings) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2756
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2757 # warn "\$report_filename is $report_filename\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2758 my $special_mbias_report = $report_filename.".${offset}.mbias";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2759
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2760 open (SPECIAL_MBIAS,'>',$special_mbias_report) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2761
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2762 # determining maximum read length
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2763 my $max_length_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2764 my $max_length_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2765
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2766 foreach my $context (keys %mbias_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2767 foreach my $pos (sort {$a<=>$b} keys %{$mbias_1{$context}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2768 $max_length_1 = $pos unless ($max_length_1 >= $pos);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2770 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2771 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2772 foreach my $context (keys %mbias_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2773 foreach my $pos (sort {$a<=>$b} keys %{$mbias_2{$context}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2774 $max_length_2 = $pos unless ($max_length_2 >= $pos);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2775 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2776 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2777 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2778
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2779 if ($single){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2780 # warn "Determining maximum read length for M-Bias plot\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2781 # warn "Maximum read length of Read 1: $max_length_1\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2782 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2783 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2784 # warn "Determining maximum read lengths for M-Bias plots\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2785 # warn "Maximum read length of Read 1: $max_length_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2786 # warn "Maximum read length of Read 2: $max_length_2\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2787 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2788
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2789 foreach my $context (qw(CpG CHG CHH)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2790
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2791 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2792 print SPECIAL_MBIAS "$context context (R1)\n================\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2793 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2794 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2795 print SPECIAL_MBIAS "$context context\n===========\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2796 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2797 print SPECIAL_MBIAS "position\tcount methylated\tcount unmethylated\t% methylation\tcoverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2798
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2799 foreach my $pos (1..$max_length_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2800
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2801 unless (defined $mbias_1{$context}->{$pos}->{meth}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2802 $mbias_1{$context}->{$pos}->{meth} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2803 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2804 unless (defined $mbias_1{$context}->{$pos}->{un}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2805 $mbias_1{$context}->{$pos}->{un} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2806 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2807
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2808 my $percent = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2809 if (($mbias_1{$context}->{$pos}->{meth} + $mbias_1{$context}->{$pos}->{un}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2810 $percent = sprintf("%.2f",$mbias_1{$context}->{$pos}->{meth} * 100/ ( $mbias_1{$context}->{$pos}->{meth} + $mbias_1{$context}->{$pos}->{un}) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2811 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2812 my $coverage = $mbias_1{$context}->{$pos}->{un} + $mbias_1{$context}->{$pos}->{meth};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2813
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2814 print SPECIAL_MBIAS "$pos\t$mbias_1{$context}->{$pos}->{meth}\t$mbias_1{$context}->{$pos}->{un}\t$percent\t$coverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2815 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2816 print SPECIAL_MBIAS "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2817 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2818
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2819 if ($paired){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2820
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2821 foreach my $context (qw(CpG CHG CHH)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2822
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2823 print SPECIAL_MBIAS "$context context (R2)\n================\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2824 print SPECIAL_MBIAS "position\tcount methylated\tcount unmethylated\t% methylation\tcoverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2825
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2826 foreach my $pos (1..$max_length_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2827
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2828 unless (defined $mbias_2{$context}->{$pos}->{meth}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2829 $mbias_2{$context}->{$pos}->{meth} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2830 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2831 unless (defined $mbias_2{$context}->{$pos}->{un}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2832 $mbias_2{$context}->{$pos}->{un} = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2833 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2834
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2835 my $percent = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2836 if (($mbias_2{$context}->{$pos}->{meth} + $mbias_2{$context}->{$pos}->{un}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2837 $percent = sprintf("%.2f",$mbias_2{$context}->{$pos}->{meth} * 100/ ($mbias_2{$context}->{$pos}->{meth} + $mbias_2{$context}->{$pos}->{un}) );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2838 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2839 my $coverage = $mbias_2{$context}->{$pos}->{un} + $mbias_2{$context}->{$pos}->{meth};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2840
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2841 print SPECIAL_MBIAS "$pos\t$mbias_2{$context}->{$pos}->{meth}\t$mbias_2{$context}->{$pos}->{un}\t$percent\t$coverage\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2842 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2843 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2844 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2845
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2846 close SPECIAL_MBIAS or warn "Failed to close filehandle for individual M-bias report $special_mbias_report\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2847 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2848
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2849
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2850 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2851
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2852
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2853 sub print_individual_C_methylation_states_paired_end_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2854
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2855 my ($meth_call,$chrom,$start,$id,$strand,$filehandle_index,$no_overlap,$end_read_1,$cigar,$read_identity) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2856
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2857 unless (defined $meth_call) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2858 return; # skip this read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2859 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2860
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2861 ### we will use the read identity for the M-bias plot to discriminate read 1 and read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2862 die "Read identity was neither 1 nor 2: $read_identity\n\n" unless ($read_identity == 1 or $read_identity == 2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2863
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2864 my @methylation_calls = split(//,$meth_call);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2865
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2866 #################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2867 ### . for bases not involving cytosines ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2868 ### X for methylated C in CHG context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2869 ### x for not methylated C in CHG context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2870 ### H for methylated C in CHH context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2871 ### h for not methylated C in CHH context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2872 ### Z for methylated C in CpG context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2873 ### z for not methylated C in CpG context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2874 ### U for methylated C in Unknown context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2875 ### u for not methylated C in Unknown context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2876 #################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2877
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2878 my $methyl_CHG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2879 my $methyl_CHH_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2880 my $methyl_CpG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2881 my $unmethylated_CHG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2882 my $unmethylated_CHH_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2883 my $unmethylated_CpG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2884
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2885 my $pos_offset = 0; # this is only relevant for SAM reads with insertions or deletions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2886 my $cigar_offset = 0; # again, this is only relevant for SAM reads containing indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2887 my @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2888
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2889 ### Checking whether the CIGAR string is a linear genomic match or whether if requires indel processing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2890 if ($cigar =~ /^\d+M$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2891 # this check speeds up the extraction process by up to 60%!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2892 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2893 else{ # parsing CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2894 my @len;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2895 my @ops;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2896 @len = split (/\D+/,$cigar); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2897 @ops = split (/\d+/,$cigar); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2898 shift @ops; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2899
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2900 die "CIGAR string contained a non-matching number of lengths and operations\n" unless (scalar @len == scalar @ops);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2901
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2902 foreach my $index (0..$#len){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2903 foreach (1..$len[$index]){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2904 # print "$ops[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2905 push @comp_cigar, $ops[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2906 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2907 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2908 # warn "\nDetected CIGAR string: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2909 # warn "Length of methylation call: ",length $meth_call,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2910 # warn "number of operations: ",scalar @ops,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2911 # warn "number of length digits: ",scalar @len,"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2912 # print @comp_cigar,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2913 # print "$meth_call\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2914 # sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2915 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2916
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2917 if ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2918
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2919 ### the CIGAR string needs to be reversed, the methylation call has already been reversed above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2920 if (@comp_cigar){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2921 @comp_cigar = reverse@comp_cigar; # the CIGAR string needs to be reversed for all reads aligning to the reverse strand, too
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2922 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2923 # print "reverse CIGAR string: @comp_cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2924
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2925 ### the start position of paired-end files has already been corrected, see above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2926 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2927
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2928 ### THIS IS AN OPTIONAL 2-CONTEXT (CpG and non-CpG) SECTION IF --merge_non_CpG was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2929
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2930 if ($merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2931 if ($no_overlap) { # this has to be read 2...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2932
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2933 ### single-file CpG and non-CpG context output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2934 if ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2935 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2936 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2937
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2938 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2939 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2940 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2941 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2942 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2943 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2944
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2945 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2946 if ($start+$index+$pos_offset >= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2947 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2948 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2949
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2950 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2951 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2952 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2953 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2954 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2955 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2956 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2957 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2958 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2959 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2960 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2961 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2962 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2963 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2964 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2965 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2966 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2967 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2968 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2969 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2970 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2971 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2972 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2973 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2974 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2975 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2976 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2977 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2978 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2979 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2980 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2981 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2982 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2983 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2984 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2985 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2986 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2987 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2988 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2989 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2990 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2991 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2992 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2993 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2994 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2995 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2996 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2997 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2998 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2999 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3000 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3001 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3002 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3003 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3004 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3005 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3006 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3007 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3008 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3009 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3010 elsif ($methylation_calls[$index] eq '.'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3011 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3012 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3013 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3014 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3015 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3016 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3017 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3018 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3019
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3020 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3021 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3022 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3023 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3024 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3025 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3026
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3027 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3028 if ($start-$index+$pos_offset <= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3029 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3030 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3031
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3032 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3033 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3034 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3035 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3036 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3037 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3038 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3039 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3040 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3041 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3042 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3043 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3044 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3045 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3046 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3047 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3048 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3049 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3050 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3051 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3052 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3053 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3054 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3055 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3056 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3057 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3058 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3059 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3060 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3061 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3062 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3063 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3064 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3065 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3066 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3067 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3068 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3069 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3071 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3072 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3073 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3074 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3075 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3076 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3077 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3078 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3079 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3080 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3081 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3082 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3083 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3084 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3085 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3086 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3087 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3088 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3089 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3090 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3091 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3092 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3093 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3094 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3095 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3096 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3097 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3098 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3099 die "The read orientation was neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3100 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3101 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3102
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3103 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3104 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3105 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3106 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3107
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3108 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3109 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3110 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3111 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3112 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3113 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3114
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3115 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3116 if ($start+$index+$pos_offset >= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3117 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3118 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3119
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3120 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3121 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3122 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3123 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3124 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3125 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3126 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3127 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3128 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3129 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3130 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3131 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3132 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3133 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3134 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3135 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3136 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3137 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3138 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3139 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3140 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3141 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3142 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3143 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3144 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3145 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3146 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3147 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3148 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3149 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3150 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3151 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3152 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3153 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3154 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3155 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3156 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3157 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3158 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3159 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3160 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3161 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3162 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3163 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3164 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3165 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3166 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3167 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3168 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3169 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3170 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3171 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3172 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3173 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3174 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3175 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3176 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3177 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3178 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3179 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3180 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3181 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3182 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3183 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3184 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3185 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3186 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3187 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3188
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3189 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3190 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3191 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3192 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3193 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3194 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3195
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3196 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3197 if ($start-$index+$pos_offset <= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3198 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3199 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3200
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3201 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3202 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3203 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3204 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3205 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3206 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3207 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3208 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3209 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3210 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3211 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3212 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3213 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3214 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3215 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3216 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3217 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3218 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3219 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3220 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3221 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3222 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3223 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3224 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3225 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3226 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3227 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3228 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3230 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3231 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3232 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3233 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3234 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3235 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3236 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3237 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3238 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3239 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3240 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3241 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3242 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3243 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3244 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3245 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3246 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3247 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3248 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3249 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3250 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3251 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3252 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3253 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3254 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3255 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3256 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3257 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3258 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3259 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3260 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3261 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3262 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3263 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3264 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3265 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3266 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3267 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3268 die "The strand orientation was neither + nor -: '$strand'/n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3269 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3270 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3271 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3272
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3273 ### this is the default paired-end procedure allowing overlaps and using every single C position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3274 ### Still within the 2-CONTEXT ONLY optional section
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3275 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3276 ### single-file CpG and non-CpG context output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3277 if ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3278 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3279 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3280
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3281 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3282 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3283 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3284 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3285 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3286 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3287
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3288 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3289 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3290 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3291 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3292 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3293 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3294 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3295 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3296 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3297 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3298 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3299 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3300 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3301 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3302 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3303 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3304 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3305 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3306 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3307 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3308 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3309 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3310 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3311 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3312 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3313 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3314 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3315 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3316 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3317 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3318 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3319 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3320 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3321 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3322 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3323 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3324 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3325 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3326 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3327 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3328 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3329 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3330 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3331 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3332 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3333 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3334 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3335 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3336 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3337 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3338 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3339 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3340 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3341 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3342 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3343 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3344 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3345 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3346 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3347 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3348 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3349 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3350 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3351 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3352 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3353 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3354 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3355 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3356
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3357 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3358 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3359 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3360 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3361 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3362 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3363
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3364 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3365 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3366 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3367 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3368 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3369 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3370 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3371 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3372 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3373 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3374 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3375 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3376 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3377 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3378 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3379 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3380 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3381 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3382 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3383 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3384 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3385 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3386 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3387 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3388 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3389 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3390 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3391 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3392 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3393 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3394 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3395 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3396 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3397 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3398 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3399 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3400 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3401 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3402 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3403 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3404 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3405 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3406 print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3407 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3408 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3409 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3410 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3411 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3412 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3413 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3414 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3415 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3416 print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3417 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3418 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3419 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3420 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3421 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3423 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3424 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3425 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3426 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3427 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3428 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3429 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3430 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3431 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3432 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3433 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3434
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3435 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3436 ### still within the 2-CONTEXT optional section
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3437 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3438 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3439 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3440
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3441 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3442 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3443 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3444 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3445 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3446 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3447
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3448 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3449 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3450 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3451 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3452 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3453 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3454 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3455 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3456 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3457 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3458 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3459 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3460 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3461 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3462 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3463 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3464 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3465 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3466 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3467 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3468 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3469 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3470 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3471 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3472 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3473 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3474 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3475 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3476 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3477 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3478 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3479 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3480 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3481 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3482 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3483 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3484 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3485 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3486 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3487 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3488 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3489 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3490 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3491 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3492 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3493 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3494 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3495 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3496 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3497 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3498 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3499 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3500 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3501 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3502 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3503 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3504 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3505 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3506 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3507 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3508 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3509 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3510 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3511 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3512 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3513 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3514 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3515 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3516
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3517 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3518 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3519 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3520 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3521 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3522 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3523
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3524 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3525 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3526 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3527 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3528 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3529 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3530 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3531 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3532 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3533 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3534 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3535 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3536 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3537 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3538 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3539 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3540 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3541 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3542 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3543 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3544 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3545 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3546 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3547 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3548 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3549 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3550 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3551 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3552 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3553 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3554 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3555 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3556 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3557 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3558 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3559 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3560 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3561 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3562 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3563 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3564 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3565 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3566 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3567 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3568 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3569 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3570 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3571 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3572 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3573 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3574 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3575 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3576 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3577 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3578 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3579 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3580 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3581 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3582 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3583 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3584 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3585 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3586 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3587 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3588 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3589 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3590 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3591 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3592 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3593 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3594 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3595 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3596
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3597 ############################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3598 ### THIS IS THE DEFAULT 3-CONTEXT OUTPUT ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3599 ############################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3600
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3601 elsif ($no_overlap) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3602 ### single-file CpG, CHG and CHH context output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3603 if ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3604 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3605 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3606
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3607 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3608 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3609 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3610 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3611 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3612 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3613
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3614 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3615 if ($start+$index+$pos_offset >= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3616 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3617 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3618
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3619 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3620 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3621 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3622 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3623 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3624 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3625 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3626 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3627 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3628 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3629 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3630 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3631 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3632 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3633 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3634 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3635 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3636 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3637 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3638 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3639 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3640 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3641 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3642 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3643 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3644 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3645 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3646 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3647 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3648 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3649 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3650 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3651 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3652 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3653 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3654 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3655 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3656 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3657 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3658 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3659 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3660 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3661 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3662 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3663 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3664 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3665 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3666 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3667 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3668 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3669 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3670 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3671 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3672 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3673 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3674 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3675 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3676 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3677 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3678 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3679 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3680 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3681 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3682 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3683 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3684 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3685 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3686 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3687
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3688 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3689 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3690 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3691 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3692 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3693 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3694
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3695 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3696 if ($start-$index+$pos_offset <= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3697 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3698 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3699
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3700 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3701 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3702 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3703 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3704 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3705 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3706 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3707 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3708 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3709 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3710 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3711 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3712 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3713 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3714 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3715 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3716 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3717 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3718 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3719 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3720 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3721 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3722 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3723 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3724 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3725 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3726 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3727 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3728 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3729 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3730 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3731 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3732 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3733 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3734 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3735 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3736 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3737 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3738 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3739 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3740 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3741 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3742 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3743 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3744 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3745 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3746 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3747 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3748 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3749 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3750 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3751 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3752 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3753 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3754 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3755 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3756 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3757 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3758 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3759 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3760 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3761 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3762 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3763 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3764 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3765 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3766 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3767 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3768 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3770
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3771 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3772 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3773 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3774 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3775
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3776 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3777 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3778 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3779 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3780 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3781 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3782
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3783 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3784 if ($start+$index+$pos_offset >= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3785 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3786 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3787
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3788 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3789 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3790 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3791 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3792 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3793 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3794 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3795 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3796 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3797 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3798 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3799 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3800 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3801 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3802 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3803 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3804 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3805 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3806 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3807 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3808 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3809 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3810 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3811 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3812 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3813 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3814 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3815 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3816 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3817 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3818 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3819 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3820 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3821 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3822 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3823 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3824 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3825 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3826 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3827 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3828 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3829 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3830 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3831 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3832 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3833 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3834 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3835 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3836 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3837 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3838 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3839 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3840 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3841 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3842 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3843 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3844 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3845 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3846 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3847 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3848 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3849 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3850 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3851 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3852 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3853 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3854 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3855 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3856
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3857 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3858 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3859 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3860 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3861 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3862 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3863
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3864 ### Returning as soon as the methylation calls start overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3865 if ($start-$index+$pos_offset <= $end_read_1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3866 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3867 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3868
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3869 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3870 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3871 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3872 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3873 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3874 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3875 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3876 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3877 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3878 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3879 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3880 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3881 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3882 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3883 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3884 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3885 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3886 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3887 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3888 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3889 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3890 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3891 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3892 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3893 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3894 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3895 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3896 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3897 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3898 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3899 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3900 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3901 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3902 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3903 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3904 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3905 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3906 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3907 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3908 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3909 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3910 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3911 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3912 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3913 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3914 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3915 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3916 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3917 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3918 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3919 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3920 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3921 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3922 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3923 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3924 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3925 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3926 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3927 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3928 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3929 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3930 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3931 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3932 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3933 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3934 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3935 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3936 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3937 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3938 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3939 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3940
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3941 ### this is the paired-end procedure allowing overlaps and using every single C position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3942 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3943 ### single-file CpG, CHG and CHH context output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3944 if ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3945 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3946 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3947
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3948 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3949 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3950 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3951 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3952 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3953 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3954
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3955 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3956 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3957 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3958 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3959 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3960 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3961 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3962 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3963 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3964 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3965 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3966 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3967 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3968 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3969 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3970 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3971 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3972 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3973 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3974 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3975 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3976 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3977 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3978 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3979 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3980 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3981 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3982 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3983 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3984 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3985 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3986 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3987 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3988 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3989 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3990 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3991 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3992 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3993 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3994 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3995 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3996 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3997 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3998 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3999 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4000 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4001 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4002 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4003 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4004 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4005 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4006 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4007 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4008 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4009 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4010 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4011 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4012 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4013 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4014 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4015 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4016 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4017 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4018 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4019 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4020 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4021 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4022 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4023
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4024 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4025 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4026 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4027 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4028 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4029 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4030
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4031 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4032 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4033 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4034 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4035 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4036 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4037 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4038 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4039 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4040 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4041 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4042 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4043 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4044 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4045 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4046 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4047 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4048 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4049 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4050 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4051 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4052 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4053 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4054 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4055 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4056 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4057 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4058 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4059 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4060 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4061 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4062 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4063 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4064 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4065 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4066 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4067 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4068 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4069 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4071 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4072 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4073 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4074 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4075 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4076 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4077 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4078 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4079 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4080 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4081 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4082 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4083 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4084 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4085 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4086 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4087 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4088 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4089 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4090 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4091 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4092 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4093 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4094 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4095 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4096 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4097 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4098 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4100 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4101
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4102 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4103 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4104 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4105 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4106
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4107 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4108 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4109 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4110 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4111 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4112 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4113
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4114 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4115 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4116 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4117 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4118 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4119 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4120 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4121 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4122 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4124 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4125 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4126 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4127 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4128 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4129 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4130 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4131 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4132 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4133 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4134 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4135 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4136 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4137 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4138 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4139 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4140 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4141 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4142 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4143 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4144 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4145 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4146 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4147 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4148 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4149 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4150 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4151 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4152 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4153 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4154 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4155 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4156 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4157 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4158 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4159 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4160 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4161 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4162 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4163 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4164 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4165 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4166 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4167 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4168 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4169 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4170 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4171 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4172 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4173 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4174 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4175 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4176 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4177 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4178 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4179 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4180 } elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4181 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4182
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4183 if ($cigar and @comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4184 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4185 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4186 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4187 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4188 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4189
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4190 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4191 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4192 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4193 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4194 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4195 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4196 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4197 $mbias_2{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4198 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4199 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4200 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4201 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4202 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4203 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4204 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4205 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4206 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4207 $mbias_2{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4208 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4209 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4210 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4211 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4212 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4213 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4214 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4215 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4216 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4217 $mbias_2{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4218 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4219 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4220 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4221 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4222 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4223 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4224 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4225 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4226 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4227 $mbias_2{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4228 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4230 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4231 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4232 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4233 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4234 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4235 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4236 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4237 $mbias_2{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4238 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4239 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4240 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4241 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4242 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4243 if ($read_identity == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4244 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4245 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4246 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4247 $mbias_2{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4248 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4249 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4250 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4251 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4252 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4253 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4254 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4255 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4256 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4257 die "The strand orientation as neither + nor -: '$strand'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4258 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4259 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4260 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4261 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4262
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4263 sub check_cigar_string {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4264 my ($index,$cigar_offset,$pos_offset,$strand,$comp_cigar) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4265 # print "$index\t$cigar_offset\t$pos_offset\t$strand\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4266 my ($new_cigar_offset,$new_pos_offset) = (0,0);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4267
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4268 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4269 # print "### $strand strand @$comp_cigar[$index + $cigar_offset]\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4270
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4271 if (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'M'){ # sequence position matches the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4272 # warn "position needs no adjustment\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4273 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4274
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4275 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'I'){ # insertion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4276 $new_pos_offset -= 1; # we need to subtract the length of inserted bases from the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4277 # warn "adjusted genomic position by -1 bp (insertion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4278 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4280 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'D'){ # deletion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4281 $new_cigar_offset += 1; # the composite cigar string does no longer match the methylation call index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4282 $new_pos_offset += 1; # we need to add the length of deleted bases to get the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4283 # warn "adjusted genomic position by +1 bp (deletion). Now looping through the CIGAR string until we hit another M or I\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4284
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4285 while ( ($index + $cigar_offset + $new_cigar_offset) < (scalar @$comp_cigar) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4286 if (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'M'){ # sequence position matches the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4287 # warn "position needs no adjustment\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4288 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4289 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4290 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'I'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4291 $new_pos_offset -= 1; # we need to subtract the length of inserted bases from the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4292 # warn "adjusted genomic position by another -1 bp (insertion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4293 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4294 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4295 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'D'){ # deletion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4296 $new_cigar_offset += 1; # the composite cigar string does no longer match the methylation call index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4297 $new_pos_offset += 1; # we need to add the length of deleted bases to get the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4298 # warn "adjusted genomic position by another +1 bp (deletion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4299 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4300 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4301 die "The CIGAR string contained undefined operations in addition to 'M', 'I' and 'D': '@$comp_cigar[$index + $cigar_offset + $new_cigar_offset]'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4302 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4303 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4304 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4305 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4306 die "The CIGAR string contained undefined operations in addition to 'M', 'I' and 'D': '@$comp_cigar[$index + $cigar_offset + $new_cigar_offset]'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4307 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4308 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4309
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4310 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4311 # print "### $strand strand @$comp_cigar[$index + $cigar_offset]\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4312
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4313 if (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'M'){ # sequence position matches the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4314 # warn "position needs no adjustment\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4315 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4316
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4317 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'I'){ # insertion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4318 $new_pos_offset += 1; # we need to add the length of inserted bases to the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4319 # warn "adjusted genomic position by +1 bp (insertion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4320 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4321
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4322 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'D'){ # deletion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4323 $new_cigar_offset += 1; # the composite cigar string does no longer match the methylation call index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4324 $new_pos_offset -= 1; # we need to subtract the length of deleted bases to get the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4325 # warn "adjusted genomic position by -1 bp (deletion). Now looping through the CIGAR string until we hit another M or I\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4326
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4327 while ( ($index + $cigar_offset + $new_cigar_offset) < (scalar @$comp_cigar) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4328 if (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'M'){ # sequence position matches the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4329 # warn "Found new 'M' operation; position needs no adjustment\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4330 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4331 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4332 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'I'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4333 $new_pos_offset += 1; # we need to subtract the length of inserted bases from the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4334 # warn "Found new 'I' operation; adjusted genomic position by another +1 bp (insertion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4335 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4336 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4337 elsif (@$comp_cigar[$index + $cigar_offset + $new_cigar_offset] eq 'D'){ # deletion in the read sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4338 $new_cigar_offset += 1; # the composite cigar string does no longer match the methylation call index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4339 $new_pos_offset -= 1; # we need to subtract the length of deleted bases to get the genomic position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4340 # warn "adjusted genomic position by another -1 bp (deletion)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4341 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4342 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4343 die "The CIGAR string contained undefined operations in addition to 'M', 'I' and 'D': '@$comp_cigar[$index + $cigar_offset + $new_cigar_offset]'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4344 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4345 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4346 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4347 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4348 die "The CIGAR string contained undefined operations in addition to 'M', 'I' and 'D': '@$comp_cigar[$index + $cigar_offset + $new_cigar_offset]'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4349 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4350 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4351 # print "new cigar offset: $new_cigar_offset\tnew pos offset: $new_pos_offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4352 return ($new_cigar_offset,$new_pos_offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4353 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4354
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4355 sub print_individual_C_methylation_states_single_end{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4356
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4357 my ($meth_call,$chrom,$start,$id,$strand,$filehandle_index,$cigar) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4358 my @methylation_calls = split(//,$meth_call);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4359
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4360 #################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4361 ### . for bases not involving cytosines ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4362 ### X for methylated C in CHG context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4363 ### x for not methylated C in CHG context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4364 ### H for methylated C in CHH context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4365 ### h for not methylated C in CHH context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4366 ### Z for methylated C in CpG context (was protected) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4367 ### z for not methylated C in CpG context (was converted) ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4368 #################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4369
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4370 my $methyl_CHG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4371 my $methyl_CHH_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4372 my $methyl_CpG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4373 my $unmethylated_CHG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4374 my $unmethylated_CHH_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4375 my $unmethylated_CpG_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4376
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4377 my $pos_offset = 0; # this is only relevant for SAM reads with insertions or deletions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4378 my $cigar_offset = 0; # again, this is only relevant for SAM reads containing indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4379
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4380 my @comp_cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4381
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4382 if ($cigar){ # parsing CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4383
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4384 ### Checking whether the CIGAR string is a linear genomic match or whether it requires indel processing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4385 if ($cigar =~ /^\d+M$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4386 # warn "See!? I told you so! $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4387 # sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4388 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4389 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4390
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4391 my @len;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4392 my @ops;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4393
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4394 @len = split (/\D+/,$cigar); # storing the length per operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4395 @ops = split (/\d+/,$cigar); # storing the operation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4396 shift @ops; # remove the empty first element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4397 # die "CIGAR string contained a non-matching number of lengths and operations: id: $id\nmeth call: $meth_call\nCIGAR: $cigar\n".join(" ",@len)."\n".join(" ",@ops)."\n" unless (scalar @len == scalar @ops);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4398 die "CIGAR string contained a non-matching number of lengths and operations\n" unless (scalar @len == scalar @ops);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4399
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4400 foreach my $index (0..$#len){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4401 foreach (1..$len[$index]){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4402 # print "$ops[$index]";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4403 push @comp_cigar, $ops[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4404 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4405 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4406 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4407 # warn "\nDetected CIGAR string: $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4408 # warn "Length of methylation call: ",length $meth_call,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4409 # warn "number of operations: ",scalar @ops,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4410 # warn "number of length digits: ",scalar @len,"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4411 # print @comp_cigar,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4412 # print "$meth_call\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4413 # sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4414 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4415
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4416 ### adjusting the start position for all reads mapping to the reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4417 if ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4418
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4419 if (@comp_cigar){ # only needed for SAM reads with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4420 @comp_cigar = reverse@comp_cigar; # the CIGAR string needs to be reversed for all reads aligning to the reverse strand, too
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4421 # print @comp_cigar,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4423
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4424 unless ($ignore){ ### if --ignore was specified the start position has already been corrected
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4425
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4426 if ($cigar){ ### SAM format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4427 if ($cigar =~ /^(\d+)M$/){ # linear match
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4428 $start += $1 - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4429 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4430 else{ # InDel read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4431 my $MD_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4432 foreach (@comp_cigar){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4433 ++$MD_count if ($_ eq 'M' or $_ eq 'D'); # Matching bases or deletions affect the genomic position of the 3' ends of reads, insertions don't
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4434 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4435 $start += $MD_count - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4436 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4437 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4438 else{ ### vanilla format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4439 $start += length($meth_call)-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4441 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4442 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4443
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4444 ### THIS IS THE CpG and Non-CpG SECTION (OPTIONAL)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4445
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4446 ### single-file CpG and other-context output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4447 if ($full and $merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4448 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4449 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4450
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4451 if ($cigar and @comp_cigar){ # only needed for SAM alignments with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4452 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4453 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition+index: ",$start+$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4454 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4455 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4456 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4457
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4458 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4459 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4460 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4461 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4462 my $line = join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4463 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4464 # print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4465 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4466 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4467 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4468 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4469 my $line = join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4470 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4471 # print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4472 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4473 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4474 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4475 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4476 my $line = join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4477 print {$fhs{CpG_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4478 # print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4479 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4480 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4481 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4482 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4483 my $line = join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4484 print {$fhs{CpG_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4485 # print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4486 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4487 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4488 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4489 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4490 my $line = join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4491 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4492 # print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4493 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4494 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4495 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4496 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4497 my $line = join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4498 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4499 # print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4500 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4501 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4502 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4503 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4504 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4505 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4506 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4507 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4508 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4509 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4510
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4511 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4512 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4513 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4514
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4515 if ($cigar and @comp_cigar){ # only needed for SAM entries with InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4516 # print "index: $index\tmethylation_call: $methylation_calls[$index]\tposition-index: ",$start-$index,"\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4517 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4518 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4519 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4520 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4521
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4522 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4523 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4524 my $line = join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4525 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4526 #print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4527 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4528 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4529 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4530 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4531 my $line = join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4532 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4533 #print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4534 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4535 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4536 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4537 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4538 my $line = join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4539 print {$fhs{CpG_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4540 #print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4541 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4542 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4543 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4544 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4545 my $line = join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4546 print {$fhs{CpG_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4547 #print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4548 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4549 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4550 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4551 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4552 my $line = join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4553 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4554 #print {$fhs{other_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4555 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4556 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4557 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4558 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4559 my $line = join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4560 print {$fhs{other_context}} $line unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4561 #print {$fhs{other_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4562 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4563 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4564 elsif ($methylation_calls[$index] eq '.'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4565 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4566 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4567 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4568 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4569 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4570 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4571 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4572 die "The strand information was neither + nor -: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4573 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4574 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4575
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4576 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4577 elsif ($merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4578 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4579 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4580 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4581 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4582
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4583 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4584 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4585 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4586 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4587 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4588
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4589 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4590 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4591 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4592 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4593 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4594 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4595 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4596 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4597 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4598 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4599 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4600 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4601 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4602 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4603 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4604 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4605 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4606 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4607 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4608 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4609 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4610 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4611 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4612 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4613 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4614 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4615 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4616 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4617 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4618 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4619 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4620 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4621 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4622 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4623 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4624 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4625 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4626 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4627
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4628 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4629 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4630 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4631
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4632 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4633 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4634 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4635 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4636 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4637
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4638 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4639 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4640 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4641 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4642 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4643 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4644 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4645 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4646 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4647 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4648 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4649 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4650 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4651 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4652 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4653 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4654 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4655 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4656 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4657 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4658 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4659 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4660 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4661 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4662 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4663 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4664 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4665 print {$fhs{$filehandle_index}->{other_c}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4666 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4667 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4668 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4669 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4670 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4671 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4672 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4673 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4674 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4675 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4676 die "The strand information was neither + nor -: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4677 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4678 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4679
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4680 ### THIS IS THE 3-CONTEXT (CpG, CHG and CHH) DEFAULT SECTION
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4681
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4682 elsif ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4683 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4684 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4685 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4686 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4687
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4688 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4689 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4690 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4691 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4692 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4693
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4694 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4695 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4696 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4697 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4698 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4699 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4700 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4701 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4702 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4703 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4704 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4705 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4706 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4707 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4708 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4709 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4710 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4711 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4712 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4713 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4714 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4715 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4716 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4717 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4718 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4719 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4720 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4721 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4722 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4723 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4724 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4725 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4726 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4727 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4728 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4729 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4730 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4731 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4732
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4733 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4734 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4735 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4736
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4737 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4738 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4739 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4740 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4741 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4742
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4743 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4744 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4745 print {$fhs{CHG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4746 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4747 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4748 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4749 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4750 print {$fhs{CHG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4751 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4752 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4753 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4754 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4755 print {$fhs{CpG_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4756 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4757 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4758 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4759 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4760 print {$fhs{CpG_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4761 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4762 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4763 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4764 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4765 print {$fhs{CHH_context}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4766 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4767 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4768 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4769 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4770 print {$fhs{CHH_context}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4771 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4772 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4773 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4774 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4775 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4776 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4777 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4778 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4779 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4780 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4781 die "The read had a strand orientation which was neither + nor -: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4782 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4783 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4784
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4785 ### strand-specific methylation output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4786 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4787 if ($strand eq '+') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4788 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4789 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4790 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4791
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4792 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4793 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4794 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4795 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4796 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4797
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4798 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4799 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4800 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4801 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4802 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4803 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4804 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4805 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4806 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4807 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4808 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4809 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4810 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4811 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4812 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4813 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4814 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4815 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4816 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4817 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4818 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4819 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4820 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4821 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4822 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4823 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4824 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4825 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start+$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4826 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4827 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4828 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4829 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4830 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4831 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4832 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4833 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4834 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4835 elsif ($strand eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4836
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4837 for my $index (0..$#methylation_calls) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4838 ### methylated Cs (any context) will receive a forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4839 ### not methylated Cs (any context) will receive a reverse (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4840
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4841 if ($cigar and @comp_cigar){ # only needed for SAM reads with Indels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4842 my ($cigar_mod,$pos_mod) = check_cigar_string($index,$cigar_offset,$pos_offset,$strand,\@comp_cigar);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4843 $cigar_offset += $cigar_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4844 $pos_offset += $pos_mod;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4845 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4846
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4847 if ($methylation_calls[$index] eq 'X') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4848 $counting{total_meCHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4849 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4850 $mbias_1{CHG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4851 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4852 elsif ($methylation_calls[$index] eq 'x') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4853 $counting{total_unmethylated_CHG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4854 print {$fhs{$filehandle_index}->{CHG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4855 $mbias_1{CHG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4856 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4857 elsif ($methylation_calls[$index] eq 'Z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4858 $counting{total_meCpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4859 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4860 $mbias_1{CpG}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4861 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4862 elsif ($methylation_calls[$index] eq 'z') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4863 $counting{total_unmethylated_CpG_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4864 print {$fhs{$filehandle_index}->{CpG}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4865 $mbias_1{CpG}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4866 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4867 elsif ($methylation_calls[$index] eq 'H') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4868 $counting{total_meCHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4869 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'+',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4870 $mbias_1{CHH}->{$index+1}->{meth}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4871 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4872 elsif ($methylation_calls[$index] eq 'h') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4873 $counting{total_unmethylated_CHH_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4874 print {$fhs{$filehandle_index}->{CHH}} join ("\t",$id,'-',$chrom,$start-$index+$pos_offset,$methylation_calls[$index])."\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4875 $mbias_1{CHH}->{$index+1}->{un}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4876 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4877 elsif ($methylation_calls[$index] eq '.') {}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4878 elsif (lc$methylation_calls[$index] eq 'u'){}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4879 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4880 die "The methylation call string contained the following unrecognised character: $methylation_calls[$index]\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4881 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4882 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4883 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4884 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4885 die "The strand information was neither + nor -: $strand\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4886 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4887 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4888 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4889
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4890 sub open_output_filehandles{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4891
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4892 my $filename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4893
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4894 my $output_filename = (split (/\//,$filename))[-1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4895 my $report_filename = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4896
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4897 ### OPENING OUTPUT-FILEHANDLES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4898 if ($report) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4899 $report_filename =~ s/\.sam$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4900 $report_filename =~ s/\.txt$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4901 $report_filename =~ s/$/_splitting_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4902 $report_filename = $output_dir . $report_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4903 open (REPORT,'>',$report_filename) or die "Failed to write to file $report_filename $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4904 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4905
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4906 if ($report) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4907
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4908 print REPORT "$output_filename\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4909 print REPORT "Parameters used to extract methylation information:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4910 print REPORT "Bismark Extractor Version: $version\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4911
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4912 if ($paired) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4913 if ($vanilla) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4914 print REPORT "Bismark result file: paired-end (vanilla Bismark format)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4915 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4916 print REPORT "Bismark result file: paired-end (SAM format)\n"; # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4917 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4918 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4919
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4920 if ($single) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4921 if ($vanilla) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4922 print REPORT "Bismark result file: single-end (vanilla Bismark format)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4923 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4924 print REPORT "Bismark result file: single-end (SAM format)\n"; # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4925 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4926 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4927 if ($single){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4928 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4929 print REPORT "Ignoring first $ignore bp\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4930 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4931 if ($ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4932 print REPORT "Ignoring last $ignore_3prime bp\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4933 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4934 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4935 else{ # paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4936 if ($ignore) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4937 print REPORT "Ignoring first $ignore bp of Read 1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4938 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4939 if ($ignore_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4940 print REPORT "Ignoring first $ignore_r2 bp of Read 2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4941 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4942
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4943 if ($ignore_3prime) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4944 print REPORT "Ignoring last $ignore_3prime bp of Read 1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4945 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4946 if ($ignore_3prime_r2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4947 print REPORT "Ignoring last $ignore_3prime_r2 bp of Read 2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4948 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4949
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4950 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4951
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4952 if ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4953 print REPORT "Output specified: comprehensive\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4954 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4955 print REPORT "Output specified: strand-specific (default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4956 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4957
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4958 if ($no_overlap) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4959 print REPORT "No overlapping methylation calls specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4960 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4961 if ($genomic_fasta) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4962 print REPORT "Genomic equivalent sequences will be printed out in FastA format\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4963 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4964 if ($merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4965 print REPORT "Methylation in CHG and CHH context will be merged into \"non-CpG context\" output\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4966 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4967
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4968 print REPORT "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4969 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4970
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4971 ##### open (OUT,"| gzip -c - > $output_dir$outfile") or die "Failed to write to $outfile: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4972
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4973 ### CpG-context and non-CpG context. THIS SECTION IS OPTIONAL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4974 ### if --comprehensive AND --merge_non_CpG was specified we are only writing out one CpG-context and one Any-Other-context result file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4975 if ($full and $merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4976 my $cpg_output = my $other_c_output = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4977 ### C in CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4978 $cpg_output =~ s/^/CpG_context_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4979 $cpg_output =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4980 $cpg_output =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4981 $cpg_output =~ s/$/.txt/ unless ($cpg_output =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4982 $cpg_output = $output_dir . $cpg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4983
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4984 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4985 $cpg_output .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4986 open ($fhs{CpG_context},"| gzip -c - > $cpg_output") or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4987 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4988 else{ ### disclaimer: I am aware of "The Useless Use of Cat Awards", but I saw no other option...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4989 open ($fhs{CpG_context},"| cat > $cpg_output") or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4990 # open ($fhs{CpG_context},'>',$cpg_output) or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4991 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4992
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4993 warn "Writing result file containing methylation information for C in CpG context to $cpg_output\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4994 push @sorting_files,$cpg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4995
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4996 unless ($no_header) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4997 print {$fhs{CpG_context}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4998 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4999
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5000 ### C in any other context than CpG
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5001 $other_c_output =~ s/^/Non_CpG_context_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5002 $other_c_output =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5003 $other_c_output =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5004 $other_c_output =~ s/$/.txt/ unless ($other_c_output =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5005 $other_c_output = $output_dir . $other_c_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5007 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5008 $other_c_output .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5009 open ($fhs{other_context},"| gzip -c - > $other_c_output") or die "Failed to write to $other_c_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5010 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5011 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5012 open ($fhs{other_context},"| cat > $other_c_output") or die "Failed to write to $other_c_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5013 # open ($fhs{other_context},'>',$other_c_output) or die "Failed to write to $other_c_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5014 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5015
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5016 warn "Writing result file containing methylation information for C in any other context to $other_c_output\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5017 push @sorting_files,$other_c_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5018
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5019
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5020 unless ($no_header) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5021 print {$fhs{other_context}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5022 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5023 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5024
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5025 ### if only --merge_non_CpG was specified we will write out 8 different output files, depending on where the (first) unique best alignment has been found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5026 elsif ($merge_non_CpG) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5027
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5028 my $cpg_ot = my $cpg_ctot = my $cpg_ctob = my $cpg_ob = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5029
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5030 ### For cytosines in CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5031 $cpg_ot =~ s/^/CpG_OT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5032 $cpg_ot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5033 $cpg_ot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5034 $cpg_ot =~ s/$/.txt/ unless ($cpg_ot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5035 $cpg_ot = $output_dir . $cpg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5036
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5037 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5038 $cpg_ot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5039 open ($fhs{0}->{CpG},"| gzip -c - > $cpg_ot") or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5040 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5041 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5042 open ($fhs{0}->{CpG},"| cat > $cpg_ot") or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5043 # open ($fhs{0}->{CpG},'>',$cpg_ot) or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5044 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5045
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5046 warn "Writing result file containing methylation information for C in CpG context from the original top strand to $cpg_ot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5047 push @sorting_files,$cpg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5048
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5049 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5050 print {$fhs{0}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5051 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5052
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5053 $cpg_ctot =~ s/^/CpG_CTOT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5054 $cpg_ctot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5055 $cpg_ctot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5056 $cpg_ctot =~ s/$/.txt/ unless ($cpg_ctot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5057 $cpg_ctot = $output_dir . $cpg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5058
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5059 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5060 $cpg_ctot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5061 open ($fhs{1}->{CpG},"| gzip -c - > $cpg_ctot") or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5062 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5063 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5064 open ($fhs{1}->{CpG},"| cat > $cpg_ctot") or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5065 # open ($fhs{1}->{CpG},'>',$cpg_ctot) or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5066 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5067
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5068 warn "Writing result file containing methylation information for C in CpG context from the complementary to original top strand to $cpg_ctot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5069 push @sorting_files,$cpg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5070
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5071 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5072 print {$fhs{1}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5073 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5074
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5075 $cpg_ctob =~ s/^/CpG_CTOB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5076 $cpg_ctob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5077 $cpg_ctob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5078 $cpg_ctob =~ s/$/.txt/ unless ($cpg_ctob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5079 $cpg_ctob = $output_dir . $cpg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5080
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5081 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5082 $cpg_ctob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5083 open ($fhs{2}->{CpG},"| gzip -c - > $cpg_ctob") or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5084 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5085 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5086 open ($fhs{2}->{CpG},"| cat > $cpg_ctob") or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5087 # open ($fhs{2}->{CpG},'>',$cpg_ctob) or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5088 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5089
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5090 warn "Writing result file containing methylation information for C in CpG context from the complementary to original bottom strand to $cpg_ctob\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5091 push @sorting_files,$cpg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5092
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5093 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5094 print {$fhs{2}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5095 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5096
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5097 $cpg_ob =~ s/^/CpG_OB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5098 $cpg_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5099 $cpg_ob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5100 $cpg_ob =~ s/$/.txt/ unless ($cpg_ob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5101 $cpg_ob = $output_dir . $cpg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5102
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5103 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5104 $cpg_ob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5105 open ($fhs{3}->{CpG},"| gzip -c - > $cpg_ob") or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5106 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5107 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5108 open ($fhs{3}->{CpG},"| cat > $cpg_ob") or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5109 # open ($fhs{3}->{CpG},'>',$cpg_ob) or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5110 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5111
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5112 warn "Writing result file containing methylation information for C in CpG context from the original bottom strand to $cpg_ob\n\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5113 push @sorting_files,$cpg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5114
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5115 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5116 print {$fhs{3}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5117 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5118
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5119 ### For cytosines in Non-CpG (CC, CT or CA) context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5120 my $other_c_ot = my $other_c_ctot = my $other_c_ctob = my $other_c_ob = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5121
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5122 $other_c_ot =~ s/^/Non_CpG_OT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5123 $other_c_ot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5124 $other_c_ot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5125 $other_c_ot =~ s/$/.txt/ unless ($other_c_ot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5126 $other_c_ot = $output_dir . $other_c_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5127
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5128 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5129 $other_c_ot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5130 open ($fhs{0}->{other_c},"| gzip -c - > $other_c_ot") or die "Failed to write to $other_c_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5131 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5132 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5133 open ($fhs{0}->{other_c},"| cat > $other_c_ot") or die "Failed to write to $other_c_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5134 # open ($fhs{0}->{other_c},'>',$other_c_ot) or die "Failed to write to $other_c_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5135 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5136
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5137 warn "Writing result file containing methylation information for C in any other context from the original top strand to $other_c_ot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5138 push @sorting_files,$other_c_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5139
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5140 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5141 print {$fhs{0}->{other_c}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5142 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5143
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5144 $other_c_ctot =~ s/^/Non_CpG_CTOT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5145 $other_c_ctot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5146 $other_c_ctot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5147 $other_c_ctot =~ s/$/.txt/ unless ($other_c_ctot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5148 $other_c_ctot = $output_dir . $other_c_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5149
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5150 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5151 $other_c_ctot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5152 open ($fhs{1}->{other_c},"| gzip -c - > $other_c_ctot") or die "Failed to write to $other_c_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5153 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5154 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5155 open ($fhs{1}->{other_c},"| cat > $other_c_ctot") or die "Failed to write to $other_c_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5156 # open ($fhs{1}->{other_c},'>',$other_c_ctot) or die "Failed to write to $other_c_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5157 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5158
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5159 warn "Writing result file containing methylation information for C in any other context from the complementary to original top strand to $other_c_ctot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5160 push @sorting_files,$other_c_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5161
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5162 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5163 print {$fhs{1}->{other_c}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5164 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5165
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5166 $other_c_ctob =~ s/^/Non_CpG_CTOB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5167 $other_c_ctob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5168 $other_c_ctob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5169 $other_c_ctob =~ s/$/.txt/ unless ($other_c_ctob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5170 $other_c_ctob = $output_dir . $other_c_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5171
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5172 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5173 $other_c_ctob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5174 open ($fhs{2}->{other_c},"| gzip -c - > $other_c_ctob") or die "Failed to write to $other_c_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5175 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5176 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5177 open ($fhs{2}->{other_c},"| cat > $other_c_ctob") or die "Failed to write to $other_c_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5178 # open ($fhs{2}->{other_c},'>',$other_c_ctob) or die "Failed to write to $other_c_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5179 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5180
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5181 warn "Writing result file containing methylation information for C in any other context from the complementary to original bottom strand to $other_c_ctob\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5182 push @sorting_files,$other_c_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5183
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5184 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5185 print {$fhs{2}->{other_c}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5186 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5187
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5188 $other_c_ob =~ s/^/Non_CpG_OB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5189 $other_c_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5190 $other_c_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5191 $other_c_ob =~ s/$/.txt/ unless ($other_c_ob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5192 $other_c_ob = $output_dir . $other_c_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5193
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5194 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5195 $other_c_ob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5196 open ($fhs{3}->{other_c},"| gzip -c - > $other_c_ob") or die "Failed to write to $other_c_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5197 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5198 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5199 open ($fhs{3}->{other_c},"| cat > $other_c_ob") or die "Failed to write to $other_c_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5200 # open ($fhs{3}->{other_c},'>',$other_c_ob) or die "Failed to write to $other_c_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5201 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5202
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5203 warn "Writing result file containing methylation information for C in any other context from the original bottom strand to $other_c_ob\n\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5204 push @sorting_files,$other_c_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5205
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5206 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5207 print {$fhs{3}->{other_c}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5208 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5209 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5210 ### THIS SECTION IS THE DEFAULT (CpG, CHG and CHH context)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5211
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5212 ### if --comprehensive was specified we are only writing one file per context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5213 elsif ($full) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5214 my $cpg_output = my $chg_output = my $chh_output = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5215 ### C in CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5216 $cpg_output =~ s/^/CpG_context_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5217 $cpg_output =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5218 $cpg_output =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5219 $cpg_output =~ s/$/.txt/ unless ($cpg_output =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5220 $cpg_output = $output_dir . $cpg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5221
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5222 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5223 $cpg_output .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5224 open ($fhs{CpG_context},"| gzip -c - > $cpg_output") or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5225 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5226 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5227 open ($fhs{CpG_context},"| cat > $cpg_output") or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5228 # open ($fhs{CpG_context},'>',$cpg_output) or die "Failed to write to $cpg_output $! \n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5230
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5231 warn "Writing result file containing methylation information for C in CpG context to $cpg_output\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5232 push @sorting_files,$cpg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5233
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5234 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5235 print {$fhs{CpG_context}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5236 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5237
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5238 ### C in CHG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5239 $chg_output =~ s/^/CHG_context_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5240 $chg_output =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5241 $chg_output =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5242 $chg_output =~ s/$/.txt/ unless ($chg_output =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5243 $chg_output = $output_dir . $chg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5244
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5245 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5246 $chg_output .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5247 open ($fhs{CHG_context},"| gzip -c - > $chg_output") or die "Failed to write to $chg_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5248 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5249 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5250 open ($fhs{CHG_context},"| cat > $chg_output") or die "Failed to write to $chg_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5251 # open ($fhs{CHG_context},'>',$chg_output) or die "Failed to write to $chg_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5252 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5253
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5254 warn "Writing result file containing methylation information for C in CHG context to $chg_output\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5255 push @sorting_files,$chg_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5256
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5257 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5258 print {$fhs{CHG_context}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5259 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5260
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5261 ### C in CHH context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5262 $chh_output =~ s/^/CHH_context_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5263 $chh_output =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5264 $chh_output =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5265 $chh_output =~ s/$/.txt/ unless ($chh_output =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5266 $chh_output = $output_dir . $chh_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5267
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5268 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5269 $chh_output .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5270 open ($fhs{CHH_context},"| gzip -c - > $chh_output") or die "Failed to write to $chh_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5271 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5272 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5273 open ($fhs{CHH_context},"| cat > $chh_output") or die "Failed to write to $chh_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5274 # open ($fhs{CHH_context},'>',$chh_output) or die "Failed to write to $chh_output $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5275 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5276
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5277 warn "Writing result file containing methylation information for C in CHH context to $chh_output\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5278 push @sorting_files, $chh_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5280 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5281 print {$fhs{CHH_context}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5282 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5283 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5284 ### else we will write out 12 different output files, depending on where the (first) unique best alignment was found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5285 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5286 my $cpg_ot = my $cpg_ctot = my $cpg_ctob = my $cpg_ob = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5287
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5288 ### For cytosines in CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5289 $cpg_ot =~ s/^/CpG_OT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5290 $cpg_ot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5291 $cpg_ot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5292 $cpg_ot =~ s/$/.txt/ unless ($cpg_ot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5293 $cpg_ot = $output_dir . $cpg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5294
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5295 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5296 $cpg_ot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5297 open ($fhs{0}->{CpG},"| gzip -c - > $cpg_ot") or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5298 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5299 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5300 open ($fhs{0}->{CpG},"| cat > $cpg_ot") or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5301 # open ($fhs{0}->{CpG},'>',$cpg_ot) or die "Failed to write to $cpg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5302 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5303
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5304 warn "Writing result file containing methylation information for C in CpG context from the original top strand to $cpg_ot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5305 push @sorting_files,$cpg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5306
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5307 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5308 print {$fhs{0}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5309 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5310
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5311 $cpg_ctot =~ s/^/CpG_CTOT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5312 $cpg_ctot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5313 $cpg_ctot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5314 $cpg_ctot =~ s/$/.txt/ unless ($cpg_ctot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5315 $cpg_ctot = $output_dir . $cpg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5316
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5317 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5318 $cpg_ctot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5319 open ($fhs{1}->{CpG},"| gzip -c - > $cpg_ctot") or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5320 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5321 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5322 open ($fhs{1}->{CpG},"| cat > $cpg_ctot") or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5323 # open ($fhs{1}->{CpG},'>',$cpg_ctot) or die "Failed to write to $cpg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5324 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5325
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5326 warn "Writing result file containing methylation information for C in CpG context from the complementary to original top strand to $cpg_ctot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5327 push @sorting_files,$cpg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5328
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5329 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5330 print {$fhs{1}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5331 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5332
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5333 $cpg_ctob =~ s/^/CpG_CTOB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5334 $cpg_ctob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5335 $cpg_ctob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5336 $cpg_ctob =~ s/$/.txt/ unless ($cpg_ctob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5337 $cpg_ctob = $output_dir . $cpg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5338
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5339 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5340 $cpg_ctob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5341 open ($fhs{2}->{CpG},"| gzip -c - > $cpg_ctob") or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5342 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5343 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5344 open ($fhs{2}->{CpG},"| cat > $cpg_ctob") or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5345 # open ($fhs{2}->{CpG},'>',$cpg_ctob) or die "Failed to write to $cpg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5346 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5347
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5348 warn "Writing result file containing methylation information for C in CpG context from the complementary to original bottom strand to $cpg_ctob\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5349 push @sorting_files,$cpg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5350
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5351 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5352 print {$fhs{2}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5353 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5354
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5355 $cpg_ob =~ s/^/CpG_OB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5356 $cpg_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5357 $cpg_ob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5358 $cpg_ob =~ s/$/.txt/ unless ($cpg_ob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5359 $cpg_ob = $output_dir . $cpg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5360
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5361 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5362 $cpg_ob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5363 open ($fhs{3}->{CpG},"| gzip -c - > $cpg_ob") or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5364 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5365 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5366 open ($fhs{3}->{CpG},"| cat > $cpg_ob") or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5367 # open ($fhs{3}->{CpG},'>',$cpg_ob) or die "Failed to write to $cpg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5368 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5369
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5370 warn "Writing result file containing methylation information for C in CpG context from the original bottom strand to $cpg_ob\n\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5371 push @sorting_files,$cpg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5372
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5373 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5374 print {$fhs{3}->{CpG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5375 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5376
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5377 ### For cytosines in CHG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5378 my $chg_ot = my $chg_ctot = my $chg_ctob = my $chg_ob = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5379
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5380 $chg_ot =~ s/^/CHG_OT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5381 $chg_ot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5382 $chg_ot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5383 $chg_ot =~ s/$/.txt/ unless ($chg_ot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5384 $chg_ot = $output_dir . $chg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5385
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5386 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5387 $chg_ot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5388 open ($fhs{0}->{CHG},"| gzip -c - > $chg_ot") or die "Failed to write to $chg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5389 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5390 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5391 open ($fhs{0}->{CHG},"| cat > $chg_ot") or die "Failed to write to $chg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5392 # open ($fhs{0}->{CHG},'>',$chg_ot) or die "Failed to write to $chg_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5393 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5394
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5395 warn "Writing result file containing methylation information for C in CHG context from the original top strand to $chg_ot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5396 push @sorting_files,$chg_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5397
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5398 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5399 print {$fhs{0}->{CHG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5400 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5401
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5402 $chg_ctot =~ s/^/CHG_CTOT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5403 $chg_ctot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5404 $chg_ctot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5405 $chg_ctot =~ s/$/.txt/ unless ($chg_ctot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5406 $chg_ctot = $output_dir . $chg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5407
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5408 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5409 $chg_ctot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5410 open ($fhs{1}->{CHG},"| gzip -c - > $chg_ctot") or die "Failed to write to $chg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5411 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5412 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5413 open ($fhs{1}->{CHG},"| cat > $chg_ctot") or die "Failed to write to $chg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5414 # open ($fhs{1}->{CHG},'>',$chg_ctot) or die "Failed to write to $chg_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5415 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5416
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5417 warn "Writing result file containing methylation information for C in CHG context from the complementary to original top strand to $chg_ctot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5418 push @sorting_files,$chg_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5419
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5420 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5421 print {$fhs{1}->{CHG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5423
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5424 $chg_ctob =~ s/^/CHG_CTOB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5425 $chg_ctob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5426 $chg_ctob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5427 $chg_ctob =~ s/$/.txt/ unless ($chg_ctob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5428 $chg_ctob = $output_dir . $chg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5429
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5430 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5431 $chg_ctob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5432 open ($fhs{2}->{CHG},"| gzip -c - > $chg_ctob") or die "Failed to write to $chg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5433 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5434 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5435 open ($fhs{2}->{CHG},"| cat > $chg_ctob") or die "Failed to write to $chg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5436 # open ($fhs{2}->{CHG},'>',$chg_ctob) or die "Failed to write to $chg_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5437 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5438
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5439 warn "Writing result file containing methylation information for C in CHG context from the complementary to original bottom strand to $chg_ctob\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5440 push @sorting_files,$chg_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5441
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5442 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5443 print {$fhs{2}->{CHG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5444 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5445
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5446 $chg_ob =~ s/^/CHG_OB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5447 $chg_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5448 $chg_ob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5449 $chg_ob =~ s/$/.txt/ unless ($chg_ob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5450 $chg_ob = $output_dir . $chg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5451
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5452 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5453 $chg_ob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5454 open ($fhs{3}->{CHG},"| gzip -c - > $chg_ob") or die "Failed to write to $chg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5455 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5456 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5457 open ($fhs{3}->{CHG},"| cat > $chg_ob") or die "Failed to write to $chg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5458 # open ($fhs{3}->{CHG},'>',$chg_ob) or die "Failed to write to $chg_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5459 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5460
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5461 warn "Writing result file containing methylation information for C in CHG context from the original bottom strand to $chg_ob\n\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5462 push @sorting_files,$chg_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5463
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5464 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5465 print {$fhs{3}->{CHG}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5466 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5467
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5468 ### For cytosines in CHH context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5469 my $chh_ot = my $chh_ctot = my $chh_ctob = my $chh_ob = $output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5470
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5471 $chh_ot =~ s/^/CHH_OT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5472 $chh_ot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5473 $chh_ot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5474 $chh_ot =~ s/$/.txt/ unless ($chh_ot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5475 $chh_ot = $output_dir . $chh_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5476
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5477 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5478 $chh_ot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5479 open ($fhs{0}->{CHH},"| gzip -c - > $chh_ot") or die "Failed to write to $chh_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5480 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5481 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5482 open ($fhs{0}->{CHH},"| cat > $chh_ot") or die "Failed to write to $chh_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5483 # open ($fhs{0}->{CHH},'>',$chh_ot) or die "Failed to write to $chh_ot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5484 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5485
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5486 warn "Writing result file containing methylation information for C in CHH context from the original top strand to $chh_ot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5487 push @sorting_files,$chh_ot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5488
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5489 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5490 print {$fhs{0}->{CHH}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5491 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5492
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5493 $chh_ctot =~ s/^/CHH_CTOT_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5494 $chh_ctot =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5495 $chh_ctot =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5496 $chh_ctot =~ s/$/.txt/ unless ($chh_ctot =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5497 $chh_ctot = $output_dir . $chh_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5498
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5499 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5500 $chh_ctot .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5501 open ($fhs{1}->{CHH},"| gzip -c - > $chh_ctot") or die "Failed to write to $chh_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5502 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5503 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5504 open ($fhs{1}->{CHH},"| cat > $chh_ctot") or die "Failed to write to $chh_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5505 # open ($fhs{1}->{CHH},'>',$chh_ctot) or die "Failed to write to $chh_ctot $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5506 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5507
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5508 warn "Writing result file containing methylation information for C in CHH context from the complementary to original top strand to $chh_ctot\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5509 push @sorting_files,$chh_ctot;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5510
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5511 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5512 print {$fhs{1}->{CHH}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5513 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5514
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5515 $chh_ctob =~ s/^/CHH_CTOB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5516 $chh_ctob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5517 $chh_ctob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5518 $chh_ctob =~ s/$/.txt/ unless ($chh_ctob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5519 $chh_ctob = $output_dir . $chh_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5520
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5521 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5522 $chh_ctob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5523 open ($fhs{2}->{CHH},"| gzip -c - > $chh_ctob") or die "Failed to write to $chh_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5524 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5525 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5526 open ($fhs{2}->{CHH},"| cat > $chh_ctob") or die "Failed to write to $chh_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5527 # open ($fhs{2}->{CHH},'>',$chh_ctob) or die "Failed to write to $chh_ctob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5528 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5529
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5530 warn "Writing result file containing methylation information for C in CHH context from the complementary to original bottom strand to $chh_ctob\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5531 push @sorting_files,$chh_ctob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5532
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5533 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5534 print {$fhs{2}->{CHH}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5535 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5536
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5537 $chh_ob =~ s/^/CHH_OB_/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5538 $chh_ob =~ s/sam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5539 $chh_ob =~ s/bam$/txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5540 $chh_ob =~ s/$/.txt/ unless ($chh_ob =~ /\.txt$/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5541 $chh_ob = $output_dir . $chh_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5542
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5543 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5544 $chh_ob .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5545 open ($fhs{3}->{CHH},"| gzip -c - > $chh_ob") or die "Failed to write to $chh_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5546 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5547 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5548 open ($fhs{3}->{CHH},"| cat > $chh_ob") or die "Failed to write to $chh_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5549 # open ($fhs{3}->{CHH},'>',$chh_ob) or die "Failed to write to $chh_ob $!\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5550 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5551
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5552 warn "Writing result file containing methylation information for C in CHH context from the original bottom strand to $chh_ob\n\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5553 push @sorting_files,$chh_ob;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5554
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5555 unless($no_header){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5556 print {$fhs{3}->{CHH}} "Bismark methylation extractor version $version\n" unless($mbias_only);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5557 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5558 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5559 return $report_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5560 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5561
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5562 sub isBam{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5563
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5564 my $filename = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5565
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5566 # reading the first line of the input file to see if it is a BAM file in disguise (i.e. a BAM file that does not end in *.bam which may be produced by Galaxy)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5567 open (DISGUISE,"zcat $filename |") or die "Failed to open filehandle DISGUISE for $filename\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5568
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5569 ### when BAM files read through a zcat stream they start with BAM...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5570 my $bam_in_disguise = <DISGUISE>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5571 # warn "BAM in disguise: $bam_in_disguise\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5572
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5573 if ($bam_in_disguise){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5574 if ($bam_in_disguise =~ /^BAM/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5575 close (DISGUISE) or warn "Had trouble closing filehandle BAM in disguise: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5576 return 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5577 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5578 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5579 close (DISGUISE) or warn "Had trouble closing filehandle BAM in disguise: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5580 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5581 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5582 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5583 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5584 close (DISGUISE) or warn "Had trouble closing filehandle BAM in disguise: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5585 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5586 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5587 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5588
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5589
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5590 sub print_helpfile{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5591
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5592 print << 'HOW_TO';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5593
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5594
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5595 DESCRIPTION
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5596
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5597 The following is a brief description of all options to control the Bismark
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5598 methylation extractor. The script reads in a bisulfite read alignment results file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5599 produced by the Bismark bisulfite mapper and extracts the methylation information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5600 for individual cytosines. This information is found in the methylation call field
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5601 which can contain the following characters:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5602
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5603 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5604 ~~~ X for methylated C in CHG context ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5605 ~~~ x for not methylated C CHG ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5606 ~~~ H for methylated C in CHH context ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5607 ~~~ h for not methylated C in CHH context ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5608 ~~~ Z for methylated C in CpG context ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5609 ~~~ z for not methylated C in CpG context ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5610 ~~~ U for methylated C in Unknown context (CN or CHN ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5611 ~~~ u for not methylated C in Unknown context (CN or CHN) ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5612 ~~~ . for any bases not involving cytosines ~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5613 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5614
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5615 The methylation extractor outputs result files for cytosines in CpG, CHG and CHH
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5616 context (this distinction is actually already made in Bismark itself). As the methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5617 information for every C analysed can produce files which easily have tens or even hundreds of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5618 millions of lines, file sizes can become very large and more difficult to handle. The C
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5619 methylation info additionally splits cytosine methylation calls up into one of the four possible
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5620 strands a given bisulfite read aligned against:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5621
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5622 OT original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5623 CTOT complementary to original top strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5624
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5625 OB original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5626 CTOB complementary to original bottom strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5627
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5628 Thus, by default twelve individual output files are being generated per input file (unless
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5629 --comprehensive is specified, see below). The output files can be imported into a genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5630 viewer, such as SeqMonk, and re-combined into a single data group if desired (in fact
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5631 unless the bisulfite reads were generated preserving directionality it doesn't make any
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5632 sense to look at the data in a strand-specific manner). Strand-specific output files can
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5633 optionally be skipped, in which case only three output files for CpG, CHG or CHH context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5634 will be generated. For both the strand-specific and comprehensive outputs there is also
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5635 the option to merge both non-CpG contexts (CHG and CHH) into one single non-CpG context.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5636
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5637
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5638 The output files are in the following format (tab delimited):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5639
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5640 <sequence_id> <strand> <chromosome> <position> <methylation call>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5641
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5642
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5643 USAGE: methylation_extractor [options] <filenames>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5644
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5645
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5646 ARGUMENTS:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5647 ==========
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5648
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5649 <filenames> A space-separated list of Bismark result files in SAM format from
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5650 which methylation information is extracted for every cytosine in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5651 the reads. For alignment files in the older custom Bismark output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5652 see option '--vanilla'.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5653
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5654 OPTIONS:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5655
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5656 -s/--single-end Input file(s) are Bismark result file(s) generated from single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5657 read data. Specifying either --single-end or --paired-end is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5658 mandatory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5659
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5660 -p/--paired-end Input file(s) are Bismark result file(s) generated from paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5661 read data. Specifying either --paired-end or --single-end is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5662 mandatory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5663
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5664 --vanilla The Bismark result input file(s) are in the old custom Bismark format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5665 (up to version 0.5.x) and not in SAM format which is the default as
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5666 of Bismark version 0.6.x or higher. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5667
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5668 --no_overlap For paired-end reads it is theoretically possible that read_1 and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5669 read_2 overlap. This option avoids scoring overlapping methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5670 calls twice (only methylation calls of read 1 are used for in the process
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5671 since read 1 has historically higher quality basecalls than read 2).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5672 Whilst this option removes a bias towards more methylation calls
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5673 in the center of sequenced fragments it may de facto remove a sizable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5674 proportion of the data. This option is on by default for paired-end data
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5675 but can be disabled using --include_overlap. Default: ON.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5676
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5677 --include_overlap For paired-end data all methylation calls will be extracted irrespective of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5678 of whether they overlap or not. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5679
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5680 --ignore <int> Ignore the first <int> bp from the 5' end of Read 1 (or single-end alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5681 files) when processing the methylation call string. This can remove e.g. a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5682 restriction enzyme site at the start of each read or any other source of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5683 bias (such as PBAT-Seq data).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5684
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5685 --ignore_r2 <int> Ignore the first <int> bp from the 5' end of Read 2 of paired-end sequencing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5686 results only. Since the first couple of bases in Read 2 of BS-Seq experiments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5687 show a severe bias towards non-methylation as a result of end-repairing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5688 sonicated fragments with unmethylated cytosines (see M-bias plot), it is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5689 recommended that the first couple of bp of Read 2 are removed before
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5690 starting downstream analysis. Please see the section on M-bias plots in the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5691 Bismark User Guide for more details.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5692
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5693 --ignore_3prime <int> Ignore the last <int> bp from the 3' end of Read 1 (or single-end alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5694 files) when processing the methylation call string. This can remove unwanted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5695 biases from the end of reads.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5696
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5697 --ignore_3prime_r2 <int> Ignore the last <int> bp from the 3' end of Read 2 of paired-end sequencing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5698 results only. This can remove unwanted biases from the end of reads.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5699
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5700 --comprehensive Specifying this option will merge all four possible strand-specific
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5701 methylation info into context-dependent output files. The default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5702
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5703 contexts are:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5704 - CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5705 - CHG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5706 - CHH context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5707
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5708 --merge_non_CpG This will produce two output files (in --comprehensive mode) or eight
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5709 strand-specific output files (default) for Cs in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5710 - CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5711 - non-CpG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5712
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5713 --report Prints out a short methylation summary as well as the paramaters used to run
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5714 this script. Default: ON.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5715
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5716 --no_header Suppresses the Bismark version header line in all output files for more convenient
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5717 batch processing.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5718
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5719 -o/--output DIR Allows specification of a different output directory (absolute or relative
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5720 path). If not specified explicitely, the output will be written to the current directory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5721
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5722 --samtools_path The path to your Samtools installation, e.g. /home/user/samtools/. Does not need to be specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5723 explicitly if Samtools is in the PATH already.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5724
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5725 --gzip The methylation extractor files (CpG_OT_..., CpG_OB_... etc) will be written out in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5726 a GZIP compressed form to save disk space. This option does not work on bedGraph and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5727 genome-wide cytosine reports as they are 'tiny' anyway.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5728
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5729 --version Displays version information.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5730
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5731 -h/--help Displays this help file and exits.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5732
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5733 --mbias_only The methylation extractor will read the entire file but only output the M-bias table and plots as
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5734 well as a report (optional) and then quit. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5735
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5736 --mbias_off The methylation extractor will process the entire file as usual but doesn't write out any M-bias report.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5737 Only recommended for users who deliberately want to keep an earlier version of the M-bias report.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5738 Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5739
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5740 --multicore <int> Sets the number of cores to be used for the methylation extraction process. If system resources
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5741 are plentiful this is a viable option to speed up the extraction process (we observed a near linear
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5742 speed increase for up to 10 cores used). Please note that a typical process of extracting a BAM file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5743 and writing out '.gz' output streams will in fact use ~3 cores per value of --multicore <int>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5744 specified (1 for the methylation extractor itself, 1 for a Samtools stream, 1 for GZIP stream), so
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5745 --multicore 10 is likely to use around 30 cores of system resources. This option has no bearing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5746 on the bismark2bedGraph or genome-wide cytosine report processes.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5747
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5748
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5749
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5750
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5751 bedGraph specific options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5752 ==========================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5753
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5754 --bedGraph After finishing the methylation extraction, the methylation output is written into a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5755 sorted bedGraph file that reports the position of a given cytosine and its methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5756 state (in %, see details below). The methylation extractor output is temporarily split up into
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5757 temporary files, one per chromosome (written into the current directory or folder
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5758 specified with -o/--output); these temp files are then used for sorting and deleted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5759 afterwards. By default, only cytosines in CpG context will be sorted. The option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5760 '--CX_context' may be used to report all cytosines irrespective of sequence context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5761 (this will take MUCH longer!). The default folder for temporary files during the sorting
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5762 process is the output directory. The bedGraph conversion step is performed by the external
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5763 module 'bismark2bedGraph'; this script needs to reside in the same folder as the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5764 bismark_methylation_extractor itself.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5765
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5766 --zero_based Write out an additional coverage file (ending in .zero.cov) that uses 0-based genomic start
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5767 and 1-based genomic end coordinates (zero-based, half-open), like used in the bedGraph file,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5768 instead of using 1-based coordinates throughout. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5769
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5770
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5771 --cutoff [threshold] The minimum number of times a methylation state has to be seen for that nucleotide
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5772 before its methylation percentage is reported. Default: 1.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5773
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5774 --remove_spaces Replaces whitespaces in the sequence ID field with underscores to allow sorting.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5775
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5776 --CX/--CX_context The sorted bedGraph output file contains information on every single cytosine that was covered
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5777 in the experiment irrespective of its sequence context. This applies to both forward and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5778 reverse strands. Please be aware that this option may generate large temporary and output files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5779 and may take a long time to sort (up to many hours). Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5780 (i.e. Default = CpG context only).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5781
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5782 --buffer_size <string> This allows you to specify the main memory sort buffer when sorting the methylation information.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5783 Either specify a percentage of physical memory by appending % (e.g. --buffer_size 50%) or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5784 a multiple of 1024 bytes, e.g. 'K' multiplies by 1024, 'M' by 1048576 and so on for 'T' etc.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5785 (e.g. --buffer_size 20G). For more information on sort type 'info sort' on a command line.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5786 Defaults to 2G.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5787
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5788 --scaffolds/--gazillion Users working with unfinished genomes sporting tens or even hundreds of thousands of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5789 scaffolds/contigs/chromosomes frequently encountered errors with pre-sorting reads to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5790 individual chromosome files. These errors were caused by the operating system's limit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5791 of the number of filehandle that can be written to at any one time (typically 1024; to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5792 find out this limit on Linux, type: ulimit -a).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5793 To bypass the limitation of open filehandles, the option --scaffolds does not pre-sort
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5794 methylation calls into individual chromosome files. Instead, all input files are
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5795 temporarily merged into a single file (unless there is only a single file), and this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5796 file will then be sorted by both chromosome AND position using the Unix sort command.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5797 Please be aware that this option might take a looooong time to complete, depending on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5798 the size of the input files, and the memory you allocate to this process (see --buffer_size).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5799 Nevertheless, it seems to be working.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5800
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5801 --ample_memory Using this option will not sort chromosomal positions using the UNIX 'sort' command, but will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5802 instead use two arrays to sort methylated and unmethylated calls. This may result in a faster
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5803 sorting process of very large files, but this comes at the cost of a larger memory footprint
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5804 (two arrays of the length of the largest human chromosome 1 (~250M bp) consume around 16GB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5805 of RAM). Due to overheads in creating and looping through these arrays it seems that it will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5806 actually be *slower* for small files (few million alignments), and we are currently testing at
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5807 which point it is advisable to use this option. Note that --ample_memory is not compatible
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5808 with options '--scaffolds/--gazillion' (as it requires pre-sorted files to begin with).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5809
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5810
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5811
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5812 Genome-wide cytosine methylation report specific options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5813 =========================================================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5814
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5815 --cytosine_report After the conversion to bedGraph has completed, the option '--cytosine_report' produces a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5816 genome-wide methylation report for all cytosines in the genome. By default, the output uses 1-based
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5817 chromosome coordinates (zero-based start coords are optional) and reports CpG context only (all
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5818 cytosine context is optional). The output considers all Cs on both forward and reverse strands and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5819 reports their position, strand, trinucleotide content and methylation state (counts are 0 if not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5820 covered). The cytosine report conversion step is performed by the external module
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5821 'coverage2cytosine'; this script needs to reside in the same folder as the bismark_methylation_extractor
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5822 itself.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5823
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5824 --CX/--CX_context The output file contains information on every single cytosine in the genome irrespective of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5825 its context. This applies to both forward and reverse strands. Please be aware that this will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5826 generate output files with > 1.1 billion lines for a mammalian genome such as human or mouse.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5827 Default: OFF (i.e. Default = CpG context only).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5828
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5829 --zero_based Uses 0-based genomic coordinates instead of 1-based coordinates. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5830
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5831 --genome_folder <path> Enter the genome folder you wish to use to extract sequences from (full path only). Accepted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5832 formats are FastA files ending with '.fa' or '.fasta'. Specifying a genome folder path is mandatory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5833
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5834 --split_by_chromosome Writes the output into individual files for each chromosome instead of a single output file. Files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5835 will be named to include the input filename and the chromosome number.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5836
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5837
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5838
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5839 OUTPUT:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5840
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5841 The bismark_methylation_extractor output is in the form:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5842 ========================================================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5843 <seq-ID> <methylation state*> <chromosome> <start position (= end position)> <methylation call>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5844
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5845 * Methylated cytosines receive a '+' orientation,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5846 * Unmethylated cytosines receive a '-' orientation.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5847
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5848
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5849
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5850 The bedGraph output (optional) looks like this (tab-delimited; 0-based start coords, 1-based end coords):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5851 =========================================================================================================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5852
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5853 track type=bedGraph (header line)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5854
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5855 <chromosome> <start position> <end position> <methylation percentage>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5856
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5857
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5858
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5859 The coverage output looks like this (tab-delimited, 1-based genomic coords; zero-based half-open coordinates available with '--zero_based'):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5860 ============================================================================================================================================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5861
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5862 <chromosome> <start position> <end position> <methylation percentage> <count methylated> <count non-methylated>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5863
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5864
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5865
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5866 The genome-wide cytosine methylation output file is tab-delimited in the following format:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5867 ==========================================================================================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5868 <chromosome> <position> <strand> <count methylated> <count non-methylated> <C-context> <trinucleotide context>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5869
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5870
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5871
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5872 This script was last modified on 22 April 2015.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5873
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5874 HOW_TO
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5875 }