annotate bismark_mapping/bismark @ 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/env 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 strict;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3 use warnings;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4 use IO::Handle;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5 use Cwd;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6 $|++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7 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
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-16, 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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
27 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
28 my $bismark_version = 'v0.16.3';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
29 my $command_line = join (" ",@ARGV);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
30
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 ### before processing the command line we will replace --solexa1.3-quals with --phred64-quals as the '.' in the option name will cause Getopt::Long to fail
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
33 foreach my $arg (@ARGV){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
34 if ($arg eq '--solexa1.3-quals'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
35 $arg = '--phred64-quals';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
36 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
37 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
38 my @filenames; # will be populated by processing the command line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
39
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
40 my ($genome_folder,$CT_index_basename,$GA_index_basename,$path_to_bowtie,$sequence_file_format,$bowtie_options,$directional,$unmapped,$ambiguous,$phred64,$solexa,$output_dir,$bowtie2,$vanilla,$sam_no_hd,$skip,$upto,$temp_dir,$non_bs_mm,$insertion_open,$insertion_extend,$deletion_open,$deletion_extend,$gzip,$bam,$samtools_path,$pbat,$prefix,$old_flag,$basename,$score_min_intercept,$score_min_slope,$bt2_large_index,$multicore,$rg_tag,$rg_id,$rg_sample,$ambig_bam,$cram,$cram_ref,$nucleotide_coverage,$dovetail) = process_command_line();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
41
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
42 my @fhs; # stores alignment process names, bisulfite index location, bowtie filehandles and the number of times sequences produced an alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
43 my %chromosomes; # stores the chromosome sequences of the mouse genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
44 my %SQ_order; # stores the order of sequences in the reference. This is to produce SAM/BAM files with a known order of chromosomes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
45 my %counting; # counting various events
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
46 my $final_output_filename; # required for the nucleotide coverage report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
47 my @pids; # storing the process IDs of child processes in parallel mode
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
50 my $seqID_contains_tabs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
51 my $verbose = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
52
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
53 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
54 warn "Running Bismark Parallel version. Number of parallel instances to be spawned: $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
55 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
58 sub 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
59
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
60 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
61 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
62 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
63
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
64 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
65 # 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
66 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
67
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
68 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
69 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
70 $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
71 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
72 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
73 ++$offset;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
74 # 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
75 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
76 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
77 # 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
78 }
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 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
81 # 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
82 $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
83 last;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
86 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
87 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
88 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
89 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
90
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
91 # 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
92 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
93 # 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
94 # 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
95 # 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
96 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
97 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
98 # 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
99 # 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
100 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
101 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
102 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
103 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
104 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
105 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
106 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
107 $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
108 }
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 return ($process_id,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
111 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
112
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 sub subset_input_file_FastQ{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
115
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
116 my ($filename,$process_id,$offset) = @_;
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 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
119 open (OFFSET,"gunzip -c $filename |") or die "Couldn't read from 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
120 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
121 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
122 open (OFFSET,$filename) or die "Couldn't read from 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
123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
124
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
125 # warn "offset is $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
126 my $temp = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
127 $temp .= ".temp.$offset";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
128 $temp =~ s/^.*\///; # replacing everything upto and including the last /, i.e. removing file path information
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 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
131 $temp .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
132 open (TEMPFQ,"| gzip -c - > ${temp_dir}${temp}") or die "Can't write to file ${temp_dir}${temp}: $!\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
135 open (TEMPFQ,'>',"${temp_dir}${temp}") or die "Failed to write output ${temp_dir}${temp}: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
136 }
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 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
139
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
140 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
141 my $l1 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
142 my $l2 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
143 my $l3 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
144 my $l4 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
145
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
146 last unless ($l4);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
147 ++$line_count;
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 ( ($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
150 # 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
151 # 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
152 # 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
153 print TEMPFQ "$l1$l2$l3$l4";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
154 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
155 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
156 # 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
157 next;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
160
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
161 close OFFSET or warn $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
162 close TEMPFQ or warn "Failed to close file handle TEMPFQ: $!\n";
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 warn "Finished subdividing $filename for PID: $process_id and offset $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
165
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
166 return ($temp); # returning the subset filename
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
167
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
168 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
169
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
170 sub subset_input_file_FastA{
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 my ($filename,$process_id,$offset) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
173
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
174 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
175 open (OFFSET,"gunzip -c $filename |") or die "Couldn't read from 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
176 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
177 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
178 open (OFFSET,$filename) or die "Couldn't read from 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
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 # warn "offset is $offset\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
182 my $temp = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
183 $temp .= ".temp.$offset";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
184 $temp =~ s/^.*\///; # replacing everything upto and including the last /, i.e. removing file path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
185
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
186 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
187 $temp .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
188 open (TEMPFA,"| gzip -c - > ${temp_dir}${temp}") or die "Can't write to file ${temp_dir}${temp}: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
189 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
190 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
191 open (TEMPFA,'>',"${temp_dir}${temp}") or die "Failed to write output ${temp_dir}${temp}: $!\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
194 warn "Writing temporary infile to $temp\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
195
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
196 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
197
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
198 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
199 my $l1 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
200 my $l2 = <OFFSET>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
201
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
202 last unless ($l2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
203 ++$line_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
204
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
205 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
206 # 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
207 # 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
208 # 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
209 print TEMPFA "$l1$l2";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
212 # 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
213 next;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
216
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
217 close OFFSET or warn $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
218 close TEMPFA or warn "Failed to close file handle TEMPFQ: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
219
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
220 warn "Finished subdividing $filename for PID: $process_id and offset $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
221
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
222 return ($temp); # returning the subset filename
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
223
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
224 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
225
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
226 #####
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 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
230
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
231 my $original_filename = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
232 my $original_filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
233 my $original_filename_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 chdir $parent_dir or die "Unable to move to initial working 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
236 ### resetting the counting hash and fhs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
237 reset_counters_and_fhs($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
238 @pids = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
239 $seqID_contains_tabs = 0;
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 ### if 2 or more files are provided we can hold the genome in memory and don't need to read it in a second time
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
242 unless (%chromosomes){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
243 my $cwd = getcwd; # storing the path of the current working directory
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
244 warn "Current working directory is: $cwd\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
245 read_genome_into_memory($cwd);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
246 }
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 ### As of version 0.14.0 we support multi-threading. In a first instance we accomplish this by
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
249 ### splitting the input file(s) into several smaller subfiles and merging the results back at
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
250 ### the end.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
251
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
252 # get general settings (also for single-threaded use)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
253 my ($pid,$offset) = 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
254
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
255 my ($single_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
256 ### 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
257 if ($filename =~ ','){
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 $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
260 $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
261
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
262 my ($C_to_T_infile_1,$G_to_A_infile_1); # to be made from mate1 file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
263
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
264 $fhs[0]->{name} = 'CTread1GAread2CTgenome';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
265 $fhs[1]->{name} = 'GAread1CTread2GAgenome';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
266 $fhs[2]->{name} = 'GAread1CTread2CTgenome';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
267 $fhs[3]->{name} = 'CTread1GAread2GAgenome';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
268 warn "\nPaired-end alignments will be performed\n",'='x39,"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
269
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
270 my ($filename_1,$filename_2) = (split (/,/,$filename));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
271 $original_filename_1 = $filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
272 $original_filename_2 = $filename_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
273
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
274 warn "The provided filenames for paired-end alignments are $filename_1 and $filename_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
275
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
276 ### subsetting the input file(s)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
277 unless ($multicore == 1){ # not needed in single-core mode
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
278 # warn "My PID: $pid\nMy 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
279 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
280 my $temp_filename_1 = subset_input_file_FastA($filename_1,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
281 warn "Using the subset file >${temp_dir}$temp_filename_1< as new in-file 1 (instead of >$filename_1<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
282 $filename_1 = "${temp_dir}$temp_filename_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
283
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
284 my $temp_filename_2 = subset_input_file_FastA($filename_2,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
285 warn "Using the subset file >${temp_dir}$temp_filename_2< as new in-file 2 (instead of >$filename_2<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
286 $filename_2 = "${temp_dir}$temp_filename_2";
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{ # FastQ format, default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
289 my $temp_filename_1 = subset_input_file_FastQ($filename_1,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
290 warn "Using the subset file >${temp_dir}$temp_filename_1< as new in-file 1 (instead of >$filename_1<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
291 $filename_1 = "${temp_dir}$temp_filename_1";
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 my $temp_filename_2 = subset_input_file_FastQ($filename_2,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
294 warn "Using the subset file >${temp_dir}$temp_filename_2< as new in-file 2 (instead of >$filename_2<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
295 $filename_2 = "${temp_dir}$temp_filename_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
296 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
299 ### additional variables only for 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
300 my ($C_to_T_infile_2,$G_to_A_infile_2); # to be made from mate2 file
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 ### FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
303 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
304 warn "Input files are 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
305
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
306 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
307 ($C_to_T_infile_1) = biTransformFastAFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
308 ($G_to_A_infile_2) = biTransformFastAFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
309
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
310 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
311 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
312 $fhs[1]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
313 $fhs[1]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
314 $fhs[2]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
315 $fhs[2]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
316 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
317 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
318 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
319 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
320 ($C_to_T_infile_1,$G_to_A_infile_1) = biTransformFastAFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
321 ($C_to_T_infile_2,$G_to_A_infile_2) = biTransformFastAFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
322
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
323 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
324 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
325 $fhs[1]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
326 $fhs[1]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
327 $fhs[2]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
328 $fhs[2]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
329 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
330 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
331 }
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 ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
334 paired_end_align_fragments_to_bisulfite_genome_fastA_bowtie2 ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2);
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
337 paired_end_align_fragments_to_bisulfite_genome_fastA ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2);
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
340
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
341 ### FastQ format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
342 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
343 warn "Input files are in FastQ format\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
344 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
345 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
346 ($C_to_T_infile_1) = biTransformFastQFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
347 ($G_to_A_infile_2) = biTransformFastQFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
348
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
349 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
350 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
351 $fhs[1]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
352 $fhs[1]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
353 $fhs[2]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
354 $fhs[2]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
355 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
356 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
357 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
358 else{ # Bowtie 1 alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
359 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
360 ($C_to_T_infile_1) = biTransformFastQFiles_paired_end_bowtie1_gzip ($filename_1,$filename_2); # passing both reads at the same time
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
361
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
362 $fhs[0]->{inputfile_1} = $C_to_T_infile_1; # this file contains both read 1 and read 2 in tab delimited format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
363 $fhs[0]->{inputfile_2} = undef; # no longer needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
364 $fhs[1]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
365 $fhs[1]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
366 $fhs[2]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
367 $fhs[2]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
368 $fhs[3]->{inputfile_1} = $C_to_T_infile_1; # this file contains both read 1 and read 2 in tab delimited format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
369 $fhs[3]->{inputfile_2} = undef; # no longer needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
370 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
371 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
372 ($C_to_T_infile_1) = biTransformFastQFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
373 ($G_to_A_infile_2) = biTransformFastQFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
374
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
375 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
376 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
377 $fhs[1]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
378 $fhs[1]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
379 $fhs[2]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
380 $fhs[2]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
381 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
382 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
383 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
384 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
385 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
386 elsif($pbat){ # PBAT-Seq. This works for both Bowtie and Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
387 ### At the moment we are only performing alignments only with uncompressed FastQ files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
388 ($C_to_T_infile_1,$G_to_A_infile_1) = biTransformFastQFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
389 ($C_to_T_infile_2,$G_to_A_infile_2) = biTransformFastQFiles_paired_end ($filename_2,2);
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 $fhs[0]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
392 $fhs[0]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
393 $fhs[1]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
394 $fhs[1]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
395 $fhs[2]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
396 $fhs[2]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
397 $fhs[3]->{inputfile_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
398 $fhs[3]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
399 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
400 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
401 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
402 ($C_to_T_infile_1,$G_to_A_infile_1) = biTransformFastQFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
403 ($C_to_T_infile_2,$G_to_A_infile_2) = biTransformFastQFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
404
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
405 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
406 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
407 $fhs[1]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
408 $fhs[1]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
409 $fhs[2]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
410 $fhs[2]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
411 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
412 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
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 else{ # Bowtie 1 alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
415 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
416 ($C_to_T_infile_1,$G_to_A_infile_1) = biTransformFastQFiles_paired_end_bowtie1_gzip ($filename_1,$filename_2); # passing both reads at the same time
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 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
419 $fhs[0]->{inputfile_2} = undef; # not needed for compressed temp files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
420 $fhs[1]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
421 $fhs[1]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
422 $fhs[2]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
423 $fhs[2]->{inputfile_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
424 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
425 $fhs[3]->{inputfile_2} = undef; # not needed for compressed temp files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
426 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
427 else{ # uncompressed temp files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
428 ($C_to_T_infile_1,$G_to_A_infile_1) = biTransformFastQFiles_paired_end ($filename_1,1); # also passing the read number
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
429 ($C_to_T_infile_2,$G_to_A_infile_2) = biTransformFastQFiles_paired_end ($filename_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
430
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
431 $fhs[0]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
432 $fhs[0]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
433 $fhs[1]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
434 $fhs[1]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
435 $fhs[2]->{inputfile_1} = $G_to_A_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
436 $fhs[2]->{inputfile_2} = $C_to_T_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
437 $fhs[3]->{inputfile_1} = $C_to_T_infile_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
438 $fhs[3]->{inputfile_2} = $G_to_A_infile_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
439 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
441 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
442 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
443 paired_end_align_fragments_to_bisulfite_genome_fastQ_bowtie2 ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
444 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
445 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
446 paired_end_align_fragments_to_bisulfite_genome_fastQ ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
447 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
448 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
449 start_methylation_call_procedure_paired_ends($filename_1,$filename_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
452 ### Else we are performing 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
453 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
454 warn "\nSingle-end alignments will be performed\n",'='x39,"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
455
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
456 $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
457 $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
458
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
459 ### subsetting the input file(s)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
460 unless ($multicore == 1){ # not needed in single-core mode
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
461 # warn "My PID: $pid\nMy 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
462 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
463 my $temp_filename = subset_input_file_FastA($filename,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
464 warn "Using the subset file >${temp_dir}$temp_filename< as new in-file (instead of >$filename<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
465 $filename = "${temp_dir}$temp_filename";
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 else{ # FastQ format, default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
468 my $temp_filename = subset_input_file_FastQ($filename,$pid,$offset);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
469 warn "Using the subset file >${temp_dir}$temp_filename< as new in-file (instead of >$filename<)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
470 $filename = "${temp_dir}$temp_filename";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
471 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
472 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
473
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
474 ### Initialising bisulfite conversion filenames
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
475 my ($C_to_T_infile,$G_to_A_infile);
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 ### FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
478 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
479 warn "Input file is 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
480 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
481 ($C_to_T_infile) = biTransformFastAFiles ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
482 $fhs[0]->{inputfile} = $fhs[1]->{inputfile} = $C_to_T_infile;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
485 ($C_to_T_infile,$G_to_A_infile) = biTransformFastAFiles ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
486 $fhs[0]->{inputfile} = $fhs[1]->{inputfile} = $C_to_T_infile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
487 $fhs[2]->{inputfile} = $fhs[3]->{inputfile} = $G_to_A_infile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
488 }
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 ### Creating 4 different bowtie filehandles and storing the first entry
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
491 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
492 single_end_align_fragments_to_bisulfite_genome_fastA_bowtie2 ($C_to_T_infile,$G_to_A_infile);
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
495 single_end_align_fragments_to_bisulfite_genome_fastA ($C_to_T_infile,$G_to_A_infile);
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 ## FastQ format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
500 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
501 warn "Input file is in FastQ format\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
502 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
503 ($C_to_T_infile) = biTransformFastQFiles ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
504 $fhs[0]->{inputfile} = $fhs[1]->{inputfile} = $C_to_T_infile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
505 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
506 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
507 ($G_to_A_infile) = biTransformFastQFiles ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
508 $fhs[0]->{inputfile} = $fhs[1]->{inputfile} = $G_to_A_infile; # PBAT-Seq only uses the G to A converted files
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
511 ($C_to_T_infile,$G_to_A_infile) = biTransformFastQFiles ($filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
512 $fhs[0]->{inputfile} = $fhs[1]->{inputfile} = $C_to_T_infile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
513 $fhs[2]->{inputfile} = $fhs[3]->{inputfile} = $G_to_A_infile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
514 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
515
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
516 ### Creating up to 4 different bowtie filehandles and storing the first entry
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
517 if ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
518 if ($bowtie2){ # as of version 0.10.2 we also support PBAT alignments for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
519 single_end_align_fragments_to_bisulfite_genome_fastQ_bowtie2 (undef,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
520 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
521 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
522 single_end_align_fragments_to_bisulfite_genome_fastQ (undef,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
523 }
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 elsif ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
526 single_end_align_fragments_to_bisulfite_genome_fastQ_bowtie2 ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
527 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
528 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
529 single_end_align_fragments_to_bisulfite_genome_fastQ ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
530 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
533 start_methylation_call_procedure_single_ends($filename,$C_to_T_infile,$G_to_A_infile,$pid);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
534
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
535 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
536
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
537 ### MERGING AND DELETING TEMP FILES // TIDYING UP AFTER A MULTICORE PROCESS
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 if ($pid){ # only performing this for the parent process
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
540
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
541 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
542
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
543 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
544
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
545 ### 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
546 # 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
547 # 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
548
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
549 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
550 # 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
551 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
552 # 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
553 unless ($? == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
554 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
555 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
556 }
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 # regenerating names for temporary files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
559 my @temp_input;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
560 my @temp_output;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
561 my @temp_reports;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
562 my @temp_unmapped_1; # will store single end reads or R1 of paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
563 my @temp_unmapped_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
564 my @temp_ambiguous_1; # will store single end reads or R1 of paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
565 my @temp_ambiguous_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
566 my @temp_ambig_bam;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
567
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
568 for (1..$offset){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
569
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
570 # Temp Input Files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
571 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
572 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
573 push @temp_input, "${original_filename}.temp.${_}.gz";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
576 push @temp_input, "${original_filename}.temp.${_}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
577 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
578
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
579 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
580 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
581 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
582 push @temp_input, "${original_filename_1}.temp.${_}.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
583 push @temp_input, "${original_filename_2}.temp.${_}.gz";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
586 push @temp_input, "${original_filename_1}.temp.${_}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
587 push @temp_input, "${original_filename_2}.temp.${_}";
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 }
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 # if files had a prefix we need to specify it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
592 my $add_prefix;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
593 if (defined $prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
594 $add_prefix = "${prefix}.";
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 $add_prefix = '';
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 # Temp Output Files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
601 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
602
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
603 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
604 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
605 push @temp_output, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_bismark_bt2.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
606 push @temp_reports, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_bismark_bt2_SE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
607 push @temp_ambig_bam, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_bismark_bt2.ambig.bam"; # only for Bowtie 2
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
610 push @temp_output, "${output_dir}${add_prefix}${original_filename}.temp.${_}_bismark_bt2.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
611 push @temp_reports, "${output_dir}${add_prefix}${original_filename}.temp.${_}_bismark_bt2_SE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
612 push @temp_ambig_bam, "${output_dir}${add_prefix}${original_filename}.temp.${_}_bismark_bt2.ambig.bam"; # only for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
613 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
614 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
615 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
616 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
617 push @temp_output, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_bismark.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
618 push @temp_reports, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_bismark_SE_report.txt";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
621 push @temp_output, "${output_dir}${add_prefix}${original_filename}.temp.${_}_bismark.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
622 push @temp_reports, "${output_dir}${add_prefix}${original_filename}.temp.${_}_bismark_SE_report.txt";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
625
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
626 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
627 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
628 push @temp_unmapped_1, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_unmapped_reads.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
629 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
630 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
631 push @temp_unmapped_1, "${output_dir}${add_prefix}${original_filename}.temp.${_}_unmapped_reads.fq";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
634
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
635 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
636 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
637 push @temp_ambiguous_1, "${output_dir}${add_prefix}${original_filename}.temp.${_}.gz_ambiguous_reads.fq";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
640 push @temp_ambiguous_1, "${output_dir}${add_prefix}${original_filename}.temp.${_}_ambiguous_reads.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
641 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
642 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
643
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 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
646 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
647 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
648 push @temp_output, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_bismark_bt2_pe.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
649 push @temp_reports, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_bismark_bt2_PE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
650 push @temp_ambig_bam, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_bismark_bt2_pe.ambig.bam"; # only for Bowtie 2
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
653 push @temp_output, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_bismark_bt2_pe.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
654 push @temp_reports, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_bismark_bt2_PE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
655 push @temp_ambig_bam, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_bismark_bt2_pe.ambig.bam"; # only for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
656 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
657 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
658 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
659 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
660 push @temp_output, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_bismark_pe.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
661 push @temp_reports, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_bismark_PE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
662 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
663 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
664 push @temp_output, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_bismark_pe.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
665 push @temp_reports, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_bismark_PE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
666 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
667 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
668
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
669 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
670 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
671 push @temp_unmapped_1, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_unmapped_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
672 push @temp_unmapped_2, "${output_dir}${add_prefix}${original_filename_2}.temp.${_}.gz_unmapped_reads_2.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
673 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
674 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
675 push @temp_unmapped_1, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_unmapped_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
676 push @temp_unmapped_2, "${output_dir}${add_prefix}${original_filename_2}.temp.${_}_unmapped_reads_2.fq";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
680 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
681 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
682 push @temp_ambiguous_1, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}.gz_ambiguous_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
683 push @temp_ambiguous_2, "${output_dir}${add_prefix}${original_filename_2}.temp.${_}.gz_ambiguous_reads_2.fq";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
686 push @temp_ambiguous_1, "${output_dir}${add_prefix}${original_filename_1}.temp.${_}_ambiguous_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
687 push @temp_ambiguous_2, "${output_dir}${add_prefix}${original_filename_2}.temp.${_}_ambiguous_reads_2.fq";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
690
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
691 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
692 }
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 warn "\n\nRight, cleaning up now...\n\n";
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 # deleting temp files;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
697 warn "Deleting temporary sequence files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
698 foreach my $temp (@temp_input){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
699 #print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
700 $temp =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
701 print "${temp_dir}${temp}\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
702 unlink "${temp_dir}${temp}" or warn "Failed to delete temporary FastQ file ${temp_dir}$temp: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
703 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
704 print "\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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
706 # merging temp BAM files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
707 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
708 merge_individual_BAM_files(\@temp_output,$original_filename,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
709 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
710 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
711 merge_individual_BAM_files(\@temp_output,$original_filename_1,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
712 }
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 # deleting temp BAM files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
715 warn "Deleting temporary BAM files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
716 foreach my $temp (@temp_output){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
717 # print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
718 $temp =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
719 print "${output_dir}${temp}\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
720 unlink "${output_dir}${temp}" or warn "Failed to delete temporary BAM file ${output_dir}${temp}: $!\n";
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 print "\n\n";
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 ### AMBIGUOUS BAM files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
725 if ($ambig_bam){
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 # merging temp AMBIG BAM files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
728 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
729 merge_individual_ambig_BAM_files(\@temp_ambig_bam,$original_filename,$single_end);
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
732 merge_individual_ambig_BAM_files(\@temp_ambig_bam,$original_filename_1,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
733 }
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 # deleting temp BAM files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
736 warn "Deleting temporary ambiguous BAM files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
737 foreach my $temp (@temp_ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
738 # print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
739 $temp =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
740 print "${output_dir}${temp}\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
741 unlink "${output_dir}${temp}" or warn "Failed to delete temporary ambiguous BAM file ${output_dir}${temp}: $!\n";
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 print "\n\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
746 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
747 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
748 merge_individual_unmapped_files(\@temp_unmapped_1,$original_filename,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
749 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
750 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
751 merge_individual_unmapped_files(\@temp_unmapped_1,$original_filename_1,$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
752 merge_individual_unmapped_files(\@temp_unmapped_2,$original_filename_2,$single_end,'_2');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
753 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
754
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
755 # deleting temp unmapped files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
756 warn "Deleting temporary unmapped files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
757 foreach my $temp (@temp_unmapped_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
758 print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
759 unlink "${output_dir}${temp}" or warn "Failed to delete temporary unmapped FastQ file ${output_dir}$temp: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
760 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
761 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
762 foreach my $temp (@temp_unmapped_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
763 print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
764 unlink "${output_dir}${temp}" or warn "Failed to delete temporary unmapped FastQ file ${output_dir}$temp: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
765 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
766 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
767 print "\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
768
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
770
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
771 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
772 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
773 merge_individual_ambiguous_files(\@temp_ambiguous_1,$original_filename,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
774 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
775 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
776 merge_individual_ambiguous_files(\@temp_ambiguous_1,$original_filename_1,$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
777 merge_individual_ambiguous_files(\@temp_ambiguous_2,$original_filename_2,$single_end,'_2');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
778 }
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 # deleting temp ambiguous files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
781 warn "Deleting temporary ambiguous files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
782 foreach my $temp (@temp_ambiguous_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
783 print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
784 unlink "${output_dir}${temp}" or warn "Failed to delete temporary ambiguous FastQ file ${output_dir}$temp: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
785 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
786
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
787 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
788 foreach my $temp (@temp_ambiguous_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
789 print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
790 unlink "${output_dir}${temp}" or warn "Failed to delete temporary ambiguous FastQ file ${output_dir}$temp: $!\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
793 print "\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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
795
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
796 # resetting the counters once more so we can add all data from all temporary reports
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
797 reset_counters_and_fhs($original_filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
798
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
799 ### Merging the Bismark mapping report files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
800 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
801 merge_individual_mapping_reports(\@temp_reports,$original_filename,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
802 print_final_analysis_report_single_end('mock_file1','mock_file_2','mock_pid','mergeThis');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
803 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
804 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
805 merge_individual_mapping_reports(\@temp_reports,$original_filename_1,$single_end,$original_filename_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
806 print_final_analysis_report_paired_ends('mock_file1','mock_file_2','mock_file3','mock_file_4','mock_pid','mergeThis');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
807 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
808
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
809 # deleting temp report files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
810 warn "Deleting temporary report files...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
811 foreach my $temp (@temp_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
812 print "$temp\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
813 unlink "${output_dir}${temp}" or warn "Failed to delete temporary report file $output_dir$temp: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
814 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
815 print "\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
816
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
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
821 if ($pid){ # only for the Parent
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
822 warn "\n====================\nBismark run complete\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
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 ($nucleotide_coverage){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
825 warn "Now calculating observed and expected nucleotide coverage statistics... \n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
826 if ($final_output_filename =~ /(bam|cram)|/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
827 my @args;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
828 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
829 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
830 push @args, "--samtools_path $samtools_path";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
831 push @args, $final_output_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
832 print "@args","\n"; sleep(3);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
833
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
834 system ("$Bin/bam2nuc @args");
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
835 warn "Finished bam2nuc calculation ...\n\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
838 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
839 warn "Nucleotide coverage statistics are currently only available for BAM or CRAM files\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
840 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
843 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
844
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
845 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
846
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
847 sub merge_individual_mapping_reports{
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 my ($temp_reports,$original_filename_1,$single_end,$original_filename_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
850 my $report_file = $original_filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
851 $report_file =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
852 $report_file =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
853
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
854 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
855 $report_file = "${prefix}.${report_file}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
856 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
857
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
858 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
859 $report_file = ${basename};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
860 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
861
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
862 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
863 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
864 $report_file .= '_bismark_bt2_SE_report.txt';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
865 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
866 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
867 $report_file .= '_bismark_SE_report.txt';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
868 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
869 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
870 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
871 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
872 $report_file .= '_bismark_bt2_PE_report.txt';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
873 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
874 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
875 $report_file .= '_bismark_PE_report.txt';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
876 }
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 warn "Writing report to ${output_dir}${report_file}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
879 open (REPORT,'>',"$output_dir$report_file") or die "Failed to write to ${output_dir}${report_file}: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
880
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
881 foreach my $temp(@$temp_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
882 $temp =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
883 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
884
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
885 warn "Now merging temporary reports @$temp_reports into >>> ${output_dir}${report_file} <<<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
886
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
887 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
888 print REPORT "Bismark report for: $original_filename_1 (version: $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
889 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
890 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
891 print REPORT "Bismark report for: $original_filename_1 and $original_filename_2 (version: $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
892 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
893
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 my $first = 0;
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 foreach my $temp(@$temp_reports){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
898 # $temp =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
899
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
900 warn "Merging from file >> $temp <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
901 open (IN,"${output_dir}${temp}") or die "Failed to read from temporary mapping report '${output_dir}${temp}'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
902
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
903 ### this is printing the first couple of lines
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
904 while (<IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
905 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
906 if ($_ =~ /^Bismark report/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
907 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
908 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
909
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
910 unless ($first){ # only happens for the first run we are processing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
911 if ($_ =~ /^Final Alignment/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
912 ++$first;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
913 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
914 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
915 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
916 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
917 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
918 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
919 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
920 close IN or warn "Failed to close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
921
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
922 ### Simon says: You are going to regret this in the future. Just for the record. He might be right...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
923 read_alignment_report($temp,$single_end);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
924
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
925 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
926 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
927
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
928 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
929
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
930 sub read_alignment_report{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
931 my ($report,$single_end) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
932
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
933 my $unique;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
934 my $no_aln;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
935 my $multiple;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
936 my $no_genomic;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
937 my $total_seqs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
938 my $bismark_version;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
939 my $input_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
940
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
941 my $unique_text;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
942 my $no_aln_text;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
943 my $multiple_text;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
944 my $total_seq_text;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
945
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
946 my $total_C_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
947 my ($meth_CpG,$meth_CHG,$meth_CHH,$meth_unknown);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
948 my ($unmeth_CpG,$unmeth_CHG,$unmeth_CHH,$unmeth_unknown);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
949
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
950 my $number_OT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
951 my $number_CTOT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
952 my $number_CTOB;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
953 my $number_OB;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
954
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
955 open (ALN,"${output_dir}${report}") or die "Failed to read from temporary mapping report '$output_dir$report'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
956
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
957 while (<ALN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
958 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
959
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
960 ### General Alignment stats
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
961 if ($_ =~ /^Sequence pairs analysed in total:/ ){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
962 (undef,$total_seqs) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
963 # warn "Total paired seqs: >> $total_seqs <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
964 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
965 elsif ($_ =~ /^Sequences analysed in total:/ ){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
966 (undef,$total_seqs) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
967 # warn "total single-end seqs >> $total_seqs <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
968 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
969
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
970 elsif($_ =~ /^Number of paired-end alignments with a unique best hit:/){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
971 (undef,$unique) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
972 # warn "Unique PE>> $unique <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
973 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
974 elsif($_ =~ /^Number of alignments with a unique best hit 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
975 (undef,$unique) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
976 # warn "Unique SE>> $unique <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
977 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
978
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
979 elsif($_ =~ /^Sequence pairs with no alignments under any condition:/){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
980 (undef,$no_aln) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
981 # warn "No alignment PE >> $no_aln <<\n";
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 elsif($_ =~ /^Sequences with no alignments under any condition:/){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
984 (undef,$no_aln) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
985 # warn "No alignments SE>> $no_aln <<\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
988 elsif($_ =~ /^Sequence pairs did not map uniquely:/){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
989 (undef,$multiple) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
990 # warn "Multiple alignments PE >> $multiple <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
991 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
992 elsif($_ =~ /^Sequences did not map uniquely:/){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
993 (undef,$multiple) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
994 # warn "Multiple alignments SE >> $multiple <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
995 }
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 elsif($_ =~ /^Sequence pairs which were discarded because genomic sequence could not be extracted:/){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
998 (undef,$no_genomic) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
999 # warn "No genomic sequence PE >> $no_genomic <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1000 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1001 elsif($_ =~ /^Sequences which were discarded because genomic sequence could not be extracted:/){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1002 (undef,$no_genomic) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1003 # warn "No genomic sequence SE>> $no_genomic <<\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1006 ### Context Methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1007 elsif($_ =~ /^Total number of C/ ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1008 (undef,$total_C_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
1009 # warn "Total number C >> $total_C_count <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1010 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1012 elsif($_ =~ /^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
1013 (undef,$meth_CpG) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1014 # warn "meth CpG >> $meth_CpG <<\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 elsif($_ =~ /^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
1017 (undef,$meth_CHG) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1018 # warn "meth CHG >> $meth_CHG <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1019 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1020 elsif($_ =~ /^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
1021 (undef,$meth_CHH) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1022 # warn "meth CHH >> $meth_CHH <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1023 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1024 elsif($_ =~ /^Total methylated C\'s in Unknown context:/ ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1025 (undef,$meth_unknown) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1026 # warn "meth Unknown >> $meth_unknown <<\n" ;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1029 elsif($_ =~ /^Total unmethylated C\'s in CpG context:/ or $_ =~ /^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
1030 (undef,$unmeth_CpG) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1031 # warn "unmeth CpG >> $unmeth_CpG <<\n" ;
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 elsif($_ =~ /^Total unmethylated C\'s in CHG context:/ or $_ =~ /^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
1034 (undef,$unmeth_CHG) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1035 # warn "unmeth CHG >> $unmeth_CHG <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1036 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1037 elsif($_ =~ /^Total unmethylated C\'s in CHH context:/ or $_ =~ /^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
1038 (undef,$unmeth_CHH) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1039 # warn "unmeth CHH >> $unmeth_CHH <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1040 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1041 elsif($_ =~ /^Total unmethylated C\'s in Unknown context:/ or $_ =~ /^Total C to T conversions in Unknown context:/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1042 (undef,$unmeth_unknown) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1043 # warn "unmeth Unknown >> $unmeth_unknown <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1044 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1045
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1046 ### Strand Origin
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 elsif($_ =~ /^CT\/GA\/CT:/ ){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1049 (undef,$number_OT) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1050 # warn "Number OT PE>> $number_OT <<\n" ;
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 elsif($_ =~ /^CT\/CT:/ ){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1053 (undef,$number_OT) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1054 # warn "Number OT SE>> $number_OT <<\n" ;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1057 elsif($_ =~ /^GA\/CT\/CT:/ ){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1058 (undef,$number_CTOT) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1059 # warn "Number CTOT PE >> $number_CTOT <<\n" ;
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 elsif($_ =~ /^GA\/CT:/ ){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1062 (undef,$number_CTOT) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1063 # warn "Number CTOT SE >> $number_CTOT <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1064 }
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 elsif($_ =~ /^GA\/CT\/GA:/ ){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1067 (undef,$number_CTOB) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1068 # warn "Number CTOB PE >> $number_CTOB <<\n" ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1069 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1070 elsif($_ =~ /^GA\/GA:/ ){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1071 (undef,$number_CTOB) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1072 # warn "Number CTOB SE >> $number_CTOB <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1073 }
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($_ =~ /^CT\/GA\/GA:/ ){ ## Paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1076 (undef,$number_OB) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1077 # warn "Number OB PE >> $number_OB <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1078 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1079 elsif($_ =~ /^CT\/GA:/ ){ ## Single-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1080 (undef,$number_OB) = split /\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1081 # warn "Number OB SE >> $number_OB <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1082 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1083 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1084
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1085 $counting{sequences_count} += $total_seqs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1086 $counting{unique_best_alignment_count} += $unique;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1087 $counting{no_single_alignment_found} += $no_aln;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1088 $counting{unsuitable_sequence_count} += $multiple;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1089 $counting{genomic_sequence_could_not_be_extracted_count} += $no_genomic;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1090
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1091 $counting{total_meCHH_count} += $meth_CHH;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1092 $counting{total_meCHG_count} += $meth_CHG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1093 $counting{total_meCpG_count} += $meth_CpG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1094 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1095 $counting{total_meC_unknown_count} += $meth_unknown;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1096 }
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 $counting{total_unmethylated_CHH_count} += $unmeth_CHH;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1099 $counting{total_unmethylated_CHG_count} += $unmeth_CHG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1100 $counting{total_unmethylated_CpG_count} += $unmeth_CpG;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1101 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1102 $counting{total_unmethylated_C_unknown_count} += $unmeth_unknown;
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 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
1106 $counting{CT_CT_count} += $number_OT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1107 $counting{CT_GA_count} += $number_OB;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1108 $counting{GA_CT_count} += $number_CTOT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1109 $counting{GA_GA_count} += $number_CTOB;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1112 # paired-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1113 $counting{GA_CT_CT_count} += $number_CTOT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1114 $counting{CT_GA_CT_count} += $number_OT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1115 $counting{GA_CT_GA_count} += $number_CTOB;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1116 $counting{CT_GA_GA_count} += $number_OB;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1120 sub merge_individual_ambiguous_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1121
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1122 my ($temp_ambiguous,$original_filename,$single_end,$paired_information) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1123 my $ambiguous_file = $original_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1124 $ambiguous_file =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1125
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1126 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1127 $ambiguous_file = "${prefix}.${ambiguous_file}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1128 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1129
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1130 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
1131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1132 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1133 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1134 $ambiguous_file = "${basename}_ambiguous_reads.fq.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1135 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1136 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1137 $ambiguous_file = "${basename}_ambiguous_reads.fa.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1138 }
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{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1141 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1142 $ambiguous_file =~ s/$/_ambiguous_reads.fq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1143 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1144 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1145 $ambiguous_file =~ s/$/_ambiguous_reads.fa.gz/;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1148 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1149 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
1150
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1151 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1152 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1153 $ambiguous_file = "${basename}_ambiguous_reads${paired_information}.fq.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1154 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1155 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1156 $ambiguous_file = "${basename}_ambiguous_reads${paired_information}.fa.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1157 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1158 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1159 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1160 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1161 $ambiguous_file =~ s/$/_ambiguous_reads${paired_information}.fq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1162 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1163 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1164 $ambiguous_file =~ s/$/_ambiguous_reads${paired_information}.fa.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1165 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1169 foreach my $temp(@$temp_ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1170 $temp =~ s/.*\///; # removing path information
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1173 open (AMBIGUOUS,"| gzip -c - > $output_dir$ambiguous_file") or die "Failed to write to $ambiguous_file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1174 warn "Now merging ambiguous sequences @$temp_ambiguous into >>> $output_dir$ambiguous_file <<<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1175
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1176 foreach my $temp(@$temp_ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1177 warn "Merging from file >> $temp <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1178 if ($temp =~ /gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1179 open (IN,"gunzip -c ${output_dir}$temp |") or die "Failed to read from ambiguous temp file '${output_dir}$temp'\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1182 open (IN,"${output_dir}$temp") or die "Failed to read from ambiguous temp file '${output_dir}$temp'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1183 }
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 while (<IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1186 print AMBIGUOUS;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1187 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1188 close IN or warn "Failed to close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1189 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1190 warn "\n";
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 close AMBIGUOUS or warn "Failed to close output filehandle AMBIGUOUS\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1193 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1194
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 sub merge_individual_unmapped_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1197
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1198 my ($temp_unmapped,$original_filename,$single_end,$paired_information) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1199 my $unmapped_file = $original_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1200 $unmapped_file =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1201
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1202 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1203 $unmapped_file = "${prefix}.${unmapped_file}";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1206 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
1207
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1208 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1209 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1210 $unmapped_file = "${basename}_unmapped_reads.fq.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1211 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1212 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1213 $unmapped_file = "${basename}_unmapped_reads.fa.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1214 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1215 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1216 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1217 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1218 $unmapped_file =~ s/$/_unmapped_reads.fq.gz/;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1221 $unmapped_file =~ s/$/_unmapped_reads.fa.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1222 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1223 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1224 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1225 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
1226
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1227 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1228 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1229 $unmapped_file = "${basename}_unmapped_reads${paired_information}.fq.gz";
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 $unmapped_file = "${basename}_unmapped_reads${paired_information}.fa.gz";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1233 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1236 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1237 $unmapped_file =~ s/$/_unmapped_reads${paired_information}.fq.gz/;
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 $unmapped_file =~ s/$/_unmapped_reads${paired_information}.fa.gz/;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1245 foreach my $temp(@$temp_unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1246 $temp =~ s/.*\///; # removing path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1247 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1248
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1249 open (UNMAPPED,"| gzip -c - > ${output_dir}${unmapped_file}") or die "Failed to write to ${output_dir}${unmapped_file}: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1250 warn "Now merging unmapped sequences @$temp_unmapped into >>> ${output_dir}${unmapped_file} <<<\n";
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 foreach my $temp(@$temp_unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1253 warn "Merging from file >> $temp <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1254 if ($temp =~ /gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1255 open (IN,"gunzip -c ${output_dir}${temp} |") or die "Failed to read from unmapped temp file '${output_dir}$temp'\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1258 open (IN,"${output_dir}${temp}") or die "Failed to read from unmapped temp file '${output_dir}${temp}'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1259 }
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 while (<IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1262 print UNMAPPED;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1263 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1264 close IN or warn "Failed to close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1265 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1266 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1267
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1268 close UNMAPPED or warn "Failed to close output filehandle UNMAPPED\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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1272 sub merge_individual_BAM_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1273
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1274 my ($tempbam,$original_filename,$single_end) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1275 my $merged_name = $original_filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1276
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1277 #warn "merged name is: $merged_name\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1278 $merged_name =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1279 # warn "merged name is: $merged_name\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1280 $merged_name =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1281 # warn "merged name is: $merged_name\n"; sleep(5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1282
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1283 foreach my $temp_bam(@$tempbam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1284 $temp_bam =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1285 }
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 ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1288 $merged_name = "$prefix.$merged_name";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1291 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
1292 if ($bowtie2){ # BAM format is the default for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1293 $merged_name .= '_bismark_bt2.bam';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1294 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1295 else{ # BAM is the default output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1296 $merged_name .= '_bismark.bam';
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1299 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1300 $merged_name = "${basename}.bam";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1303 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1304 if ($bowtie2){ # BAM format is the default for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1305 $merged_name .= '_bismark_bt2_pe.bam';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1306 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1307 else{ # BAM is the default output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1308 $merged_name .= '_bismark_pe.bam';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1309 }
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 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1312 $merged_name = "${basename}_pe.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1313 }
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
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 if ($cram){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1318 $merged_name =~ s/bam$/cram/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1319 warn "At this stage we write out a single CRAM file and delete all temporary BAM files\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1320 warn "Now merging BAM files @$tempbam into >>> $merged_name <<<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1321 $final_output_filename = "${output_dir}${merged_name}";
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 open (OUT,"| $samtools_path view -h -C -T $cram_ref 2>/dev/null - > ${output_dir}${merged_name}") or die "Failed to write to CRAM file $merged_name: $!\nPlease note that this option requires Samtools version 1.2 or higher!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1324 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1325 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1326 $final_output_filename = "${output_dir}${merged_name}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1327 warn "Now merging BAM files @$tempbam into >>> $merged_name <<<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1328 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > ${output_dir}${merged_name}") or die "Failed to write to $merged_name: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1329 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1330
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1331 my $first = 0;
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 foreach my $temp_bam(@$tempbam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1334 # $temp_bam =~ s/.*\///; # deleting path information
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 warn "Merging from file >> $temp_bam <<\n";
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 if ($first > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1339 open (IN,"$samtools_path view ${output_dir}${temp_bam} |") or die "Failed to read from BAM file ${output_dir}${temp_bam}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1340 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1341 else{ # only for the first file we print the header as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1342 open (IN,"$samtools_path view -h ${output_dir}${temp_bam} |") or die "Failed to read from BAM file ${output_dir}${temp_bam}\n";
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 while (<IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1346 print OUT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1347 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1348 close IN or warn "Failed to close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1349 ++$first;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1350 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1351 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1352
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1353 close OUT or warn "Failed to close output filehandle\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1354
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 sub merge_individual_ambig_BAM_files{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1359
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1360 my ($tempbam,$original_filename,$single_end) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1361 my $merged_name = $original_filename;
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 # warn "merged name is: $merged_name\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1364 $merged_name =~ s/.*\///; # deleting path information
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1365 # warn "merged name is: $merged_name\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
1366
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1367 foreach my $temp_bam(@$tempbam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1368 $temp_bam =~ s/.*\///; # deleting path information
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1371 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1372 $merged_name = "$prefix.$merged_name";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1373 }
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 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
1376 if ($bowtie2){ # BAM format is the default for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1377 $merged_name .= '_bismark_bt2.ambig.bam';
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1380 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1381 $merged_name = "${basename}.ambig.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1382 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1383 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1384 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1385 if ($bowtie2){ # BAM format is the default for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1386 $merged_name .= '_bismark_bt2_pe.ambig.bam';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1387 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1388
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1389 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1390 $merged_name = "${basename}_pe.ambig.bam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1391 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1392 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1393
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1394 warn "Now merging ambiguous BAM files @$tempbam into >>> $merged_name <<<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1395 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > ${output_dir}${merged_name}") or die "Failed to write to $merged_name: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1396 my $first = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1397
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1398 foreach my $temp_bam(@$tempbam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1399 # $temp_bam =~ s/.*\///; # deleting path information
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 warn "Merging from file >> $temp_bam <<\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1402
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1403 if ($first > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1404 open (IN,"$samtools_path view ${output_dir}${temp_bam} |") or die "Failed to read from BAM file ${output_dir}${temp_bam}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1405 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1406 else{ # only for the first file we print the header as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1407 open (IN,"$samtools_path view -h ${output_dir}${temp_bam} |") or die "Failed to read from BAM file ${output_dir}${temp_bam}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1408 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1409
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1410 while (<IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1411 print OUT;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1412 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1413 close IN or warn "Failed to close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1414 ++$first;
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 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1417
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1418 close OUT or warn "Failed to close output filehandle\n\n";
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 sub start_methylation_call_procedure_single_ends {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1422 my ($sequence_file,$C_to_T_infile,$G_to_A_infile,$pid) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1423 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1424
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1425 if ($sequence_file =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1426 ($dir,$filename) = $sequence_file =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1427 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1428 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1429 $filename = $sequence_file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1430 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1431
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1432 ### printing all alignments to a results file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1433 my $outfile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1434 # warn "Outfile: $outfile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1435 $outfile =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1436 # warn "Outfile: $outfile\n";sleep(5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1437
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1438 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1439 $outfile = "$prefix.$outfile";
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 if ($bowtie2){ # SAM format is the default for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1442 $outfile =~ s/$/_bismark_bt2.sam/;
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 elsif ($vanilla){ # vanilla custom Bismark output single-end output (like Bismark versions 0.5.X)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1445 $outfile =~ s/$/_bismark.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1446 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1447 else{ # SAM is the default output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1448 $outfile =~ s/$/_bismark.sam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1449 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1450
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1451 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1452 $outfile = "${basename}.sam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1453 }
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 $bam = 0 unless (defined $bam);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1456
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1457 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1458 my $ambig_bam_out = $outfile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1459 $ambig_bam_out =~ s/sam$/ambig.bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1460 warn "Ambiguous BAM output: $ambig_bam_out\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1461 open (AMBIBAM,"| $samtools_path view -bSh 2>/dev/null - > $output_dir$ambig_bam_out") or die "Failed to write to $ambig_bam_out: $!\n";
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 if ($cram){ ### Samtools is installed, writing out CRAM directly. This qill require Samtools version 1.2 or higher!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1465 ### for multicore processing we write out BAM files by default and merge them together as a single CRAM file in the merging step later on.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1466 ### This avoids having to change all the the file endings on the way
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1467 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
1468 $outfile =~ s/sam$/bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1469 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > $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
1470 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1471 else{ # single-core mode
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1472 $outfile =~ s/sam$/cram/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1473 $final_output_filename = "${output_dir}${outfile}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1474 open (OUT,"| $samtools_path view -h -C -T $cram_ref 2>/dev/null - > $output_dir$outfile") or die "Failed to write to CRAM file $outfile: $!\nPlease note that this option requires Samtools version 1.2 or higher!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1475 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1476 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1477 elsif($bam == 1){ ### Samtools is installed, writing out BAM directly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1478 $outfile =~ s/sam$/bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1479 $final_output_filename = "${output_dir}${outfile}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1480 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > $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
1481 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1482 elsif($bam == 2){ ### no Samtools found on system. Using GZIP compression instead
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1483 $outfile .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1484 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
1485 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1486 else{ # uncompressed ouput, default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1487 open (OUT,'>',"$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
1488 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1489 warn "\n>>> Writing bisulfite mapping results to $output_dir$outfile <<<\n\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1492 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1493
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1494 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1495 print OUT "Bismark version: $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
1496 }
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 ### printing alignment and methylation call summary to a report file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1499 my $reportfile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1500 $reportfile =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1501
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1502 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1503 $reportfile = "$prefix.$reportfile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1504 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1505 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1506 $reportfile =~ s/$/_bismark_bt2_SE_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1507 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1508 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1509 $reportfile =~ s/$/_bismark_SE_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1510 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1511
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1512 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1513 $reportfile = "${basename}_SE_report.txt";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1514 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1515
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1516 open (REPORT,'>',"$output_dir$reportfile") or die "Failed to write to $reportfile: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1517 print REPORT "Bismark report for: $sequence_file (version: $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
1518
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1519 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1520 my $unmapped_file = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1521 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1522 $unmapped_file = "$prefix.$unmapped_file";
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 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1526 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1527 $unmapped_file = "${basename}_unmapped_reads.fq";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1530 $unmapped_file = "${basename}_unmapped_reads.fa";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1531 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1532 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1533 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1534 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1535 $unmapped_file =~ s/$/_unmapped_reads.fq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1536 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1537 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1538 $unmapped_file =~ s/$/_unmapped_reads.fa/;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1541
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1542 if ($multicore > 1){ # multicore runs already output gzipped unmapped files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1543 open (UNMAPPED,'>',"$output_dir$unmapped_file") or die "Failed to write to $unmapped_file: $!\n";
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 $unmapped_file .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1547 open (UNMAPPED,"| gzip -c - > $output_dir$unmapped_file") or die "Failed to write to $unmapped_file: $!\n";
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 warn "Unmapped sequences will be written to $output_dir$unmapped_file\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1552 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1553 my $ambiguous_file = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1554
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1555 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1556 $ambiguous_file = "$prefix.$ambiguous_file";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1557 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1558
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1559 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1560 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1561 $ambiguous_file = "${basename}_ambiguous_reads.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1562 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1563 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1564 $ambiguous_file = "${basename}_ambiguous_reads.fa";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1567 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1568 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1569 $ambiguous_file =~ s/$/_ambiguous_reads.fq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1570 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1571 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1572 $ambiguous_file =~ s/$/_ambiguous_reads.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1573 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1576 if ($multicore > 1){ # multicore runs already output gzipped amobiguous files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1577 open (AMBIG,'>',"$output_dir$ambiguous_file") or die "Failed to write to $ambiguous_file: $!\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1580 $ambiguous_file .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1581 open (AMBIG,"| gzip -c - > $output_dir$ambiguous_file") or die "Failed to write to $ambiguous_file: $!\n";
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 warn "Ambiguously mapping sequences will be written to $output_dir$ambiguous_file\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1584 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1585
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1586 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1587 print REPORT "Option '--directional' specified (default mode): alignments to complementary strands (CTOT, CTOB) were ignored (i.e. not performed)\n";
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 elsif ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1590 print REPORT "Option '--pbat' specified: alignments to original strands (OT and OB) strands were ignored (i.e. not performed)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1591 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1592 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1593 print REPORT "Option '--non_directional' specified: alignments to all strands were being performed (OT, OB, CTOT, CTOB)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1594 }
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 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1597 print REPORT "Bismark was run with Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1598 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1599 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1600 print REPORT "Bismark was run with Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1601 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1602
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1603
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1604 unless ($vanilla or $sam_no_hd){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1605 generate_SAM_header();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1606 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1607
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1608 ### Input file is in FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1609 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1610 process_single_end_fastA_file_for_methylation_call($sequence_file,$C_to_T_infile,$G_to_A_infile,$pid);
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 ### Input file is in FastQ format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1613 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1614 process_single_end_fastQ_file_for_methylation_call($sequence_file,$C_to_T_infile,$G_to_A_infile,$pid);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1615 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1616 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1617
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1618 sub start_methylation_call_procedure_paired_ends {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1619 my ($sequence_file_1,$sequence_file_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1620 my ($dir_1,$filename_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1621
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1622 if ($sequence_file_1 =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1623 ($dir_1,$filename_1) = $sequence_file_1 =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1624 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1625 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1626 $filename_1 = $sequence_file_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1627 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1628
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1629 my ($dir_2,$filename_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1630
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1631 if ($sequence_file_2 =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1632 ($dir_2,$filename_2) = $sequence_file_2 =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1633 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1634 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1635 $filename_2 = $sequence_file_2;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1638 ### printing all alignments to a results file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1639 my $outfile = $filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1640 # warn "Outfile: $outfile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1641 $outfile =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1642 # warn "Outfile: $outfile\n";sleep(5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1643
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1644 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1645 $outfile = "$prefix.$outfile";
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 if ($bowtie2){ # SAM format is the default Bowtie 2 output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1648 $outfile =~ s/$/_bismark_bt2_pe.sam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1649 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1650 elsif ($vanilla){ # vanilla custom Bismark paired-end output (like Bismark versions 0.5.X)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1651 $outfile =~ s/$/_bismark_pe.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1652 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1653 else{ # SAM format is the default Bowtie 1 output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1654 $outfile =~ s/$/_bismark_pe.sam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1655 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1656
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 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1659 $outfile = "${basename}_pe.sam";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1660 }
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 ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1663 my $ambig_bam_out = $outfile;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1664 $ambig_bam_out =~ s/sam$/ambig.bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1665 warn "Ambiguous BAM output: $ambig_bam_out\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1666 open (AMBIBAM,"| $samtools_path view -bSh 2>/dev/null - > $output_dir$ambig_bam_out") or die "Failed to write to $ambig_bam_out: $!\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1669 $bam = 0 unless (defined $bam);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1670
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1671 if ($cram){ ### Samtools is installed, writing out CRAM directly. This qill require Samtools version 1.2 or higher!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1672 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
1673 $outfile =~ s/sam$/bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1674 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > $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
1675 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1676 else{ # single-core mode
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1677 $outfile =~ s/sam$/cram/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1678 $final_output_filename = "${output_dir}${outfile}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1679 open (OUT,"| $samtools_path view -h -C -T $cram_ref 2>/dev/null - > $output_dir$outfile") or die "Failed to write to CRAM file $outfile: $!\nPlease note that this option requires Samtools version 1.2 or higher!\n\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1682 elsif ($bam == 1){ ### Samtools is installed, writing out BAM directly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1683 $outfile =~ s/sam$/bam/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1684 $final_output_filename = "${output_dir}${outfile}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1685 open (OUT,"| $samtools_path view -bSh 2>/dev/null - > $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
1686 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1687 elsif($bam == 2){ ### no Samtools found on system. Using GZIP compression instead
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1688 $outfile .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1689 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
1690 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1691 else{ # uncompressed ouput, default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1692 open (OUT,'>',"$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
1693 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1694
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1695 warn "\n>>> Writing bisulfite mapping results to $outfile <<<\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1696 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1697
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1698 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1699 print OUT "Bismark version: $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
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 ### printing alignment and methylation call summary to a report file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1703 my $reportfile = $filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1704 $reportfile =~ s/(\.fastq\.gz|\.fq\.gz|\.fastq|\.fq)$//; # attempting to remove fastq.gz etc to make filename a little shorter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1705
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1706 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1707 $reportfile = "$prefix.$reportfile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1708 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1709
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1710 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1711 $reportfile =~ s/$/_bismark_bt2_PE_report.txt/;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1714 $reportfile =~ s/$/_bismark_PE_report.txt/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1715 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1716
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1717 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1718 $reportfile = "${basename}_PE_report.txt";
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 open (REPORT,'>',"$output_dir$reportfile") or die "Failed to write to $reportfile: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1722 print REPORT "Bismark report for: $sequence_file_1 and $sequence_file_2 (version: $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
1723
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1724 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1725 print REPORT "Bismark was run with Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1728 print REPORT "Bismark was run with Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1731
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1732 ### Unmapped read output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1733 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1734 my $unmapped_1 = $filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1735 my $unmapped_2 = $filename_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1736
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1737 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1738 $unmapped_1 = "$prefix.$unmapped_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1739 $unmapped_2 = "$prefix.$unmapped_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1740 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1741
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1742 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1743 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1744 $unmapped_1 = "${basename}_unmapped_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1745 $unmapped_2 = "${basename}_unmapped_reads_2.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1746 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1747 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1748 $unmapped_1 = "${basename}_unmapped_reads_1.fa";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1749 $unmapped_2 = "${basename}_unmapped_reads_2.fa";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1752 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1753 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1754 $unmapped_1 =~ s/$/_unmapped_reads_1.fq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1755 $unmapped_2 =~ s/$/_unmapped_reads_2.fq/;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1758 $unmapped_1 =~ s/$/_unmapped_reads_1.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1759 $unmapped_2 =~ s/$/_unmapped_reads_2.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1760 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1761 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1762
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1763 if ($multicore > 1){ # unmapped files are merged into .gz files in multicore runs anyway
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1764 open (UNMAPPED_1,'>',"$output_dir$unmapped_1") or die "Failed to write to $unmapped_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1765 open (UNMAPPED_2,'>',"$output_dir$unmapped_2") or die "Failed to write to $unmapped_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1766 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1767 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1768 $unmapped_1 .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1769 $unmapped_2 .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1770 open (UNMAPPED_1,"| gzip -c - > $output_dir$unmapped_1") or die "Failed to write to $unmapped_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1771 open (UNMAPPED_2,"| gzip -c - > $output_dir$unmapped_2") or die "Failed to write to $unmapped_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1772 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1773 warn "Unmapped sequences will be written to $unmapped_1 and $unmapped_2\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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1776 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1777 my $amb_1 = $filename_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1778 my $amb_2 = $filename_2;
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 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1781 $amb_1 = "$prefix.$amb_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1782 $amb_2 = "$prefix.$amb_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1783 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1784
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1785 if ($basename){ # Output file basename is set using the -B argument
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1786 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1787 $amb_1 = "${basename}_ambiguous_reads_1.fq";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1788 $amb_2 = "${basename}_ambiguous_reads_2.fq";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1791 $amb_1 = "${basename}_ambiguous_reads_1.fa";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1792 $amb_2 = "${basename}_ambiguous_reads_2.fa";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1793 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1794 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1795 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1796 if ($sequence_file_format eq 'FASTQ'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1797 $amb_1 =~ s/$/_ambiguous_reads_1.fq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1798 $amb_2 =~ s/$/_ambiguous_reads_2.fq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1799 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1800 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1801 $amb_1 =~ s/$/_ambiguous_reads_1.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1802 $amb_2 =~ s/$/_ambiguous_reads_2.fa/;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1805
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1806 if ($multicore > 1){ # ambiguous files are merged into .gz files in multicore runs anyway
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1807 open (AMBIG_1,'>',"$output_dir$amb_1") or die "Failed to write to $amb_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1808 open (AMBIG_2,'>',"$output_dir$amb_2") or die "Failed to write to $amb_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1809 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1810 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1811 $amb_1 .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1812 $amb_2 .= '.gz';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1813 open (AMBIG_1,"| gzip -c - > $output_dir$amb_1") or die "Failed to write to $amb_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1814 open (AMBIG_2,"| gzip -c - > $output_dir$amb_2") or die "Failed to write to $amb_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1815 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1816 warn "Ambiguously mapping sequences will be written to $amb_1 and $amb_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1817 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1818
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1819 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1820 print REPORT "Option '--directional' specified (default mode): alignments to complementary strands (CTOT, CTOB) were ignored (i.e. not performed)\n\n";
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 elsif ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1823 print REPORT "Option '--pbat' specified: alignments to original strands (OT, OB) were ignored (i.e. not performed)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1824 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1825 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1826 print REPORT "Option '--non_directional' specified: alignments to all strands were being performed (OT, OB, CTOT, CTOB)\n\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1829
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 unless ($vanilla or $sam_no_hd){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1832 generate_SAM_header();
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 ### Input files are in FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1836 if ($sequence_file_format eq 'FASTA'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1837 process_fastA_files_for_paired_end_methylation_calls($sequence_file_1,$sequence_file_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid);
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 ### Input files are in FastQ format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1840 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1841 process_fastQ_files_for_paired_end_methylation_calls($sequence_file_1,$sequence_file_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1842 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1843 }
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 sub print_final_analysis_report_single_end{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1846 my ($C_to_T_infile,$G_to_A_infile,$pid,$merge_multi) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1847
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1848 if ($merge_multi){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1849 warn "Printing a final merged alignment report for all individual sub-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
1850 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1851 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1852 ### All sequences from the original sequence file have been analysed now
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1853 ### deleting temporary C->T or G->A infiles
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 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1856 my $deletion_successful = unlink "$temp_dir$C_to_T_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1857 if ($deletion_successful == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1858 warn "\nSuccessfully deleted the temporary file $temp_dir$C_to_T_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1859 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1860 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1861 warn "Could not delete temporary file $C_to_T_infile properly $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1862 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1863 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1864 elsif ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1865 my $deletion_successful = unlink "$temp_dir$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1866 if ($deletion_successful == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1867 warn "\nSuccessfully deleted the temporary file $temp_dir$G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1868 }
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 warn "Could not delete temporary file $G_to_A_infile properly $!\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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1874 my $deletion_successful = unlink "$temp_dir$C_to_T_infile","$temp_dir$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1875 if ($deletion_successful == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1876 warn "\nSuccessfully deleted the temporary files $temp_dir$C_to_T_infile and $temp_dir$G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1877 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1878 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1879 warn "Could not delete temporary files properly $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1880 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1881 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1884 ### printing a final report for the alignment procedure
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1885 print REPORT "Final Alignment report\n",'='x22,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1886 warn "Final Alignment report\n",'='x22,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1887 # foreach my $index (0..$#fhs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1888 # print "$fhs[$index]->{name}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1889 # print "$fhs[$index]->{seen}\talignments on the correct strand 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
1890 # print "$fhs[$index]->{wrong_strand}\talignments were discarded (nonsensical alignments)\n\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1893 ### printing a final report for the methylation call procedure
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1894 warn "Sequences analysed in total:\t$counting{sequences_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1895 print REPORT "Sequences analysed in total:\t$counting{sequences_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1896 my $percent_alignable_sequences;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1897
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1898 if ($counting{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
1899 $percent_alignable_sequences = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1900 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1901 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1902 $percent_alignable_sequences = sprintf ("%.1f",$counting{unique_best_alignment_count}*100/$counting{sequences_count});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1903 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1904
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1905 warn "Number of alignments with a unique best hit from the different alignments:\t$counting{unique_best_alignment_count}\nMapping efficiency:\t${percent_alignable_sequences}%\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1906 print REPORT "Number of alignments with a unique best hit from the different alignments:\t$counting{unique_best_alignment_count}\nMapping efficiency:\t${percent_alignable_sequences}%\n";
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 ### percentage of low complexity reads overruled because of low complexity (thereby creating a bias for highly methylated reads),
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1909 ### only calculating the percentage if there were any overruled alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1910 if ($counting{low_complexity_alignments_overruled_count}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1911 my $percent_overruled_low_complexity_alignments = sprintf ("%.1f",$counting{low_complexity_alignments_overruled_count}*100/$counting{sequences_count});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1912 # print REPORT "Number of low complexity alignments which were overruled to have a unique best hit rather than discarding them:\t$counting{low_complexity_alignments_overruled_count}\t(${percent_overruled_low_complexity_alignments}%)\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1915 print "Sequences with no alignments under any condition:\t$counting{no_single_alignment_found}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1916 print "Sequences did not map uniquely:\t$counting{unsuitable_sequence_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1917 print "Sequences which were discarded because genomic sequence could not be extracted:\t$counting{genomic_sequence_could_not_be_extracted_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
1918 print "Number of sequences with unique best (first) alignment came from the bowtie output:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1919 print join ("\n","CT/CT:\t$counting{CT_CT_count}\t((converted) top strand)","CT/GA:\t$counting{CT_GA_count}\t((converted) bottom strand)","GA/CT:\t$counting{GA_CT_count}\t(complementary to (converted) top strand)","GA/GA:\t$counting{GA_GA_count}\t(complementary to (converted) bottom strand)"),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1920
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1921 print REPORT "Sequences with no alignments under any condition:\t$counting{no_single_alignment_found}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1922 print REPORT "Sequences did not map uniquely:\t$counting{unsuitable_sequence_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1923 print REPORT "Sequences which were discarded because genomic sequence could not be extracted:\t$counting{genomic_sequence_could_not_be_extracted_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
1924 print REPORT "Number of sequences with unique best (first) alignment came from the bowtie output:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1925 print REPORT join ("\n","CT/CT:\t$counting{CT_CT_count}\t((converted) top strand)","CT/GA:\t$counting{CT_GA_count}\t((converted) bottom strand)","GA/CT:\t$counting{GA_CT_count}\t(complementary to (converted) top strand)","GA/GA:\t$counting{GA_GA_count}\t(complementary to (converted) bottom strand)"),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1926
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1927 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1928 print "Number of alignments to (merely theoretical) complementary strands being rejected in total:\t$counting{alignments_rejected_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
1929 print REPORT "Number of alignments to (merely theoretical) complementary strands being rejected in total:\t$counting{alignments_rejected_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
1930 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1931
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1932 ### 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
1933 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
1934 my $total_number_of_C = $counting{total_meCHH_count}+$counting{total_meCHG_count}+$counting{total_meCpG_count}+$counting{total_unmethylated_CHH_count}+$counting{total_unmethylated_CHG_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
1935 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
1936 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
1937 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
1938 warn "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1939 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1940 warn "Total methylated C's in Unknown context:\t$counting{total_meC_unknown_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1941 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1942 warn "\n";
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 warn "Total unmethylated C's 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
1945 warn "Total unmethylated C's 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
1946 warn "Total unmethylated C's in CHH context:\t$counting{total_unmethylated_CHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1947 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1948 warn "Total unmethylated C's in Unknown context:\t$counting{total_unmethylated_C_unknown_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1949 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1950 warn "\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 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
1953 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
1954
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1955 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
1956 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
1957 print REPORT "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1958 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1959 print REPORT "Total methylated C's in Unknown context:\t$counting{total_meC_unknown_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1960 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1961 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
1962
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1963 print REPORT "Total unmethylated C's 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
1964 print REPORT "Total unmethylated C's 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
1965 print REPORT "Total unmethylated C's in CHH context:\t$counting{total_unmethylated_CHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1966 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1967 print REPORT "Total unmethylated C's in Unknown context:\t$counting{total_unmethylated_C_unknown_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1968 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1969 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
1970
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1971 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
1972 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
1973 $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
1974 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1975
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1976 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
1977 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
1978 $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
1979 }
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 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
1982 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
1983 $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
1984 }
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 $percent_meC_unknown;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1987 if (($counting{total_meC_unknown_count}+$counting{total_unmethylated_C_unknown_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1988 $percent_meC_unknown = sprintf("%.1f",100*$counting{total_meC_unknown_count}/($counting{total_meC_unknown_count}+$counting{total_unmethylated_C_unknown_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1989 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1992 ### 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
1993 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
1994 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
1995 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
1996 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1997 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
1998 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
1999 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
2000 }
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 ### printing methylated C percentage (CHG context) if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2003 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
2004 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
2005 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
2006 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2007 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2008 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
2009 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
2010 }
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 ### printing methylated C percentage (CHH context) if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2013 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
2014 warn "C methylated in CHH context:\t${percent_meCHH}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2015 print REPORT "C methylated in CHH context:\t${percent_meCHH}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2016 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2017 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2018 warn "Can't determine percentage of methylated Cs in CHH 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
2019 print REPORT "Can't determine percentage of methylated Cs in CHH 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
2020 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2021
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2022 ### printing methylated C percentage (Unknown C context) if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2023 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2024 if ($percent_meC_unknown){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2025 warn "C methylated in Unknown context (CN or CHN):\t${percent_meC_unknown}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2026 print REPORT "C methylated in Unknown context (CN or CHN):\t${percent_meC_unknown}%\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2029 warn "Can't determine percentage of methylated Cs in Unknown context (CN or CHN) 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
2030 print REPORT "Can't determine percentage of methylated Cs in Unknown context (CN or CHN) 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
2031 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2032 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2033 print 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
2034 warn "\n\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 ($seqID_contains_tabs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2037 warn "The sequence IDs in the provided file contain tab-stops which might prevent sequence alignments. If this happened, please replace all tab characters within the seqID field with spaces before running Bismark.\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2038 print REPORT "The sequence IDs in the provided file contain tab-stops which might prevent sequence alignments. If this happened, please replace all tab characters within the seqID field with spaces before running Bismark.\n\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2041
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2042
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2043 sub print_final_analysis_report_paired_ends{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2044 my ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid,$merge_multi) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2045
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2046 if ($merge_multi){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2047 warn "Printing a final merged alignment report for all individual sub-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
2048 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2049 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2050 ### All sequences from the original sequence file have been analysed now, therefore deleting temporary C->T or G->A infiles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2051 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2052 if ($G_to_A_infile_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2053 my $deletion_successful = unlink "$temp_dir$C_to_T_infile_1","$temp_dir$G_to_A_infile_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2054 if ($deletion_successful == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2055 warn "\nSuccessfully deleted the temporary files $temp_dir$C_to_T_infile_1 and $temp_dir$G_to_A_infile_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
2056 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2057 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2058 warn "Could not delete temporary files $temp_dir$C_to_T_infile_1 and $temp_dir$G_to_A_infile_2 properly: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2059 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2060 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2061 else{ # for paired-end FastQ infiles with Bowtie1 there is only one file to delete
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2062 my $deletion_successful = unlink "$temp_dir$C_to_T_infile_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2063 if ($deletion_successful == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2064 warn "\nSuccessfully deleted the temporary file $temp_dir$C_to_T_infile_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
2065 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2066 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2067 warn "Could not delete temporary file $temp_dir$C_to_T_infile_1 properly: $!\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2071 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2072 if ($G_to_A_infile_2 and $C_to_T_infile_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2073 my $deletion_successful = unlink "$temp_dir$C_to_T_infile_1","$temp_dir$G_to_A_infile_1","$temp_dir$C_to_T_infile_2","$temp_dir$G_to_A_infile_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2074 if ($deletion_successful == 4){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2075 warn "\nSuccessfully deleted the temporary files $temp_dir$C_to_T_infile_1, $temp_dir$G_to_A_infile_1, $temp_dir$C_to_T_infile_2 and $temp_dir$G_to_A_infile_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
2076 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2077 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2078 warn "Could not delete temporary files properly: $!\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2081 else{ # for paired-end FastQ infiles with Bowtie1 there are only two files to delete
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2082 my $deletion_successful = unlink "$temp_dir$C_to_T_infile_1","$temp_dir$G_to_A_infile_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2083 if ($deletion_successful == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2084 warn "\nSuccessfully deleted the temporary files $temp_dir$C_to_T_infile_1 and $temp_dir$G_to_A_infile_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
2085 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2086 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2087 warn "Could not delete temporary files properly: $!\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2090 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2091 }
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 ### printing a final report for the alignment procedure
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2094 warn "Final Alignment report\n",'='x22,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2095 print REPORT "Final Alignment report\n",'='x22,"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2096 # foreach my $index (0..$#fhs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2097 # print "$fhs[$index]->{name}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2098 # print "$fhs[$index]->{seen}\talignments on the correct strand 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
2099 # print "$fhs[$index]->{wrong_strand}\talignments were discarded (nonsensical alignments)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2100 # }
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 ### printing a final report for the methylation call procedure
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2103 warn "Sequence pairs analysed in total:\t$counting{sequences_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2104 print REPORT "Sequence pairs analysed in total:\t$counting{sequences_count}\n";
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 my $percent_alignable_sequence_pairs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2107 if ($counting{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
2108 $percent_alignable_sequence_pairs = 0;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2111 $percent_alignable_sequence_pairs = sprintf ("%.1f",$counting{unique_best_alignment_count}*100/$counting{sequences_count});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2112 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2113 print "Number of paired-end alignments with a unique best hit:\t$counting{unique_best_alignment_count}\nMapping efficiency:\t${percent_alignable_sequence_pairs}%\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2114 print REPORT "Number of paired-end alignments with a unique best hit:\t$counting{unique_best_alignment_count}\nMapping efficiency:\t${percent_alignable_sequence_pairs}% \n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2115
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2116 print "Sequence pairs with no alignments under any condition:\t$counting{no_single_alignment_found}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2117 print "Sequence pairs did not map uniquely:\t$counting{unsuitable_sequence_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2118 print "Sequence pairs which were discarded because genomic sequence could not be extracted:\t$counting{genomic_sequence_could_not_be_extracted_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
2119 print "Number of sequence pairs with unique best (first) alignment came from the bowtie output:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2120 print join ("\n","CT/GA/CT:\t$counting{CT_GA_CT_count}\t((converted) top strand)","GA/CT/CT:\t$counting{GA_CT_CT_count}\t(complementary to (converted) top strand)","GA/CT/GA:\t$counting{GA_CT_GA_count}\t(complementary to (converted) bottom strand)","CT/GA/GA:\t$counting{CT_GA_GA_count}\t((converted) bottom strand)"),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2121
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 print REPORT "Sequence pairs with no alignments under any condition:\t$counting{no_single_alignment_found}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2124 print REPORT "Sequence pairs did not map uniquely:\t$counting{unsuitable_sequence_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2125 print REPORT "Sequence pairs which were discarded because genomic sequence could not be extracted:\t$counting{genomic_sequence_could_not_be_extracted_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
2126 print REPORT "Number of sequence pairs with unique best (first) alignment came from the bowtie output:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2127 print REPORT join ("\n","CT/GA/CT:\t$counting{CT_GA_CT_count}\t((converted) top strand)","GA/CT/CT:\t$counting{GA_CT_CT_count}\t(complementary to (converted) top strand)","GA/CT/GA:\t$counting{GA_CT_GA_count}\t(complementary to (converted) bottom strand)","CT/GA/GA:\t$counting{CT_GA_GA_count}\t((converted) bottom strand)"),"\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2128 ### 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
2129
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2130 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2131 print "Number of alignments to (merely theoretical) complementary strands being rejected in total:\t$counting{alignments_rejected_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
2132 print REPORT "Number of alignments to (merely theoretical) complementary strands being rejected in total:\t$counting{alignments_rejected_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
2133 }
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 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
2136 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
2137
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2138 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
2139 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
2140 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
2141 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
2142 warn "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2143 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2144 warn "Total methylated C's in Unknown context:\t$counting{total_meC_unknown_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2145 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2146 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2147
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2148 warn "Total unmethylated C's 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
2149 warn "Total unmethylated C's 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
2150 warn "Total unmethylated C's in CHH context:\t$counting{total_unmethylated_CHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2151 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2152 warn "Total unmethylated C's in Unknown context:\t$counting{total_unmethylated_C_unknown_count}\n";
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 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2155
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2156 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
2157 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
2158 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
2159 print REPORT "Total methylated C's in CHH context:\t$counting{total_meCHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2160 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2161 print REPORT "Total methylated C's in Unknown context:\t$counting{total_meC_unknown_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
2162 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2163 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
2164
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2165 print REPORT "Total unmethylated C's 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
2166 print REPORT "Total unmethylated C's 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
2167 print REPORT "Total unmethylated C's in CHH context:\t$counting{total_unmethylated_CHH_count}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2168 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2169 print REPORT "Total unmethylated C's in Unknown context:\t$counting{total_unmethylated_C_unknown_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
2170 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2171 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
2172
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2173 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
2174 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
2175 $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
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 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
2179 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
2180 $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
2181 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2182
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2183 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
2184 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
2185 $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
2186 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2187
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2188 my $percent_meC_unknown;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2189 if (($counting{total_meC_unknown_count}+$counting{total_unmethylated_C_unknown_count}) > 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2190 $percent_meC_unknown = sprintf("%.1f",100*$counting{total_meC_unknown_count}/($counting{total_meC_unknown_count}+$counting{total_unmethylated_C_unknown_count}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2191 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2192
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2193
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2194 ### 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
2195 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
2196 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
2197 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
2198 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2199 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2200 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
2201 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
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 ### printing methylated C percentage in CHG context if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2205 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
2206 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
2207 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
2208 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2209 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2210 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
2211 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
2212 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2213
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2214 ### printing methylated C percentage in CHH context if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2215 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
2216 warn "C methylated in CHH context:\t${percent_meCHH}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2217 print REPORT "C methylated in CHH context:\t${percent_meCHH}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2218 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2219 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2220 warn "Can't determine percentage of methylated Cs in CHH 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
2221 print REPORT "Can't determine percentage of methylated Cs in CHH 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
2222 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2223
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2224 ### printing methylated C percentage (Unknown C context) if applicable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2225 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2226 if ($percent_meC_unknown){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2227 warn "C methylated in unknown context (CN or CHN):\t${percent_meC_unknown}%\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2228 print REPORT "C methylated in unknown context (CN or CHN):\t${percent_meC_unknown}%\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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2231 warn "Can't determine percentage of methylated Cs in unknown context (CN or CHN) 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
2232 print REPORT "Can't determine percentage of methylated Cs in unknown context (CN or CHN) 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
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 print 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
2236 warn "\n\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2240 sub process_single_end_fastA_file_for_methylation_call{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2241 my ($sequence_file,$C_to_T_infile,$G_to_A_infile,$pid) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2242 ### this is a FastA sequence file; we need the actual sequence to compare it against the genomic sequence in order to make a methylation call.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2243 ### Now reading in the sequence file sequence by sequence and see if the current sequence was mapped to one (or both) of the converted genomes in either
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2244 ### the C->T or G->A version
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2245
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2246 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2247 if ($sequence_file =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2248 open (IN,"gunzip -c $sequence_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
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 open (IN,$sequence_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
2252 }
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 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
2255
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2256 warn "\nReading in the sequence file $sequence_file\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2257 while (1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2258 # last if ($counting{sequences_count} > 100);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2259 my $identifier = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2260 my $sequence = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2261 last unless ($identifier and $sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2262
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2263 $identifier = fix_IDs($identifier); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2264
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2265 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2266
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2267 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2268 next unless ($count > $skip);
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 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2271 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2272 }
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 $counting{sequences_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2275 if ($counting{sequences_count}%1000000==0) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2276 warn "Processed $counting{sequences_count} sequences so far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2278 chomp $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2279 chomp $identifier;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2280
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2281 $identifier =~ s/^>//; # deletes the > at the beginning of FastA headers
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2282
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2283 my $return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2284 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2285 $return = check_bowtie_results_single_end_bowtie2 (uc$sequence,$identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2286 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2287 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2288 $return = check_bowtie_results_single_end(uc$sequence,$identifier); # default Bowtie 1
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 unless ($return){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2292 $return = 0;
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 # print the sequence to ambiguous.out if --ambiguous was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2296 if ($ambiguous and $return == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2297 print AMBIG ">$identifier\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2298 print AMBIG "$sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2299 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2300
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2301 # print the sequence to <unmapped.out> file if --un was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2302 elsif ($unmapped and $return == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2303 print UNMAPPED ">$identifier\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2304 print UNMAPPED "$sequence\n";
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 print "Processed $counting{sequences_count} sequences in total\n\n";
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 close OUT or warn "Failed to close filehandle OUT: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2310
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2311 print_final_analysis_report_single_end($C_to_T_infile,$G_to_A_infile,$pid);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2312
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2313 }
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 sub process_single_end_fastQ_file_for_methylation_call{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2316
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2317 my ($sequence_file,$C_to_T_infile,$G_to_A_infile,$pid) = @_;
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 ### this is the Illumina sequence file; we need the actual sequence to compare it against the genomic sequence in order to make a methylation call.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2320 ### Now reading in the sequence file sequence by sequence and see if the current sequence was mapped to one (or both) of the converted genomes in either
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2321 ### the C->T or G->A version
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 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2324 if ($sequence_file =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2325 open (IN,"gunzip -c $sequence_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
2326 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2327 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2328 open (IN,$sequence_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
2329 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2330
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2331 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
2332
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2333 warn "\nReading in the sequence file $sequence_file\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2334 while (1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2335 my $identifier = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2336 my $sequence = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2337 my $identifier_2 = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2338 my $quality_value = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2339 last unless ($identifier and $sequence and $identifier_2 and $quality_value);
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 $identifier = fix_IDs($identifier); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2342
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2343 ++$count;
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 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2346 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2347 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2348 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2349 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2350 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2351
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2352 $counting{sequences_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2353
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2354 if ($counting{sequences_count}%1000000==0) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2355 warn "Processed $counting{sequences_count} sequences so far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2356 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2357 chomp $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2358 chomp $identifier;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2359 chomp $quality_value;
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 $identifier =~ s/^\@//; # deletes the @ at the beginning of Illumin FastQ headers
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2362
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2363 my $return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2364 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2365 $return = check_bowtie_results_single_end_bowtie2 (uc$sequence,$identifier,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2366 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2367 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2368 $return = check_bowtie_results_single_end(uc$sequence,$identifier,$quality_value); # default Bowtie 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2369 }
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 unless ($return){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2372 $return = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2373 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2374
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2375 # print the sequence to ambiguous.out if --ambiguous was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2376 if ($ambiguous and $return == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2377 print AMBIG "\@$identifier\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2378 print AMBIG "$sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2379 print AMBIG $identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2380 print AMBIG "$quality_value\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2383 # print the sequence to <unmapped.out> file if --un was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2384 elsif ($unmapped and $return == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2385 print UNMAPPED "\@$identifier\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2386 print UNMAPPED "$sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2387 print UNMAPPED $identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2388 print UNMAPPED "$quality_value\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2389 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2390 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2391 print "Processed $counting{sequences_count} sequences in total\n\n";
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 close OUT or warn "Failed to close filehandle OUT: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2394
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2395 print_final_analysis_report_single_end($C_to_T_infile,$G_to_A_infile,$pid);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2396 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2397 close AMBIBAM or warn "Had trouble closing filehandle AMBIBAM: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2398 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2399 }
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 sub process_fastA_files_for_paired_end_methylation_calls{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2402 my ($sequence_file_1,$sequence_file_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2403 ### Processing the two FastA sequence files; we need the actual sequences of both reads to compare them against the genomic sequence in order to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2404 ### make a methylation call. The sequence idetifier per definition needs to be the same for a sequence pair used for paired-end mapping.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2405 ### Now reading in the sequence files sequence by sequence and see if the current sequences produced an alignment to one (or both) of the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2406 ### converted genomes (either the C->T or G->A version)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2407
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2408 ### gzipped version of the infiles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2409 if ($sequence_file_1 =~ /\.gz$/ and $sequence_file_2 =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2410 open (IN1,"gunzip -c $sequence_file_1 |") or die "Failed to open gunzip -c pipe to $sequence_file_1 $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2411 open (IN2,"gunzip -c $sequence_file_2 |") or die "Failed to open gunzip -c pipe to $sequence_file_2 $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2412 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2413 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2414 open (IN1,$sequence_file_1) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2415 open (IN2,$sequence_file_2) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2416 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2417
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2418 warn "\nReading in the sequence files $sequence_file_1 and $sequence_file_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2419 ### Both files are required to have the exact same number of sequences, therefore we can process the sequences jointly one by one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2420
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2421 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
2422
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2423 while (1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2424 # reading from the first input file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2425 my $identifier_1 = <IN1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2426 my $sequence_1 = <IN1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2427 # reading from the second input file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2428 my $identifier_2 = <IN2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2429 my $sequence_2 = <IN2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2430 last unless ($identifier_1 and $sequence_1 and $identifier_2 and $sequence_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2431
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2432 $identifier_1 = fix_IDs($identifier_1); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2433 $identifier_2 = fix_IDs($identifier_2);
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 ++$count;
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 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2438 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2439 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2440 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2441 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2442 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2443
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2444 $counting{sequences_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2445 if ($counting{sequences_count}%1000000==0) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2446 warn "Processed $counting{sequences_count} sequence pairs so far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2447 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2448 my $orig_identifier_1 = $identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2449 my $orig_identifier_2 = $identifier_2;
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 chomp $sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2452 chomp $identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2453 chomp $sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2454 chomp $identifier_2;
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 $identifier_1 =~ s/^>//; # deletes the > at the beginning of FastA headers
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2457
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2458 my $return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2459 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2460 $return = check_bowtie_results_paired_ends_bowtie2 (uc$sequence_1,uc$sequence_2,$identifier_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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2463 $return = check_bowtie_results_paired_ends (uc$sequence_1,uc$sequence_2,$identifier_1);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2466 unless ($return){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2467 $return = 0;
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 # print the sequences to ambiguous_1 and _2 if --ambiguous was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2471 if ($ambiguous and $return == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2472 print AMBIG_1 $orig_identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2473 print AMBIG_1 "$sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2474 print AMBIG_2 $orig_identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2475 print AMBIG_2 "$sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2476 }
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 # print the sequences to unmapped_1.out and unmapped_2.out if --un was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2479 elsif ($unmapped and $return == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2480 print UNMAPPED_1 $orig_identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2481 print UNMAPPED_1 "$sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2482 print UNMAPPED_2 $orig_identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2483 print UNMAPPED_2 "$sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2484 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2487 warn "Processed $counting{sequences_count} sequences in total\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2488
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2489 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
2490
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2491 print_final_analysis_report_paired_ends($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid);
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 sub process_fastQ_files_for_paired_end_methylation_calls{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2496 my ($sequence_file_1,$sequence_file_2,$C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2497 ### Processing the two Illumina sequence files; we need the actual sequence of both reads to compare them against the genomic sequence in order to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2498 ### make a methylation call. The sequence identifier per definition needs to be same for a sequence pair used for 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
2499 ### Now reading in the sequence files sequence by sequence and see if the current sequences produced a paired-end alignment to one (or both)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2500 ### of the converted genomes (either C->T or G->A version)
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 ### gzipped version of the infiles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2503 if ($sequence_file_1 =~ /\.gz$/ and $sequence_file_2 =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2504 open (IN1,"gunzip -c $sequence_file_1 |") or die "Failed to open gunzip -c pipe to $sequence_file_1 $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2505 open (IN2,"gunzip -c $sequence_file_2 |") or die "Failed to open gunzip -c pipe to $sequence_file_2 $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2506 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2507 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2508 open (IN1,$sequence_file_1) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2509 open (IN2,$sequence_file_2) or die $!;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2510 }
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 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
2513
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2514 warn "\nReading in the sequence files $sequence_file_1 and $sequence_file_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2515 ### Both files are required to have the exact same number of sequences, therefore we can process the sequences jointly one by one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2516 while (1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2517 # reading from the first input file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2518 my $identifier_1 = <IN1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2519 my $sequence_1 = <IN1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2520 my $ident_1 = <IN1>; # not needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2521 my $quality_value_1 = <IN1>; # not needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2522 # reading from the second input file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2523 my $identifier_2 = <IN2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2524 my $sequence_2 = <IN2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2525 my $ident_2 = <IN2>; # not needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2526 my $quality_value_2 = <IN2>; # not needed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2527 last unless ($identifier_1 and $sequence_1 and $quality_value_1 and $identifier_2 and $sequence_2 and $quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2528 $identifier_1 = fix_IDs($identifier_1); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2529 $identifier_2 = fix_IDs($identifier_2);
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 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2532
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2533 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2534 next unless ($count > $skip);
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 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2537 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2538 }
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 $counting{sequences_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2541 if ($counting{sequences_count}%1000000==0) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2542 warn "Processed $counting{sequences_count} sequence pairs so far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2543 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2544
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2545 my $orig_identifier_1 = $identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2546 my $orig_identifier_2 = $identifier_2;
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 chomp $sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2549 chomp $identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2550 chomp $sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2551 chomp $identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2552 chomp $quality_value_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2553 chomp $quality_value_2;
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 $identifier_1 =~ s/^\@//; # deletes the @ at the beginning of the FastQ ID
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2556
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2557 my $return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2558 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2559 $return = check_bowtie_results_paired_ends_bowtie2 (uc$sequence_1,uc$sequence_2,$identifier_1,$quality_value_1,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2560 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2561 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2562 $return = check_bowtie_results_paired_ends (uc$sequence_1,uc$sequence_2,$identifier_1,$quality_value_1,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2563 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2564
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2565 unless ($return){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2566 $return = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2567 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2568
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2569 # print the sequences to ambiguous_1 and _2 if --ambiguous was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2570 if ($ambiguous and $return == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2571 # seq_1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2572 print AMBIG_1 $orig_identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2573 print AMBIG_1 "$sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2574 print AMBIG_1 $ident_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2575 print AMBIG_1 "$quality_value_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2576 # seq_2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2577 print AMBIG_2 $orig_identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2578 print AMBIG_2 "$sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2579 print AMBIG_2 $ident_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2580 print AMBIG_2 "$quality_value_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2581 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2582
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2583 # print the sequences to unmapped_1.out and unmapped_2.out if --un was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2584 elsif ($unmapped and $return == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2585 # seq_1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2586 print UNMAPPED_1 $orig_identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2587 print UNMAPPED_1 "$sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2588 print UNMAPPED_1 $ident_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2589 print UNMAPPED_1 "$quality_value_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2590 # seq_2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2591 print UNMAPPED_2 $orig_identifier_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2592 print UNMAPPED_2 "$sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2593 print UNMAPPED_2 $ident_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2594 print UNMAPPED_2 "$quality_value_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2595 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2596 }
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 warn "Processed $counting{sequences_count} sequences in total\n\n";
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 close OUT or warn "Failed to close filehandle OUT: $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2601 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2602 close AMBIBAM or warn "Had trouble closing filehandle AMBIBAM: $!\n\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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2605 print_final_analysis_report_paired_ends($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2,$pid);
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2608
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2609 sub check_bowtie_results_single_end{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2610 my ($sequence,$identifier,$quality_value) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2611
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2612 unless ($quality_value){ # FastA sequences get assigned a quality value of Phred 40 throughout
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2613 $quality_value = 'I'x(length$sequence);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2616 my %mismatches = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2617 ### reading from the bowtie output files to see if this sequence aligned to a bisulfite converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2618 foreach my $index (0..$#fhs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2619
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2620 ### skipping this index if the last alignment has been set to undefined already (i.e. end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2621 next unless ($fhs[$index]->{last_line} and defined $fhs[$index]->{last_seq_id});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2622 ### if the sequence we are currently looking at produced an alignment we are doing various things with it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2623 if ($fhs[$index]->{last_seq_id} eq $identifier) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2624 ###############################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2625 ### STEP I Now processing the alignment stored in last_line ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2626 ###############################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2627 my $valid_alignment_found_1 = decide_whether_single_end_alignment_is_valid($index,$identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2628 ### sequences can fail at this point if there was only 1 seq in the wrong orientation, or if there were 2 seqs, both in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2629 ### we only continue to extract useful information about this alignment if 1 was returned
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2630 if ($valid_alignment_found_1 == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2631 ### Bowtie outputs which made it this far are in the correct orientation, so we can continue to analyse the alignment itself
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2632 ### need to extract the chromosome number from the bowtie output (which is either XY_cf (complete forward) or XY_cr (complete reverse)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2633 my ($id,$strand,$mapped_chromosome,$position,$bowtie_sequence,$mismatch_info) = (split (/\t/,$fhs[$index]->{last_line},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2634
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2635 unless($mismatch_info){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2636 $mismatch_info = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2637 }
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 chomp $mismatch_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2640 my $chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2641 if ($mapped_chromosome =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2642 $chromosome = $mapped_chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2643 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2644 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2645 die "Chromosome number extraction failed for $mapped_chromosome\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 ### Now extracting the number of mismatches to the converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2648 my $number_of_mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2649 if ($mismatch_info eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2650 $number_of_mismatches = 0;
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 elsif ($mismatch_info =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2653 my @mismatches = split (/,/,$mismatch_info);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2654 $number_of_mismatches = scalar @mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2655 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2656 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2657 die "Something weird is going on with the mismatch field:\t>>> $mismatch_info <<<\n";
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 ### creating a composite location variable from $chromosome and $position and storing the alignment information in a temporary hash table
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2660 my $alignment_location = join (":",$chromosome,$position);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2661 ### If a sequence aligns to exactly the same location twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2662 ### strand) were methylated and therefore protected. It is not needed to overwrite the same positional entry with a second entry for the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2663 ### location (the genomic sequence extraction and methylation would not be affected by this, only the thing which would change is the index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2664 ### number for the found alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2665 unless (exists $mismatches{$number_of_mismatches}->{$alignment_location}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2666 $mismatches{$number_of_mismatches}->{$alignment_location}->{seq_id}=$id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2667 $mismatches{$number_of_mismatches}->{$alignment_location}->{bowtie_sequence}=$bowtie_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2668 $mismatches{$number_of_mismatches}->{$alignment_location}->{index}=$index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2669 $mismatches{$number_of_mismatches}->{$alignment_location}->{chromosome}=$chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2670 $mismatches{$number_of_mismatches}->{$alignment_location}->{position}=$position;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2671 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2672 $number_of_mismatches = undef;
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 ### STEP II Now reading in the next line from the bowtie filehandle. The next alignment can either be a second alignment of the same sequence or a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2675 ### a new sequence. In either case we will store the next line in @fhs ->{last_line}. In case the alignment is already the next entry, a 0 will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2676 ### be returned as $valid_alignment_found and it will then be processed in the next round only.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2677 ##################################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2678 my $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2679 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2680 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2681 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2682 $fhs[$index]->{last_line} = $newline;
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2685 # assigning undef to last_seq_id and last_line and jumping to the next index (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2686 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2687 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2688 next;
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 my $valid_alignment_found_2 = decide_whether_single_end_alignment_is_valid($index,$identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2691 ### we only continue to extract useful information about this second alignment if 1 was returned
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2692 if ($valid_alignment_found_2 == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2693 ### If the second Bowtie output made it this far it is in the correct orientation, so we can continue to analyse the alignment itself
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2694 ### need to extract the chromosome number from the bowtie output (which is either XY_cf (complete forward) or XY_cr (complete reverse)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2695 my ($id,$strand,$mapped_chromosome,$position,$bowtie_sequence,$mismatch_info) = (split (/\t/,$fhs[$index]->{last_line},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2696 unless($mismatch_info){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2697 $mismatch_info = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2698 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2699 chomp $mismatch_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2700
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2701 my $chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2702 if ($mapped_chromosome =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2703 $chromosome = $mapped_chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2704 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2705 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2706 die "Chromosome number extraction failed for $mapped_chromosome\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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2709 ### Now extracting the number of mismatches to the converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2710 my $number_of_mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2711 if ($mismatch_info eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2712 $number_of_mismatches = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2713 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2714 elsif ($mismatch_info =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2715 my @mismatches = split (/,/,$mismatch_info);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2716 $number_of_mismatches = scalar @mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2717 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2718 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2719 die "Something weird is going on with the mismatch field\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 ### creating a composite location variable from $chromosome and $position and storing the alignment information in a temporary hash table
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2722 ### extracting the chromosome number from the bowtie output (see above)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2723 my $alignment_location = join (":",$chromosome,$position);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2724 ### In the special case that two differently converted sequences align against differently converted genomes, but to the same position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2725 ### with the same number of mismatches (or perfect matches), the chromosome, position and number of mismatches are the same. In this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2726 ### case we are not writing the same entry out a second time.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2727 unless (exists $mismatches{$number_of_mismatches}->{$alignment_location}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2728 $mismatches{$number_of_mismatches}->{$alignment_location}->{seq_id}=$id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2729 $mismatches{$number_of_mismatches}->{$alignment_location}->{bowtie_sequence}=$bowtie_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2730 $mismatches{$number_of_mismatches}->{$alignment_location}->{index}=$index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2731 $mismatches{$number_of_mismatches}->{$alignment_location}->{chromosome}=$chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2732 $mismatches{$number_of_mismatches}->{$alignment_location}->{position}=$position;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2733 }
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 #### STEP III Now reading in one more line which has to be the next alignment to be analysed. Adding it to @fhs ->{last_line} ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2736 ####################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2737 $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2738 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2739 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2740 die "The same seq ID occurred more than twice in a row\n" if ($seq_id eq $identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2741 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2742 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2743 next;
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2746 # assigning undef to last_seq_id and last_line and jumping to the next index (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2747 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2748 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2749 next;
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 ### still within the 2nd sequence in correct orientation found
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 ### still withing the 1st sequence in correct orientation found
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 ### still within the if (last_seq_id eq identifier) condition
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 ### still within foreach index loop
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2758 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2759 ### if there was not a single alignment found for a certain sequence we will continue with the next sequence in the sequence file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2760 unless(%mismatches){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2761 $counting{no_single_alignment_found}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2762 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2763 return 1; ### We will print this sequence out as unmapped sequence if --un unmapped.out has been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2764 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2765 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2766 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2767 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2768 }
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 ### We are now looking if there is a unique best alignment for a certain sequence. This means we are sorting in ascending order and look at the ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2772 ### sequence with the lowest amount of mismatches. If there is only one single best position we are going to store the alignment information in the ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2773 ### meth_call variables, if there are multiple hits with the same amount of (lowest) mismatches we are discarding the sequence altogether ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2774 #######################################################################################################################################################
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 ### Going to use the variable $sequence_fails as a memory if a sequence could not be aligned uniquely (set to 1 then)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2777 my $sequence_fails = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2778 ### Declaring an empty hash reference which will store all information we need for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2779 my $methylation_call_params; # hash reference!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2780 ### sorting in ascending order
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2781 foreach my $mismatch_number (sort {$a<=>$b} keys %mismatches){
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 ### if there is only 1 entry in the hash with the lowest number of mismatches we accept it as the best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2784 if (scalar keys %{$mismatches{$mismatch_number}} == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2785 for my $unique_best_alignment (keys %{$mismatches{$mismatch_number}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2786 $methylation_call_params->{$identifier}->{bowtie_sequence} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{bowtie_sequence};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2787 $methylation_call_params->{$identifier}->{chromosome} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2788 $methylation_call_params->{$identifier}->{position} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2789 $methylation_call_params->{$identifier}->{index} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2790 $methylation_call_params->{$identifier}->{number_of_mismatches} = $mismatch_number;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2791 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2792 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2793 elsif (scalar keys %{$mismatches{$mismatch_number}} == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2794 ### If there are 3 sequences with the same number of lowest mismatches we can discriminate 2 cases: (i) all 3 alignments are unique best hits and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2795 ### come from different alignments processes (== indices) or (ii) one sequence alignment (== index) will give a unique best alignment, whereas a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2796 ### second one will produce 2 (or potentially many) alignments for the same sequence but in a different conversion state or against a different genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2797 ### version (or both). This becomes especially relevant for highly converted sequences in which all Cs have been converted to Ts in the bisulfite
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2798 ### reaction. E.g.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2799 ### CAGTCACGCGCGCGCG will become
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2800 ### TAGTTATGTGTGTGTG in the CT transformed version, which will ideally still give the correct alignment in the CT->CT alignment condition.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2801 ### If the same read will then become G->A transformed as well however, the resulting sequence will look differently and potentially behave
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2802 ### differently in a GA->GA alignment and this depends on the methylation state of the original sequence!:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2803 ### G->A conversion:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2804 ### highly methylated: CAATCACACACACACA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2805 ### highly converted : TAATTATATATATATA <== this sequence has a reduced complexity (only 2 bases left and not 3), and it is more likely to produce
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2806 ### an alignment with a low complexity genomic region than the one above. This would normally lead to the entire sequence being kicked out as the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2807 ### there will be 3 alignments with the same number of lowest mismatches!! This in turn means that highly methylated and thereby not converted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2808 ### sequences are more likely to pass the alignment step, thereby creating a bias for methylated reads compared to their non-methylated counterparts.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2809 ### We do not want any bias, whatsover. Therefore if we have 1 sequence producing a unique best alignment and the second and third conditions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2810 ### producing alignments only after performing an additional (theoretical) conversion we want to keep the best alignment with the lowest number of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2811 ### additional transliterations performed. Thus we want to have a look at the level of complexity of the sequences producing the alignment.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2812 ### In the above example the number of transliterations required to transform the actual sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2813 ### to the C->T version would be TAGTTATGTGTGTGTG -> TAGTTATGTGTGTGTG = 0; (assuming this gives the correct alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2814 ### in the G->A case it would be TAGTTATGTGTGTGTG -> TAATTATATATATATA = 6; (assuming this gives multiple wrong alignments)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2815 ### if the sequence giving a unique best alignment required a lower number of transliterations than the second best sequence yielding alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2816 ### while requiring a much higher number of transliterations, we are going to accept the unique best alignment with the lowest number of performed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2817 ### transliterations. As a threshold which does scale we will start with the number of tranliterations of the lowest best match x 2 must still be
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2818 ### smaller than the number of tranliterations of the second best sequence. Everything will be flagged with $sequence_fails = 1 and discarded.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2819 my @three_candidate_seqs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2820 foreach my $composite_location (keys (%{$mismatches{$mismatch_number}}) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2821 my $transliterations_performed;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2822 if ($mismatches{$mismatch_number}->{$composite_location}->{index} == 0 or $mismatches{$mismatch_number}->{$composite_location}->{index} == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2823 $transliterations_performed = determine_number_of_transliterations_performed($sequence,'CT');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2824 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2825 elsif ($mismatches{$mismatch_number}->{$composite_location}->{index} == 2 or $mismatches{$mismatch_number}->{$composite_location}->{index} == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2826 $transliterations_performed = determine_number_of_transliterations_performed($sequence,'GA');
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2829 die "unexpected index number range $!\n";
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 push @three_candidate_seqs,{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2832 index =>$mismatches{$mismatch_number}->{$composite_location}->{index},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2833 bowtie_sequence => $mismatches{$mismatch_number}->{$composite_location}->{bowtie_sequence},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2834 mismatch_number => $mismatch_number,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2835 chromosome => $mismatches{$mismatch_number}->{$composite_location}->{chromosome},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2836 position => $mismatches{$mismatch_number}->{$composite_location}->{position},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2837 seq_id => $mismatches{$mismatch_number}->{$composite_location}->{seq_id},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2838 transliterations_performed => $transliterations_performed,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2839 };
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 ### sorting in ascending order for the lowest number of transliterations performed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2842 @three_candidate_seqs = sort {$a->{transliterations_performed} <=> $b->{transliterations_performed}} @three_candidate_seqs;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2843 my $first_array_element = $three_candidate_seqs[0]->{transliterations_performed};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2844 my $second_array_element = $three_candidate_seqs[1]->{transliterations_performed};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2845 my $third_array_element = $three_candidate_seqs[2]->{transliterations_performed};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2846 # print "$first_array_element\t$second_array_element\t$third_array_element\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2847 if (($first_array_element*2) < $second_array_element){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2848 $counting{low_complexity_alignments_overruled_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2849 ### taking the index with the unique best hit and over ruling low complexity alignments with 2 hits
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2850 $methylation_call_params->{$identifier}->{bowtie_sequence} = $three_candidate_seqs[0]->{bowtie_sequence};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2851 $methylation_call_params->{$identifier}->{chromosome} = $three_candidate_seqs[0]->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2852 $methylation_call_params->{$identifier}->{position} = $three_candidate_seqs[0]->{position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2853 $methylation_call_params->{$identifier}->{index} = $three_candidate_seqs[0]->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2854 $methylation_call_params->{$identifier}->{number_of_mismatches} = $mismatch_number;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2855 # print "Overruled low complexity alignments! Using $first_array_element and disregarding $second_array_element and $third_array_element\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2858 $sequence_fails = 1;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2862 $sequence_fails = 1;
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 ### after processing the alignment with the lowest number of mismatches we exit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2865 last;
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 ### skipping the sequence completely if there were multiple alignments with the same amount of lowest mismatches found at different positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2868 if ($sequence_fails == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2869 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2870 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2871 return 2; # => exits to next sequence, and prints it out to multiple_alignments.out if --ambiguous has been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2872 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2873 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2874 return 1; # => exits to next sequence, and prints it out to unmapped.out if --un has been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2875 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2876 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2877 return 0; # => exits to next sequence (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2878 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2879 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2880
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2881 ### --DIRECTIONAL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2882 ### If the option --directional has been specified the user wants to consider only alignments to the original top strand or the original bottom strand. We will therefore
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2883 ### discard all alignments to strands complementary to the original strands, as they should not exist in reality due to the library preparation protocol
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2884 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2885 if ( ($methylation_call_params->{$identifier}->{index} == 2) or ($methylation_call_params->{$identifier}->{index} == 3) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2886 # warn "Alignment rejected! (index was: $methylation_call_params->{$identifier}->{index})\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2887 $counting{alignments_rejected_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2888 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2889 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2890 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2891
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2892 ### If the sequence has not been rejected so far it will have a unique best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2893 $counting{unique_best_alignment_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2894 extract_corresponding_genomic_sequence_single_end($identifier,$methylation_call_params);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2895
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2896 ### check test to see if the genomic sequence we extracted has the same length as the observed sequence+2, and only then we perform the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2897 if (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence}) != length($sequence)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2898 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{position}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2899 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2900 return 0;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2903 ### otherwise we are set to perform the actual methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2904 $methylation_call_params->{$identifier}->{methylation_call} = methylation_call($identifier,$sequence,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence},$methylation_call_params->{$identifier}->{read_conversion});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2905
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2906 print_bisulfite_mapping_result_single_end($identifier,$sequence,$methylation_call_params,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2907 return 0; ## otherwise 1 will be returned by default, which would print the sequence to unmapped.out
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2908 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2909
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2910 sub check_bowtie_results_single_end_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2911 my ($sequence,$identifier,$quality_value) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2912
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2913 unless ($quality_value){ # FastA sequences get assigned a quality value of Phred 40 throughout
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2914 $quality_value = 'I'x(length$sequence);
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 # as of version Bowtie 2 2.0.0 beta7, when input reads are unpaired, Bowtie 2 no longer removes the trailing /1 or /2 from the read name.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2918 # $identifier =~ s/\/[1234567890]+$//; # some sequencers don't just have /1 or /2 at the end of read IDs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2919 # print "sequence $sequence\nid $identifier\nquality: '$quality_value'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2920
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2921 my $alignment_ambiguous = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2922 my $first_ambig_alignment; # storing the first ambiguous alignment so it can be written out in case '--ambig_bam' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2923 my $best_AS_so_far; ## we need to keep a memory of the best alignment score so far
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2924 my $amb_same_thread = 0; ## if a reads primary and secondary alignments have the same alignment score we set this to true.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2925
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2926 my %alignments = ();
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 ### reading from the Bowtie 2 output filehandles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2929 foreach my $index (0..$#fhs){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2930 # print "Index: $index\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2931 # print "$fhs[$index]->{last_line}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2932 # print "$fhs[$index]->{last_seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2933 # sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2934 ### skipping this index if the last alignment has been set to undefined already (i.e. end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2935 next unless ($fhs[$index]->{last_line} and defined $fhs[$index]->{last_seq_id});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2936
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2937 ### if the sequence we are currently looking at produced an alignment we are doing various things with it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2938 # print "last seq id: $fhs[$index]->{last_seq_id} and identifier: $identifier\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2939
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2940 if ($fhs[$index]->{last_seq_id} eq $identifier) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2941 # SAM format specifications for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2942 # (1) Name of read that aligned
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2943 # (2) Sum of all applicable flags. Flags relevant to Bowtie are:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2944 # 1 The read is one of a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2945 # 2 The alignment is one end of a proper paired-end alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2946 # 4 The read has no reported alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2947 # 8 The read is one of a pair and has no reported alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2948 # 16 The alignment is to the reverse reference strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2949 # 32 The other mate in the paired-end alignment is aligned to the reverse reference strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2950 # 64 The read is mate 1 in a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2951 # 128 The read is mate 2 in a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2952 # 256 The read has multiple mapping states
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2953 # (3) Name of reference sequence where alignment occurs (unmapped reads have a *)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2954 # (4) 1-based offset into the forward reference strand where leftmost character of the alignment occurs (0 for unmapped reads)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2955 # (5) Mapping quality (255 means MAPQ is not available)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2956 # (6) CIGAR string representation of alignment (* if unavailable)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2957 # (7) Name of reference sequence where mate's alignment occurs. Set to = if the mate's reference sequence is the same as this alignment's, or * if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2958 # (8) 1-based offset into the forward reference strand where leftmost character of the mate's alignment occurs. Offset is 0 if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2959 # (9) Inferred fragment size. Size is negative if the mate's alignment occurs upstream of this alignment. Size is 0 if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2960 # (10) Read sequence (reverse-complemented if aligned 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
2961 # (11) ASCII-encoded read qualities (reverse-complemented if the read aligned to the reverse strand). The encoded quality values are on the Phred quality scale and the encoding is ASCII-offset by 33 (ASCII char !), similarly to a FASTQ file.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2962 # (12) Optional fields. Fields are tab-separated. bowtie2 outputs zero or more of these optional fields for each alignment, depending on the type of the alignment:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2963 # AS:i:<N> Alignment score. Can be negative. Can be greater than 0 in --local mode (but not in --end-to-end mode). Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2964 # XS:i:<N> Alignment score for second-best alignment. Can be negative. Can be greater than 0 in --local mode (but not in --end-to-end mode). Only present if the SAM record is for an aligned read and more than one alignment was found for the read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2965 # YS:i:<N> Alignment score for opposite mate in the paired-end alignment. Only present if the SAM record is for a read that aligned as part of a paired-end alignment.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2966 # XN:i:<N> The number of ambiguous bases in the reference covering this alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2967 # XM:i:<N> The number of mismatches in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2968 # XO:i:<N> The number of gap opens, for both read and reference gaps, in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2969 # XG:i:<N> The number of gap extensions, for both read and reference gaps, in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2970 # NM:i:<N> The edit distance; that is, the minimal number of one-nucleotide edits (substitutions, insertions and deletions) needed to transform the read string into the reference string. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2971 # YF:Z:<N> String indicating reason why the read was filtered out. See also: Filtering. Only appears for reads that were filtered out.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2972 # MD:Z:<S> A string representation of the mismatched reference bases in the alignment. See SAM format specification for details. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2973
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2974 my ($id,$flag,$mapped_chromosome,$position,$mapping_quality,$cigar,$bowtie_sequence,$qual) = (split (/\t/,$fhs[$index]->{last_line}))[0,1,2,3,4,5,9,10];
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 ### If a sequence has no reported alignments there will be a single output line with a bit-wise flag value of 4. We can store the next alignment and move on to the next Bowtie 2 instance
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2977 if ($flag == 4){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2978 ## reading in the next alignment, which must be the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2979 my $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2980 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2981 chomp $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2982 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2983 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2984 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2985 if ($seq_id eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2986 die "Sequence with ID $identifier did not produce any alignment, but next seq-ID was also $fhs[$index]->{last_seq_id}!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2987 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2988 next; # next instance
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2991 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2992 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2993 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2994 next;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2997
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
2998 # if there are one or more proper alignments we can extract 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
2999 my $chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3000 if ($mapped_chromosome =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3001 $chromosome = $mapped_chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3002 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3003 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3004 die "Chromosome number extraction failed for $mapped_chromosome\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3007 ### We will use the optional field to determine the best alignment. Later on we extract the number of mismatches and/or indels from the CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3008 my ($alignment_score,$second_best,$MD_tag);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3009 my @fields = split (/\t/,$fhs[$index]->{last_line});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3010
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3011 foreach (11..$#fields){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3012 if ($fields[$_] =~ /AS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3013 $alignment_score = $1;
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 elsif ($fields[$_] =~ /XS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3016 $second_best = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3017 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3018 elsif ($fields[$_] =~ /MD:Z:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3019 $MD_tag = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3020 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3021 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3022
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3023 my $overwrite = 0; # If we get 2 alignments to the very same position, e.g. to OT with and AS of -156 and to CTOB with and AS of 0 we need the latter to trump the former, else
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3024 # the read will be assigned to the wrong strand which may result in incorrect methylation calls.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3025 # this was brought to our attention by Sylvain Foret (ANU Canberra), 13 April 2016
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 if (!defined $best_AS_so_far){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3028 $best_AS_so_far = $alignment_score;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3029 $overwrite++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3030 # warn "First alignment score, setting \$best_AS_so_far to $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3031 if ($ambig_bam){ # also setting the first_ambig_alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3032 $first_ambig_alignment = $fhs[$index]->{last_line};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3033 $first_ambig_alignment =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3034 # warn "$first_ambig_alignment\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
3035 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3036 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3037 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3038 if ($alignment_score >= $best_AS_so_far){ # AS are generally negative with a maximum of 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3039 # 19 07 2016: changed this to >= so that equally good alignments are also added. Ambiguous alignments from different threads will be identified later on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3040 $best_AS_so_far = $alignment_score;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3041 $overwrite++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3042 # warn "Found better or equal alignment score ($alignment_score), setting \$best_AS_so_far to $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3043
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3044 # 22 07 2016: resetting the ambiguous score within same thread only if the current alignment is really better than the previous one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3045 if ($alignment_score > $best_AS_so_far){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3046 # warn "Resetting amb within thread value to 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3047 $amb_same_thread = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3048
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3049 if ($ambig_bam){ # also setting a new first_ambig_alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3050 $first_ambig_alignment = $fhs[$index]->{last_line};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3051 $first_ambig_alignment =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3052 # warn "$first_ambig_alignment\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
3053 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3054 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3055 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3056 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3057 # warn "Current alignment (AS $alignment_score) isn't better than the best so far ($best_AS_so_far). Not changing anything\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3058 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3059 }
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 # warn "First best alignment_score is: '$alignment_score'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3062 # warn "MD tag is: '$MD_tag'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3063 die "Failed to extract alignment score ($alignment_score) and MD tag ($MD_tag) from line $fhs[$index]->{last_line}!\n" unless (defined $alignment_score and defined $MD_tag);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3064
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3065 if (defined $second_best){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3066 # warn "second best alignment_score is: '$second_best'\n\n";
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 # If the first alignment score is the same as the alignment score of the second best hit we keep a memory of this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3069 if ($alignment_score == $second_best){
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 # checking to see if this read produced the best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3072 if ($alignment_score == $best_AS_so_far){ # yes this read is the best one so far, however it is ambiguous
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3073 # warn "Read is ambiguous within the same thread, or otherwise as good as the best one so far. Setting \$amb_same_thread to 1 for currently best AS: $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3074 $amb_same_thread = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3075 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3076 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3077 # warn "This read has a worse alignments score than the best alignment so far and will be ignored even though it is ambiguous in itself\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3078 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3079
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3080 ### if there is a better alignment later on -> fine. If not, the read will get booted altogether
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 ## need to read and discard all additional ambiguous reads until we reach the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3083 until ($fhs[$index]->{last_seq_id} ne $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3084 my $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3085 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3086 chomp $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3087 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3088 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3089 $fhs[$index]->{last_line} = $newline;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3092 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3093 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3094 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3095 last; # break free in case we have reached the end of the alignment output
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 # warn "Index: $index\tThe current Seq-ID is $identifier, skipped all ambiguous sequences until the next ID which is: $fhs[$index]->{last_seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3100 else{ # the next best alignment has a lower alignment score than the current read, so we can safely store the current alignment
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 my $alignment_location = join (":",$chromosome,$position);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3103
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3104 ### If a sequence aligns to exactly the same location with a perfect match twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3105 ### strand) were methylated and therefore protected. Alternatively it will align better in one condition than in the other. In any case, it is not needed to overwrite
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3106 ### the same positional entry with a second entry for the same location, as the genomic sequence extraction and methylation call would not be affected by this. The only
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3107 ### thing which would change is the index number for the found alignment). We will continue to assign these alignments to the first indexes 0 and 1, i.e. OT and OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3108
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3109 if ($overwrite){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3110 $alignments{$alignment_location}->{seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3111 $alignments{$alignment_location}->{alignment_score} = $alignment_score;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3112 $alignments{$alignment_location}->{alignment_score_second_best} = $second_best;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3113 $alignments{$alignment_location}->{bowtie_sequence} = $bowtie_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3114 $alignments{$alignment_location}->{index} = $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3115 $alignments{$alignment_location}->{chromosome} = $chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3116 $alignments{$alignment_location}->{position} = $position;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3117 $alignments{$alignment_location}->{CIGAR} = $cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3118 $alignments{$alignment_location}->{MD_tag} = $MD_tag;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3121 ### now reading and discarding all (inferior) alignments of this sequencing read until we hit the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3122 until ($fhs[$index]->{last_seq_id} ne $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3123 my $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3124 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3125 chomp $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3126 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3127 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3128 $fhs[$index]->{last_line} = $newline;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3131 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3132 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3133 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3134 last; # break free in case we have reached the end of the alignment output
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3137 # warn "Index: $index\tThe current Seq-ID is $identifier, skipped all ambiguous sequences until the next ID which is: $fhs[$index]->{last_seq_id}\n";
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 else{ # there is no second best hit, so we can just store this one and read in the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3141
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3142 my $alignment_location = join (":",$chromosome,$position);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3143 # warn "There is no second best hit. Overwrite status: $overwrite\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3144 ### If a sequence aligns to exactly the same location with a perfect match twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3145 ### strand) were methylated and therefore protected. Alternatively it will align better in one condition than in the other. In any case, it is not needed to overwrite
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3146 ### the same positional entry with a second entry for the same location, as the genomic sequence extraction and methylation call would not be affected by this. The only
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3147 ### thing which would change is the index number for the found alignment). We will continue to assign these alignments to the first indexes 0 and 1, i.e. OT and OB
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 if ($overwrite){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3150 $alignments{$alignment_location}->{seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3151 $alignments{$alignment_location}->{alignment_score} = $alignment_score;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3152 $alignments{$alignment_location}->{alignment_score_second_best} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3153 $alignments{$alignment_location}->{bowtie_sequence} = $bowtie_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3154 $alignments{$alignment_location}->{index} = $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3155 $alignments{$alignment_location}->{chromosome} = $chromosome;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3156 $alignments{$alignment_location}->{position} = $position;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3157 $alignments{$alignment_location}->{MD_tag} = $MD_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3158 $alignments{$alignment_location}->{CIGAR} = $cigar;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3161 my $newline = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3162 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3163 chomp $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3164 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3165 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3166 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3167 if ($seq_id eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3168 die "Sequence with ID $identifier did not have a second best alignment, but next seq-ID was also $fhs[$index]->{last_seq_id}!\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3171 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3172 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3173 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3174 $fhs[$index]->{last_line} = undef;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3177 }
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 ### If there were several equally good alignments for the best alignment score we will boot the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3181 if ($amb_same_thread){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3182 $alignment_ambiguous = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3183 # warn "\$alignment_ambiguous now: $alignment_ambiguous\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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3186 # warn "alignment won't be considered ambiguous. This time....\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3187 }
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 the read produced several ambiguous alignments already now can returning already now. If --ambiguous or --unmapped was specified the read sequence will be printed out.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3190 if ($alignment_ambiguous == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3191 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3192 ### report that the sequence has multiple hits with bitwise flag 256. We can print the sequence to the result file straight away and skip everything else
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3193 # my $ambiguous_read_output = join("\t",$identifier,'256','*','0','0','*','*','0','0',$sequence,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3194 # print "$ambiguous_read_output\n";
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 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3197 # warn "Sequence is ambiguous, printing out BAM file:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3198 print AMBIBAM "$first_ambig_alignment\n";
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 ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3202 return 2; # => exits to next sequence, and prints it out to _ambiguous_reads.txt if '--ambiguous' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3203 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3204 elsif ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3205 return 1; # => exits to next sequence, and prints it out to _unmapped_reads.txt if '--unmapped' but not '--ambiguous' was specified
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 return 0;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3212 ### if there was no alignment found for a certain sequence at all we continue with the next sequence in the sequence file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3213 unless(%alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3214 $counting{no_single_alignment_found}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3215 # my $unmapped_read_output = join("\t",$identifier,'4','*','0','0','*','*','0','0',$sequence,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3216 # print "$unmapped_read_output\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3217 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3218 return 1; # => exits to next sequence, and prints it out to _unmapped_reads.txt if '--unmapped' was specified
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3221 return 0; # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3222 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3223 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3224
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3225 #######################################################################################################################################################
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 ### If the sequence was not rejected so far we are now looking if there is a unique best alignment among all alignment instances. If there is only one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3228 ### single best position we are going to store the alignment information in the $meth_call variable. If there are multiple hits with the same (highest)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3229 ### alignment score we are discarding the sequence altogether.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3230 ### For end-to-end alignments the maximum alignment score can be 0, each mismatch can receive penalties up to 6, and each gap receives penalties for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3231 ### opening (5) and extending (3 per bp) the gap.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3232
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3233 #######################################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3234
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3235 my $methylation_call_params; # hash reference which will store all information we need for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3236 my $sequence_fails = 0; # Going to use $sequence_fails as a 'memory' if a sequence could not be aligned uniquely (set to 1 then)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3237
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3238 ### print contents of %alignments for debugging
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3239 # if (scalar keys %alignments > 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3240 # print "\n******\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3241 # foreach my $alignment_location (sort {$a cmp $b} keys %alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3242 # print "Loc: $alignment_location\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3243 # print "ID: $alignments{$alignment_location}->{seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3244 # print "AS: $alignments{$alignment_location}->{alignment_score}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3245 # print "Seq: $alignments{$alignment_location}->{bowtie_sequence}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3246 # print "Index $alignments{$alignment_location}->{index}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3247 # print "Chr: $alignments{$alignment_location}->{chromosome}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3248 # print "pos: $alignments{$alignment_location}->{position}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3249 # print "MD: $alignments{$alignment_location}->{MD_tag}\n\n";
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 # print "\n******\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3252 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3253
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3254 ### if there is only 1 entry in the hash with we accept it as the best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3255 if (scalar keys %alignments == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3256 for my $unique_best_alignment (keys %alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3257 $methylation_call_params->{$identifier}->{bowtie_sequence} = $alignments{$unique_best_alignment}->{bowtie_sequence};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3258 $methylation_call_params->{$identifier}->{chromosome} = $alignments{$unique_best_alignment}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3259 $methylation_call_params->{$identifier}->{position} = $alignments{$unique_best_alignment}->{position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3260 $methylation_call_params->{$identifier}->{index} = $alignments{$unique_best_alignment}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3261 $methylation_call_params->{$identifier}->{alignment_score} = $alignments{$unique_best_alignment}->{alignment_score};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3262 $methylation_call_params->{$identifier}->{alignment_score_second_best} = $alignments{$unique_best_alignment}->{alignment_score_second_best};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3263 $methylation_call_params->{$identifier}->{MD_tag} = $alignments{$unique_best_alignment}->{MD_tag};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3264 $methylation_call_params->{$identifier}->{CIGAR} = $alignments{$unique_best_alignment}->{CIGAR};
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3268 ### otherwise we are going to find out if there is a best match among the multiple alignments, or whether there are 2 or more equally good alignments (in which case
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3269 ### we boot the sequence altogether
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3270 elsif (scalar keys %alignments >= 2 and scalar keys %alignments <= 4){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3271 my $best_alignment_score;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3272 my $best_alignment_location;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3273 foreach my $alignment_location (sort {$alignments{$b}->{alignment_score} <=> $alignments{$a}->{alignment_score}} keys %alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3274 # print "$alignments{$alignment_location}->{alignment_score}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3275 unless (defined $best_alignment_score){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3276 $best_alignment_score = $alignments{$alignment_location}->{alignment_score};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3277 $best_alignment_location = $alignment_location;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3278 # print "setting best alignment score: $best_alignment_score\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3279 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3280 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3281 ### if the second best alignment has the same alignment score as the first one, the sequence will get booted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3282 if ($alignments{$alignment_location}->{alignment_score} == $best_alignment_score){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3283 # warn "Same alignment score, the sequence will get booted!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3284 $sequence_fails = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3285 last; # exiting after the second alignment since we know that the sequence has ambiguous alignments
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 ### else we are going to store the best alignment for further processing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3288 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3289 $methylation_call_params->{$identifier}->{bowtie_sequence} = $alignments{$best_alignment_location}->{bowtie_sequence};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3290 $methylation_call_params->{$identifier}->{chromosome} = $alignments{$best_alignment_location}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3291 $methylation_call_params->{$identifier}->{position} = $alignments{$best_alignment_location}->{position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3292 $methylation_call_params->{$identifier}->{index} = $alignments{$best_alignment_location}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3293 $methylation_call_params->{$identifier}->{alignment_score} = $alignments{$best_alignment_location}->{alignment_score};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3294 $methylation_call_params->{$identifier}->{MD_tag} = $alignments{$best_alignment_location}->{MD_tag};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3295 $methylation_call_params->{$identifier}->{CIGAR} = $alignments{$best_alignment_location}->{CIGAR};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3296 if (defined $alignments{$best_alignment_location}->{alignment_score_second_best} and $alignments{$best_alignment_location}-> {alignment_score_second_best} > $alignments{$alignment_location}->{alignment_score}) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3297 $methylation_call_params->{$identifier}->{alignment_score_second_best} = $alignments{$best_alignment_location}->{alignment_score_second_best};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3298 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3299 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3300 $methylation_call_params->{$identifier}->{alignment_score_second_best} = $alignments{$alignment_location}->{alignment_score};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3301 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3302 last; # exiting after processing the second alignment since the sequence produced a unique best alignment
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3305 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3308 die "There are too many potential hits for this sequence (1-4 expected, but found: ",scalar keys %alignments,")\n";;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3309 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3310
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3311 ### skipping the sequence completely if there were multiple alignments with the same best alignment score at different positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3312 if ($sequence_fails == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3313 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3314
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3315 ### report that the sequence has multiple hits with bitwise flag 256. We can print the sequence to the result file straight away and skip everything else
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3316 # my $ambiguous_read_output = join("\t",$identifier,'256','*','0','0','*','*','0','0',$sequence,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3317 # print OUT "$ambiguous_read_output\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3318
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3319 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3320 return 2; # => exits to next sequence, and prints it out (in FastQ format) to _ambiguous_reads.txt if '--ambiguous' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3321 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3322 elsif ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3323 return 1; # => exits to next sequence, and prints it out (in FastQ format) to _unmapped_reads.txt if '--unmapped' but not '--ambiguous' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3324 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3325 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3326 return 0; # => exits to next sequence (default)
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3329
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3330 ### --DIRECTIONAL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3331 ### If the option --directional has been specified the user wants to consider only alignments to the original top strand or the original bottom strand. We will therefore
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3332 ### discard all alignments to strands complementary to the original strands, as they should not exist in reality due to the library preparation protocol
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3333 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3334 if ( ($methylation_call_params->{$identifier}->{index} == 2) or ($methylation_call_params->{$identifier}->{index} == 3) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3335 # warn "Alignment rejected! (index was: $methylation_call_params->{$identifier}->{index})\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3336 $counting{alignments_rejected_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3337 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3338 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3339 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3340
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3341 ### If the sequence has not been rejected so far it has a unique best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3342 $counting{unique_best_alignment_count}++;
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 ### Now we need to extract a genomic sequence that exactly corresponds to the reported alignment. This potentially means that we need to deal with insertions or deletions as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3345 extract_corresponding_genomic_sequence_single_end_bowtie2 ($identifier,$methylation_call_params);
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 ### check test to see if the genomic sequence we extracted has the same length as the observed sequence+2, and only then we perform the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3348 if (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence}) != length($sequence)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3349 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{position}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3350 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3351 return 0;
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 # Compute MAPQ value
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3355 $methylation_call_params->{$identifier}->{mapq} = calc_mapq (length($sequence), undef,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3356 $methylation_call_params->{$identifier}->{alignment_score},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3357 $methylation_call_params->{$identifier}->{alignment_score_second_best});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3358
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3359
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3360
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3361 ### otherwise we are set to perform the actual methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3362 $methylation_call_params->{$identifier}->{methylation_call} = methylation_call($identifier,$sequence,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence},$methylation_call_params->{$identifier}->{read_conversion});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3363 print_bisulfite_mapping_result_single_end_bowtie2 ($identifier,$sequence,$methylation_call_params,$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3364 return 0; ## if a sequence got this far we do not want to print it to unmapped or ambiguous.out
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3365 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3366
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3367
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3368 sub determine_number_of_transliterations_performed{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3369 my ($sequence,$read_conversion) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3370 my $number_of_transliterations;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3371 if ($read_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
3372 $number_of_transliterations = $sequence =~ tr/C/T/;
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 ($read_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
3375 $number_of_transliterations = $sequence =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3376 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3377 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3378 die "Read conversion mode of the read was not specified $!\n";
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 return $number_of_transliterations;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3381 }
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 sub decide_whether_single_end_alignment_is_valid{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3384 my ($index,$identifier) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3385
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3386 # extracting from Bowtie 1 format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3387 my ($id,$strand) = (split (/\t/,$fhs[$index]->{last_line}))[0,1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3388
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3389 ### ensuring that the entry is the correct sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3390 if (($id eq $fhs[$index]->{last_seq_id}) and ($id eq $identifier)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3391 ### checking the orientation of the alignment. We need to discriminate between 8 different conditions, however only 4 of them are theoretically
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3392 ### sensible alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3393 my $orientation = ensure_sensical_alignment_orientation_single_end ($index,$strand);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3394 ### If the orientation was correct can we move on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3395 if ($orientation == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3396 return 1; ### 1st possibility for a sequence to pass
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3397 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3398 ### If the alignment was in the wrong orientation we need to read in a new line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3399 elsif($orientation == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3400 my $newline = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3401 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3402 ($id,$strand) = (split (/\t/,$newline))[0,1];
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 ### ensuring that the next entry is still the correct sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3405 if ($id eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3406 ### checking orientation again
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3407 $orientation = ensure_sensical_alignment_orientation_single_end ($index,$strand);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3408 ### If the orientation was correct can we move on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3409 if ($orientation == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3410 $fhs[$index]->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3411 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3412 return 1; ### 2nd possibility for a sequence to pass
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 ### If the alignment was in the wrong orientation again we need to read in yet another new line and store it in @fhs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3415 elsif ($orientation == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3416 $newline = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3417 if ($newline){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3418 my ($seq_id) = split (/\t/,$newline);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3419 ### check if the next line still has the same seq ID (must not happen), and if not overwrite the current seq-ID and bowtie output with
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3420 ### the same fields of the just read next entry
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3421 die "Same seq ID 3 or more times in a row!(should be 2 max) $!" if ($seq_id eq $identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3422 $fhs[$index]->{last_seq_id} = $seq_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3423 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3424 return 0; # not processing anything this round as the alignment currently stored in last_line was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3425 }
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 # assigning undef to last_seq_id and last_line (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3428 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3429 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3430 return 0; # not processing anything as the alignment currently stored in last_line was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3431 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3434 die "The orientation of the alignment must be either correct or incorrect\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3435 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3436 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3437 ### the sequence we just read in is already the next sequence to be analysed -> store it in @fhs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3438 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3439 $fhs[$index]->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3440 $fhs[$index]->{last_line} = $newline;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3441 return 0; # processing the new alignment result only in the next round
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3442 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3443 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3444 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3445 # assigning undef to last_seq_id and last_line (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3446 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3447 $fhs[$index]->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3448 return 0; # not processing anything as the alignment currently stored in last_line was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3449 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3450 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3451 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3452 die "The orientation of the alignment must be either correct or incorrect\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3455 ### the sequence stored in @fhs as last_line is already the next sequence to be analysed -> analyse next round
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3456 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3457 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3458 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3459 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3460 #########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3461 ### BOWTIE 1 | PAIRED-END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3462 #########################
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 sub check_bowtie_results_paired_ends{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3465 my ($sequence_1,$sequence_2,$identifier,$quality_value_1,$quality_value_2) = @_;
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 ### quality values are not given for FastA files, so they are initialised with a Phred quality of 40
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3468 unless ($quality_value_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3469 $quality_value_1 = 'I'x(length$sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3470 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3471 unless ($quality_value_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3472 $quality_value_2 = 'I'x(length$sequence_2);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3475 # warn "$identifier\n$fhs[0]->{last_seq_id}\n$fhs[1]->{last_seq_id}\n$fhs[2]->{last_seq_id}\n$fhs[3]->{last_seq_id}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3476 # sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3477 my %mismatches = ();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3478 ### reading from the bowtie output files to see if this sequence pair aligned to a bisulfite converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3479
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3480
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3481 ### for paired end reads we are reporting alignments to the OT strand first (index 0), then the OB strand (index 3!!), similiar to the single end way.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3482 ### alignments to the complementary strands are reported afterwards (CTOT got index 1, and CTOB got index 2).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3483 ### This is needed so that alignments which either contain no single C or G or reads which contain only protected Cs are reported to the original strands (OT and OB)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3484 ### Before the complementary strands. Remember that it does not make any difference for the methylation calls, but it will matter if alignment to the complementary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3485 ### strands are not being reported by specifying --directional
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 foreach my $index (0,3,1,2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3488 ### skipping this index if the last alignment has been set to undefined already (i.e. end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3489 next unless ($fhs[$index]->{last_line_1} and $fhs[$index]->{last_line_2} and defined $fhs[$index]->{last_seq_id});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3490 ### if the sequence pair we are currently looking at produced an alignment we are doing various things with it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3491 if ($fhs[$index]->{last_seq_id} eq $identifier) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3492 # print "$identifier\n$fhs[$index]->{last_seq_id}\n\n";
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 ##################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3495 ### STEP I Processing the entry which is stored in last_line_1 and last_line_2 ###
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 my $valid_alignment_found = decide_whether_paired_end_alignment_is_valid($index,$identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3498 ### sequences can fail at this point if there was only 1 alignment in the wrong orientation, or if there were 2 aligments both in the wrong
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3499 ### orientation. We only continue to extract useful information about this alignment if 1 was returned
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3500 if ($valid_alignment_found == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3501 ### Bowtie outputs which made it this far are in the correct orientation, so we can continue to analyse the alignment itself.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3502 ### we store the useful information in %mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3503 my ($id_1,$strand_1,$mapped_chromosome_1,$position_1,$bowtie_sequence_1,$mismatch_info_1) = (split (/\t/,$fhs[$index]->{last_line_1},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3504 my ($id_2,$strand_2,$mapped_chromosome_2,$position_2,$bowtie_sequence_2,$mismatch_info_2) = (split (/\t/,$fhs[$index]->{last_line_2},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3505 chomp $mismatch_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3506 chomp $mismatch_info_2;
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 ### need to extract the chromosome number from the bowtie output (which is either XY_CT_converted or XY_GA_converted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3509 my ($chromosome_1,$chromosome_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3510 if ($mapped_chromosome_1 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3511 $chromosome_1 = $mapped_chromosome_1;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3514 die "Chromosome number extraction failed for $mapped_chromosome_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3515 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3516 if ($mapped_chromosome_2 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3517 $chromosome_2 = $mapped_chromosome_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3518 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3519 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3520 die "Chromosome number extraction failed for $mapped_chromosome_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3521 }
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 ### Now extracting the number of mismatches to the converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3524 my $number_of_mismatches_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3525 my $number_of_mismatches_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3526 if ($mismatch_info_1 eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3527 $number_of_mismatches_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3528 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3529 elsif ($mismatch_info_1 =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3530 my @mismatches = split (/,/,$mismatch_info_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3531 $number_of_mismatches_1 = scalar @mismatches;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3534 die "Something weird is going on with the mismatch field\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3535 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3536 if ($mismatch_info_2 eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3537 $number_of_mismatches_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3538 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3539 elsif ($mismatch_info_2 =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3540 my @mismatches = split (/,/,$mismatch_info_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3541 $number_of_mismatches_2 = scalar @mismatches;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3544 die "Something weird is going on with the mismatch field\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3545 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3546 ### To decide whether a sequence pair has a unique best alignment we will look at the lowest sum of mismatches from both alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3547 my $sum_of_mismatches = $number_of_mismatches_1+$number_of_mismatches_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3548 ### creating a composite location variable from $chromosome and $position and storing the alignment information in a temporary hash table
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3549 die "Position 1 is higher than position 2" if ($position_1 > $position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3550 die "Paired-end alignments need to be on the same chromosome\n" unless ($chromosome_1 eq $chromosome_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3551 my $alignment_location = join(":",$chromosome_1,$position_1,$position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3552 ### If a sequence aligns to exactly the same location twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3553 ### strand) were methylated and therefore protected. It is not needed to overwrite the same positional entry with a second entry for the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3554 ### location (the genomic sequence extraction and methylation would not be affected by this, only the thing which would change is the index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3555 ### number for the found alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3556 unless (exists $mismatches{$sum_of_mismatches}->{$alignment_location}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3557 $mismatches{$sum_of_mismatches}->{$alignment_location}->{seq_id}=$id_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3558 $mismatches{$sum_of_mismatches}->{$alignment_location}->{bowtie_sequence_1}=$bowtie_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3559 $mismatches{$sum_of_mismatches}->{$alignment_location}->{bowtie_sequence_2}=$bowtie_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3560 $mismatches{$sum_of_mismatches}->{$alignment_location}->{index}=$index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3561 $mismatches{$sum_of_mismatches}->{$alignment_location}->{chromosome}=$chromosome_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3562 $mismatches{$sum_of_mismatches}->{$alignment_location}->{start_seq_1}=$position_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3563 $mismatches{$sum_of_mismatches}->{$alignment_location}->{start_seq_2}=$position_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3564 $mismatches{$sum_of_mismatches}->{$alignment_location}->{number_of_mismatches_1} = $number_of_mismatches_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3565 $mismatches{$sum_of_mismatches}->{$alignment_location}->{number_of_mismatches_2} = $number_of_mismatches_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3566 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3567 ###################################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3568 ### STEP II Now reading in the next 2 lines from the bowtie filehandle. If there are 2 next lines in the alignments filehandle it can either ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3569 ### be a second alignment of the same sequence pair or a new sequence pair. In any case we will just add it to last_line_1 and last_line _2. ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3570 ### If it is the alignment of the next sequence pair, 0 will be returned as $valid_alignment_found, so it will not be processed any further in ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3571 ### this round ###
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 my $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3574 my $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3575
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3576 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3577 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3578 my ($seq_id_2) = split (/\t/,$newline_2);
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 if ($seq_id_1 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3581 $fhs[$index]->{last_seq_id} = $seq_id_1;
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 elsif ($seq_id_2 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3584 $fhs[$index]->{last_seq_id} = $seq_id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3585 }
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 "Either read 1 or read 2 needs to end on '/1'\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 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3591 $fhs[$index]->{last_line_2} = $newline_2;
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3594 # assigning undef to last_seq_id and both last_lines and jumping to the next index (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3595 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3596 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3597 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3598 next; # jumping to the next index
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 ### Now processing the entry we just stored in last_line_1 and last_line_2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3601 $valid_alignment_found = decide_whether_paired_end_alignment_is_valid($index,$identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3602 ### only processing the alignment further if 1 was returned. 0 will be returned either if the alignment is already the next sequence pair to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3603 ### be analysed or if it was a second alignment of the current sequence pair but in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3604 if ($valid_alignment_found == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3605 ### we store the useful information in %mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3606 ($id_1,$strand_1,$mapped_chromosome_1,$position_1,$bowtie_sequence_1,$mismatch_info_1) = (split (/\t/,$fhs[$index]->{last_line_1}))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3607 ($id_2,$strand_2,$mapped_chromosome_2,$position_2,$bowtie_sequence_2,$mismatch_info_2) = (split (/\t/,$fhs[$index]->{last_line_2}))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3608 chomp $mismatch_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3609 chomp $mismatch_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3610 ### need to extract the chromosome number from the bowtie output (which is either _CT_converted or _GA_converted)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3611 if ($mapped_chromosome_1 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3612 $chromosome_1 = $mapped_chromosome_1;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3615 die "Chromosome number extraction failed for $mapped_chromosome_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3616 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3617 if ($mapped_chromosome_2 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3618 $chromosome_2 = $mapped_chromosome_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3619 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3620 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3621 die "Chromosome number extraction failed for $mapped_chromosome_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3622 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3623
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3624 $number_of_mismatches_1='';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3625 $number_of_mismatches_2='';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3626 ### Now extracting the number of mismatches to the converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3627 if ($mismatch_info_1 eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3628 $number_of_mismatches_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3629 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3630 elsif ($mismatch_info_1 =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3631 my @mismatches = split (/,/,$mismatch_info_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3632 $number_of_mismatches_1 = scalar @mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3633 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3634 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3635 die "Something weird is going on with the mismatch field\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3636 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3637 if ($mismatch_info_2 eq ''){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3638 $number_of_mismatches_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3639 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3640 elsif ($mismatch_info_2 =~ /^\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3641 my @mismatches = split (/,/,$mismatch_info_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3642 $number_of_mismatches_2 = scalar @mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3643 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3644 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3645 die "Something weird is going on with the mismatch field\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3646 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3647 ### To decide whether a sequence pair has a unique best alignment we will look at the lowest sum of mismatches from both alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3648 $sum_of_mismatches = $number_of_mismatches_1+$number_of_mismatches_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3649 ### creating a composite location variable from $chromosome and $position and storing the alignment information in a temporary hash table
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3650 die "position 1 is greater than position 2" if ($position_1 > $position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3651 die "Paired-end alignments need to be on the same chromosome\n" unless ($chromosome_1 eq $chromosome_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3652 $alignment_location = join(":",$chromosome_1,$position_1,$position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3653 ### If a sequence aligns to exactly the same location twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3654 ### strand) were methylated and therefore protected. It is not needed to overwrite the same positional entry with a second entry for the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3655 ### location (the genomic sequence extraction and methylation would not be affected by this, only the thing which would change is the index
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3656 ### number for the found alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3657 unless (exists $mismatches{$sum_of_mismatches}->{$alignment_location}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3658 $mismatches{$sum_of_mismatches}->{$alignment_location}->{seq_id}=$id_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3659 $mismatches{$sum_of_mismatches}->{$alignment_location}->{bowtie_sequence_1}=$bowtie_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3660 $mismatches{$sum_of_mismatches}->{$alignment_location}->{bowtie_sequence_2}=$bowtie_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3661 $mismatches{$sum_of_mismatches}->{$alignment_location}->{index}=$index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3662 $mismatches{$sum_of_mismatches}->{$alignment_location}->{chromosome}=$chromosome_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3663 $mismatches{$sum_of_mismatches}->{$alignment_location}->{start_seq_1}=$position_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3664 $mismatches{$sum_of_mismatches}->{$alignment_location}->{start_seq_2}=$position_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3665 $mismatches{$sum_of_mismatches}->{$alignment_location}->{number_of_mismatches_1} = $number_of_mismatches_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3666 $mismatches{$sum_of_mismatches}->{$alignment_location}->{number_of_mismatches_2} = $number_of_mismatches_2;
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 ### STEP III Now reading in two more lines. These have to be the next entry and we will just add assign them to last_line_1 and last_line_2 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3670 ###############################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3671 $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3672 $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3673
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3674 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3675 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3676 my ($seq_id_2) = split (/\t/,$newline_2);
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 if ($seq_id_1 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3679 $fhs[$index]->{last_seq_id} = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3680 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3681 if ($seq_id_2 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3682 $fhs[$index]->{last_seq_id} = $seq_id_2;
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 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3685 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3686 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3687 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3688 # assigning undef to last_seq_id and both last_lines and jumping to the next index (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3689 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3690 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3691 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3692 next; # jumping to the next index
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 ### within the 2nd sequence pair alignment in correct orientation found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3695 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3696 ### within the 1st sequence pair alignment in correct orientation found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3697 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3698 ### still within the (last_seq_id eq identifier) condition
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 ### still within foreach index loop
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3701 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3702 ### if there was no single alignment found for a certain sequence we will continue with the next sequence in the sequence file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3703 unless(%mismatches){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3704 $counting{no_single_alignment_found}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3705 return 1; ### We will print this sequence out as unmapped sequence if --un unmapped.out has been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3706 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3707 ### Going to use the variable $sequence_pair_fails as a 'memory' if a sequence could not be aligned uniquely (set to 1 then)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3708 my $sequence_pair_fails = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3709 ### Declaring an empty hash reference which will store all information we need for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3710 my $methylation_call_params; # hash reference!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3711 ### We are now looking if there is a unique best alignment for a certain sequence. This means we are sorting in ascending order and look at the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3712 ### sequence with the lowest amount of mismatches. If there is only one single best position we are going to store the alignment information in the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3713 ### meth_call variables, if there are multiple hits with the same amount of (lowest) mismatches we are discarding the sequence altogether
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3714 foreach my $mismatch_number (sort {$a<=>$b} keys %mismatches){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3715 #dev print "Number of mismatches: $mismatch_number\t$identifier\t$sequence_1\t$sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3716 foreach my $entry (keys (%{$mismatches{$mismatch_number}}) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3717 #dev print "$mismatch_number\t$entry\t$mismatches{$mismatch_number}->{$entry}->{index}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3718 # print join("\t",$mismatch_number,$mismatches{$mismatch_number}->{$entry}->{seq_id},$sequence,$mismatches{$mismatch_number}->{$entry}->{bowtie_sequence},$mismatches{$mismatch_number}->{$entry}->{chromosome},$mismatches{$mismatch_number}->{$entry}->{position},$mismatches{$mismatch_number}->{$entry}->{index}),"\n";
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 if (scalar keys %{$mismatches{$mismatch_number}} == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3721 # print "Unique best alignment for sequence pair $sequence_1\t$sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3722 for my $unique_best_alignment (keys %{$mismatches{$mismatch_number}}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3723 $methylation_call_params->{$identifier}->{seq_id} = $identifier;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3724 $methylation_call_params->{$identifier}->{bowtie_sequence_1} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{bowtie_sequence_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3725 $methylation_call_params->{$identifier}->{bowtie_sequence_2} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{bowtie_sequence_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3726 $methylation_call_params->{$identifier}->{chromosome} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3727 $methylation_call_params->{$identifier}->{start_seq_1} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{start_seq_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3728 $methylation_call_params->{$identifier}->{start_seq_2} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{start_seq_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3729 $methylation_call_params->{$identifier}->{alignment_end} = ($mismatches{$mismatch_number}->{$unique_best_alignment}->{start_seq_2}+length($mismatches{$mismatch_number}->{$unique_best_alignment}->{bowtie_sequence_2}));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3730 $methylation_call_params->{$identifier}->{index} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3731 $methylation_call_params->{$identifier}->{number_of_mismatches_1} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{number_of_mismatches_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3732 $methylation_call_params->{$identifier}->{number_of_mismatches_2} = $mismatches{$mismatch_number}->{$unique_best_alignment}->{number_of_mismatches_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3733 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3734 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3735 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3736 $sequence_pair_fails = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3737 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3738 ### after processing the alignment with the lowest number of mismatches we exit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3739 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3740 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3741 ### skipping the sequence completely if there were multiple alignments with the same amount of lowest mismatches found at different positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3742 if ($sequence_pair_fails == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3743 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3744 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3745 return 2; # => exits to next sequence pair, and prints both seqs out to multiple_alignments_1 and -2 if --ambiguous has been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3746 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3747 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3748 return 1; # => exits to next sequence pair, and prints both seqs out to unmapped_1 and _2 if --un has been specified
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3751 return 0; # => exits to next sequence (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3752 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3753 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3754
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3755 ### --DIRECTIONAL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3756 ### If the option --directional has been specified the user wants to consider only alignments to the original top strand or the original bottom strand. We will therefore
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3757 ### discard all alignments to strands complementary to the original strands, as they should not exist in reality due to the library preparation protocol
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3758 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3759 if ( ($methylation_call_params->{$identifier}->{index} == 1) or ($methylation_call_params->{$identifier}->{index} == 2) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3760 # warn "Alignment rejected! (index was: $methylation_call_params->{$identifier}->{index})\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3761 $counting{alignments_rejected_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3762 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3763 }
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 ### If the sequence has not been rejected so far it does have a unique best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3767 $counting{unique_best_alignment_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3768 extract_corresponding_genomic_sequence_paired_ends($identifier,$methylation_call_params);
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 ### check test to see if the genomic sequences we extracted has the same length as the observed sequences +2, and only then we perform the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3771 if (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence_1}) != length($sequence_1)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3772 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{start_seq_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3773 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3774 return 0;
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 (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2}) != length($sequence_2)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3777 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{start_seq_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3778 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3779 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3780 }
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 ### otherwise we are set to perform the actual methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3783 $methylation_call_params->{$identifier}->{methylation_call_1} = methylation_call($identifier,$sequence_1,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_1},$methylation_call_params->{$identifier}->{read_conversion_1});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3784 $methylation_call_params->{$identifier}->{methylation_call_2} = methylation_call($identifier,$sequence_2,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2},$methylation_call_params->{$identifier}->{read_conversion_2});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3785
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3786 print_bisulfite_mapping_results_paired_ends($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3787 return 0; ## otherwise 1 will be returned by default, which would print the sequence pair to unmapped_1 and _2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3788 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3789
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3790 #########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3791 ### BOWTIE 2 | PAIRED-END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3792 #########################
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 sub check_bowtie_results_paired_ends_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3795 my ($sequence_1,$sequence_2,$identifier,$quality_value_1,$quality_value_2) = @_;
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 ### quality values are not given for FastA files, so they are initialised with a Phred quality of 40
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3798 unless ($quality_value_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3799 $quality_value_1 = 'I'x(length$sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3800 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3801
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3802 unless ($quality_value_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3803 $quality_value_2 = 'I'x(length$sequence_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3804 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3805 # print "$identifier\n$fhs[0]->{last_seq_id}\n$fhs[1]->{last_seq_id}\n$fhs[2]->{last_seq_id}\n$fhs[3]->{last_seq_id}\n\n";
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 my %alignments;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3808 my $alignment_ambiguous = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3809
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3810 my $first_ambig_alignment_line1; # storing the first ambiguous alignment so it can be written out in case '--ambig_bam' was specified R1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3811 my $first_ambig_alignment_line2; # R2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3812
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3813 my $best_AS_so_far; ## we need to keep a memory of the best alignment score so far
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3814 my $amb_same_thread = 0; ## if a read's primary and secondary alignments have the same alignment score we set this to true.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3815
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3816 ### reading from the Bowtie 2 output filehandles
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 ### for paired end reads we are reporting alignments to the OT strand first (index 0), then the OB strand (index 3!!), similiar to the single end way.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3819 ### alignments to the complementary strands are reported afterwards (CTOT got index 1, and CTOB got index 2).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3820 ### This is needed so that alignments which either contain no single C or G or reads which contain only protected Cs are reported to the original strands (OT and OB)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3821 ### Before the complementary strands. Remember that it does not make any difference for the methylation calls, but it will matter if alignments to the complementary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3822 ### strands are not being reported when '--directional' is specified
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 foreach my $index (0,3,1,2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3825 ### skipping this index if the last alignment has been set to undefined already (i.e. end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3826 next unless ($fhs[$index]->{last_line_1} and $fhs[$index]->{last_line_2} and defined $fhs[$index]->{last_seq_id});
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 ### if the sequence pair we are currently looking at produced an alignment we are doing various things with it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3829 if ($fhs[$index]->{last_seq_id} eq $identifier) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3830
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3831 my ($id_1,$flag_1,$mapped_chromosome_1,$position_1,$mapping_quality_1,$cigar_1,$bowtie_sequence_1,$qual_1) = (split (/\t/,$fhs[$index]->{last_line_1}))[0,1,2,3,4,5,9,10];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3832 my ($id_2,$flag_2,$mapped_chromosome_2,$position_2,$mapping_quality_2,$cigar_2,$bowtie_sequence_2,$qual_2) = (split (/\t/,$fhs[$index]->{last_line_2}))[0,1,2,3,4,5,9,10];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3833 # print "Index: $index\t$fhs[$index]->{last_line_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3834 # print "Index: $index\t$fhs[$index]->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3835 # print join ("\t",$id_1,$flag_1,$mapped_chromosome_1,$position_1,$mapping_quality_1,$cigar_1,$bowtie_sequence_1,$qual_1),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3836 # print join ("\t",$id_2,$flag_2,$mapped_chromosome_2,$position_2,$mapping_quality_2,$cigar_2,$bowtie_sequence_2,$qual_2),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3837 $id_1 =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3838 $id_2 =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3839
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3840 # SAM format specifications for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3841 # (1) Name of read that aligned
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3842 # (2) Sum of all applicable flags. Flags relevant to Bowtie are:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3843 # 1 The read is one of a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3844 # 2 The alignment is one end of a proper paired-end alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3845 # 4 The read has no reported alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3846 # 8 The read is one of a pair and has no reported alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3847 # 16 The alignment is to the reverse reference strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3848 # 32 The other mate in the paired-end alignment is aligned to the reverse reference strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3849 # 64 The read is mate 1 in a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3850 # 128 The read is mate 2 in a pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3851 # 256 The read has multiple mapping states
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3852 # (3) Name of reference sequence where alignment occurs (unmapped reads have a *)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3853 # (4) 1-based offset into the forward reference strand where leftmost character of the alignment occurs (0 for unmapped reads)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3854 # (5) Mapping quality (255 means MAPQ is not available)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3855 # (6) CIGAR string representation of alignment (* if unavailable)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3856 # (7) Name of reference sequence where mate's alignment occurs. Set to = if the mate's reference sequence is the same as this alignment's, or * if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3857 # (8) 1-based offset into the forward reference strand where leftmost character of the mate's alignment occurs. Offset is 0 if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3858 # (9) Inferred fragment size. Size is negative if the mate's alignment occurs upstream of this alignment. Size is 0 if there is no mate.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3859 # (10) Read sequence (reverse-complemented if aligned 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
3860 # (11) ASCII-encoded read qualities (reverse-complemented if the read aligned to the reverse strand). The encoded quality values are on the Phred quality scale and the encoding is ASCII-offset by 33 (ASCII char !), similarly to a FASTQ file.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3861 # (12) Optional fields. Fields are tab-separated. bowtie2 outputs zero or more of these optional fields for each alignment, depending on the type of the alignment:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3862 # AS:i:<N> Alignment score. Can be negative. Can be greater than 0 in --local mode (but not in --end-to-end mode). Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3863 # XS:i:<N> Alignment score for second-best alignment. Can be negative. Can be greater than 0 in --local mode (but not in --end-to-end mode). Only present if the SAM record is for an aligned read and more than one alignment was found for the read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3864 # YS:i:<N> Alignment score for opposite mate in the paired-end alignment. Only present if the SAM record is for a read that aligned as part of a paired-end alignment.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3865 # XN:i:<N> The number of ambiguous bases in the reference covering this alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3866 # XM:i:<N> The number of mismatches in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3867 # XO:i:<N> The number of gap opens, for both read and reference gaps, in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3868 # XG:i:<N> The number of gap extensions, for both read and reference gaps, in the alignment. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3869 # NM:i:<N> The edit distance; that is, the minimal number of one-nucleotide edits (substitutions, insertions and deletions) needed to transform the read string into the reference string. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3870 # YF:Z:<N> String indicating reason why the read was filtered out. See also: Filtering. Only appears for reads that were filtered out.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3871 # MD:Z:<S> A string representation of the mismatched reference bases in the alignment. See SAM format specification for details. Only present if SAM record is for an aligned read.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3872
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3873 ### If a sequence has no reported alignments there will be a single output line per sequence with a bit-wise flag value of 77 for read 1 (1+4+8+64), or 141 for read 2 (1+4+8+128).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3874 ### We can store the next alignment and move on to the next Bowtie 2 instance
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3875 if ($flag_1 == 77 and $flag_2 == 141){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3876 ## reading in the next alignment, which must be the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3877 my $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3878 my $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3879
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3880 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3881 chomp $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3882 chomp $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3883 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3884 my ($seq_id_2) = split (/\t/,$newline_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3885 $seq_id_1 =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3886 $seq_id_2 =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3887 $fhs[$index]->{last_seq_id} = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3888 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3889 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3890
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3891 # print "current sequence ($identifier) did not map, reading in next sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3892 # print "$index\t$fhs[$index]->{last_seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3893 # print "$index\t$fhs[$index]->{last_line_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3894 # print "$index\t$fhs[$index]->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3895 next; # next instance
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3896 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3897 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3898 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3899 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3900 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3901 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3902 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3903 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3906 ### If there are one or more proper alignments we can extract 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
3907 my ($chromosome_1,$chromosome_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3908 if ($mapped_chromosome_1 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3909 $chromosome_1 = $mapped_chromosome_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3910 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3911 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3912 die "Chromosome number extraction failed for $mapped_chromosome_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3913 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3914 if ($mapped_chromosome_2 =~ s/_(CT|GA)_converted$//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3915 $chromosome_2 = $mapped_chromosome_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3916 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3917 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3918 die "Chromosome number extraction failed for $mapped_chromosome_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3919 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3920
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3921 die "Paired-end alignments need to be on the same chromosome\n" unless ($chromosome_1 eq $chromosome_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3922
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3923 ### We will use the optional fields to determine the best alignments. Later on we extract the number of mismatches and/or indels from the CIGAR string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3924 my ($alignment_score_1,$alignment_score_2,$second_best_1,$second_best_2,$MD_tag_1,$MD_tag_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3925
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3926 my @fields_1 = split (/\t/,$fhs[$index]->{last_line_1});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3927 my @fields_2 = split (/\t/,$fhs[$index]->{last_line_2});
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 foreach (11..$#fields_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3930 if ($fields_1[$_] =~ /AS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3931 $alignment_score_1 = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3932 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3933 elsif ($fields_1[$_] =~ /XS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3934 $second_best_1 = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3935 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3936 elsif ($fields_1[$_] =~ /MD:Z:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3937 $MD_tag_1 = $1;
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 foreach (11..$#fields_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3942 if ($fields_2[$_] =~ /AS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3943 $alignment_score_2 = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3944 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3945 elsif ($fields_2[$_] =~ /XS:i:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3946 $second_best_2 = $1;
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 elsif ($fields_2[$_] =~ /MD:Z:(.*)/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3949 $MD_tag_2 = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3950 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3951 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3952
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3953 die "Failed to extract alignment score 1 ($alignment_score_1) and MD tag ($MD_tag_1)!\nlast alignment 1: $fhs[$index]->{last_line_1}\nlast alignment 2: $fhs[$index]->{last_line_2}\n" unless (defined $alignment_score_1 and defined $MD_tag_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3954 die "Failed to extract alignment score 2 ($alignment_score_2) and MD tag ($MD_tag_2)!\nlast alignment 1: $fhs[$index]->{last_line_1}\nlast alignment 2: $fhs[$index]->{last_line_2}\n" unless (defined $alignment_score_2 and defined $MD_tag_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3955
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3956 # warn "First read 1 alignment score is: '$alignment_score_1'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3957 # warn "First read 2 alignment score is: '$alignment_score_2'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3958 # warn "MD tag 1 is: '$MD_tag_1'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3959 # warn "MD tag 2 is: '$MD_tag_2'\n";
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 ### To decide whether a sequence pair has a unique best alignment we will look at the highest sum of alignment scores from both alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3962 my $sum_of_alignment_scores_1 = $alignment_score_1 + $alignment_score_2 ;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3963 # warn "sum of alignment scores: $sum_of_alignment_scores_1\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
3964
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3965 my $overwrite = 0; # If there are 2 alternative alignments to the same position, e.g. OT with 50 mismatches and CTOB with 0 mismatches, the CTOB one trumps the OT one.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3966 # introduced 13 April 2016 as a suggestion by Sylvain Foret, ANU Canberra
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3967
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3968 if (!defined $best_AS_so_far){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3969 $overwrite = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3970 $best_AS_so_far = $sum_of_alignment_scores_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3971 # warn "First alignment score, setting \$best_AS_so_far to $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3972 if ($ambig_bam){ # also setting the first_ambig_alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3973 # Read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3974 $first_ambig_alignment_line1 = $fhs[$index]->{last_line_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3975 $first_ambig_alignment_line1 =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3976 # Read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3977 $first_ambig_alignment_line2 = $fhs[$index]->{last_line_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3978 $first_ambig_alignment_line2 =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3979 # warn "$first_ambig_alignment_line1\n$first_ambig_alignment_line2\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
3980 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3981 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3982 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3983 if ($sum_of_alignment_scores_1 >= $best_AS_so_far){ # AS are generally negative with a maximum of 0
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3984 # 19 07 2016 Changed to >= so that equally good alignments to different positions get added as well. Ambiguous alignments are identified and removed later.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3985 $best_AS_so_far = $sum_of_alignment_scores_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3986 $overwrite = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3987
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3988 # warn "Found better or equal sum of alignment scores ($sum_of_alignment_scores_1), setting \$best_AS_so_far to $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3989 # resetting the ambiguous within thread memory (if applicable at all) only if the current alignment is really better than the previous one.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3990 # 22 07 2016: ambiguous score within same thread only resets if the current alignment is really better than the previous one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3991 if ($sum_of_alignment_scores_1 > $best_AS_so_far){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3992 # warn "Resetting amb within thread value to 0\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3993 $amb_same_thread = 0;
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 if ($ambig_bam){ # also setting a new first_ambig_alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3996 # Read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3997 $first_ambig_alignment_line1 = $fhs[$index]->{last_line_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3998 $first_ambig_alignment_line1 =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
3999 # Read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4000 $first_ambig_alignment_line2 = $fhs[$index]->{last_line_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4001 $first_ambig_alignment_line2 =~ s/_(CT|GA)_converted//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4002 # warn "$first_ambig_alignment_line1\n$first_ambig_alignment_line2\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
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4006 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4007 # warn "current alignment (AS $sum_of_alignment_scores) isn't better than the best so far ($best_AS_so_far). Not changing anything\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4008 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4009 }
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 if (defined $second_best_1 and defined $second_best_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4012 my $sum_of_alignment_scores_second_best = $second_best_1 + $second_best_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4013 # warn "Second best alignment_score_1 is: '$second_best_1'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4014 # warn "Second best alignment_score_2 is: '$second_best_2'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4015 # warn "Second best alignment sum of alignment scores is: '$sum_of_alignment_scores_second_best'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4016
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4017 # If the first alignment score for the first read pair is the same as the alignment score of the second best hit we we keep a memory of this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4018 if ($sum_of_alignment_scores_1 == $sum_of_alignment_scores_second_best){
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 # checking to see if this read pair produced the best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4021 if ($sum_of_alignment_scores_1 == $best_AS_so_far){ # yes this is the best read pair so far, either within the thread or between threads, however it is ambiguous
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4022 # warn "Read pair is ambiguous within the same thread, or otherwise as good as the best one so far. Setting \$amb_same_thread to 1 for currently best AS: $best_AS_so_far\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4023 $amb_same_thread = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4024 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4025 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4026 # warn "This read pair has a worse alignment score than the best alignment so far and will be ignored even though it is ambiguous in itself\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4027 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4028
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4029 ### if there is a better alignment later on -> fine. If not, the read will get booted altogether one way or another
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 ## need to read and discard all additional ambiguous reads until we reach the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4032 until ($fhs[$index]->{last_seq_id} ne $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4033 my $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4034 my $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4035 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4036 chomp $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4037 chomp $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4038 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4039 my ($seq_id_2) = split (/\t/,$newline_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4040 $seq_id_1 =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4041 $seq_id_2 =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4042 # print "New Seq IDs:\t$seq_id_1\t$seq_id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4043
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4044 $fhs[$index]->{last_seq_id} = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4045 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4046 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4047 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4048 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4049 # assigning undef to last_seq_id and last_line and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4050 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4051 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4052 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4053 last; # break free if the end of the alignment output was reached
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4054 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4055 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4056 # if ($fhs[$index]->{last_seq_id}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4057 # warn "Index: $index\tThis Seq-ID is $identifier, skipped all ambiguous sequences until the next ID which is: $fhs[$index]->{last_seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4058 # }
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 else{ # the next best alignment has a lower alignment score than the current read, so we can safely store the current alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4061
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4062 my $alignment_location;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4063 if ($position_1 <= $position_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4064 $alignment_location = join(":",$chromosome_1,$position_1,$position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4065 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4066 elsif($position_2 < $position_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4067 $alignment_location = join(":",$chromosome_1,$position_2,$position_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4068 }
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 ### If a sequence aligns to exactly the same location twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4071 ### strand) were methylated and therefore protected. Alternatively it will align better in one condition than in the other. In any case, it is not needed to overwrite
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4072 ### the same positional entry with a second entry for the same location, as the genomic sequence extraction and methylation call would not be affected by this. The only
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4073 ### thing which would change is the index number for the found alignment). We will continue to assign these alignments to the first indexes 0 and 3, i.e. OT and OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4074
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4075 if ($overwrite){ # see comment above at "my $overwrite = ..."
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4076 #unless (exists $alignments{$alignment_location}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4077 $alignments{$alignment_location}->{seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4078 $alignments{$alignment_location}->{alignment_score_1} = $alignment_score_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4079 $alignments{$alignment_location}->{alignment_score_2} = $alignment_score_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4080 $alignments{$alignment_location}->{sum_of_alignment_scores} = $sum_of_alignment_scores_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4081 $alignments{$alignment_location}->{sum_of_alignment_scores_second_best} = $sum_of_alignment_scores_second_best;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4082 $alignments{$alignment_location}->{bowtie_sequence_1} = $bowtie_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4083 $alignments{$alignment_location}->{bowtie_sequence_2} = $bowtie_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4084 $alignments{$alignment_location}->{index} = $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4085 $alignments{$alignment_location}->{chromosome} = $chromosome_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4086 $alignments{$alignment_location}->{position_1} = $position_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4087 $alignments{$alignment_location}->{position_2} = $position_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4088 $alignments{$alignment_location}->{mismatch_info_1} = $MD_tag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4089 $alignments{$alignment_location}->{mismatch_info_2} = $MD_tag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4090 $alignments{$alignment_location}->{CIGAR_1} = $cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4091 $alignments{$alignment_location}->{CIGAR_2} = $cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4092 $alignments{$alignment_location}->{flag_1} = $flag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4093 $alignments{$alignment_location}->{flag_2} = $flag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4094 # warn "added best of several alignments to \%alignments hash\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 ### now reading and discarding all (inferior) alignments of this read pair until we hit the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4098 until ($fhs[$index]->{last_seq_id} ne $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4099 my $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4100 my $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4101 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4102 chomp $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4103 chomp $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4104 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4105 my ($seq_id_2) = split (/\t/,$newline_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4106 $seq_id_1 =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4107 $seq_id_2 =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4108 # print "New Seq IDs:\t$seq_id_1\t$seq_id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4109
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4110 $fhs[$index]->{last_seq_id} = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4111 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4112 $fhs[$index]->{last_line_2} = $newline_2;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4115 # assigning undef to last_seq_id and last_line_1 and _2 and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4116 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4117 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4118 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4119 last; # break free if the end of the alignment output was reached
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4120 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4121 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4122 # if($fhs[$index]->{last_seq_id}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4123 # warn "Index: $index\tThis Seq-ID is $identifier, skipped all other alignments until the next ID was reached which is: $fhs[$index]->{last_seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4124 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4125 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4126 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4127 else{ # there is no second best hit, so we can just store this one and read in the next sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4128
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4129 my $alignment_location = join(":",$chromosome_1,$position_1,$position_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4130 # print "$alignment_location\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4131 ### If a sequence aligns to exactly the same location with a perfect match twice the sequence does either not contain any C or G, or all the Cs (or Gs on the reverse
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4132 ### strand) were methylated and therefore protected. Alternatively it will align better in one condition than in the other. In any case, it is not needed to overwrite
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4133 ### the same positional entry with a second entry for the same location, as the genomic sequence extraction and methylation call would not be affected by this. The only
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4134 ### thing which would change is the index number for the found alignment). We will continue to assign these alignments to the first indexes 0 and 3, i.e. OT and OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4135
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4136 #unless (exists $alignments{$alignment_location}){ # see comment above at my $overwrite = ...
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4137 if ($overwrite){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4138 $alignments{$alignment_location}->{seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4139 $alignments{$alignment_location}->{alignment_score_1} = $alignment_score_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4140 $alignments{$alignment_location}->{alignment_score_2} = $alignment_score_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4141 $alignments{$alignment_location}->{sum_of_alignment_scores} = $sum_of_alignment_scores_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4142 $alignments{$alignment_location}->{sum_of_alignment_scores_second_best} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4143 $alignments{$alignment_location}->{bowtie_sequence_1} = $bowtie_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4144 $alignments{$alignment_location}->{bowtie_sequence_2} = $bowtie_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4145 $alignments{$alignment_location}->{index} = $index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4146 $alignments{$alignment_location}->{chromosome} = $chromosome_1; # either is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4147 $alignments{$alignment_location}->{position_1} = $position_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4148 $alignments{$alignment_location}->{position_2} = $position_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4149 $alignments{$alignment_location}->{mismatch_info_1} = $MD_tag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4150 $alignments{$alignment_location}->{mismatch_info_2} = $MD_tag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4151 $alignments{$alignment_location}->{CIGAR_1} = $cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4152 $alignments{$alignment_location}->{CIGAR_2} = $cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4153 $alignments{$alignment_location}->{flag_1} = $flag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4154 $alignments{$alignment_location}->{flag_2} = $flag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4155 # warn "added unique alignment to \%alignments hash\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4156 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4157
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4158 # Now reading and storing the next read pair
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4159 my $newline_1 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4160 my $newline_2 = $fhs[$index]->{fh}-> getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4161 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4162 chomp $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4163 chomp $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4164 # print "$newline_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4165 # print "$newline_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4166 my ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4167 my ($seq_id_2) = split (/\t/,$newline_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4168 $seq_id_1 =~ s/\/1$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4169 $seq_id_2 =~ s/\/2$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4170 # print "New Seq IDs:\t$seq_id_1\t$seq_id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4171
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4172 $fhs[$index]->{last_seq_id} = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4173 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4174 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4175
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4176 if ($seq_id_1 eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4177 die "Sequence with ID $identifier did not have a second best alignment, but next seq-ID was also $fhs[$index]->{last_seq_id}!\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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4181 # assigning undef to last_seq_id and last_line_1 and _2 and jumping to the next index (end of Bowtie 2 output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4182 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4183 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4184 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4185 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4186 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4187 }
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 there were several equally good alignments for the best alignment score we will boot the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4191 if ($amb_same_thread){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4192 # warn "\$alignment_ambiguous now: $alignment_ambiguous\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4193 $alignment_ambiguous = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4194 # warn "\$alignment_ambiguous now: $alignment_ambiguous\n";
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 # warn "alignment won't be considered ambiguous. This time....\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4201 ### if the read produced several ambiguous alignments for a single instance of Bowtie 2 we can return already now. If --ambiguous was specified the read sequence will be printed out in FastQ format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4202 if ($alignment_ambiguous == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4203 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4204 ### report that the sequence pair has multiple hits with bitwise flag 256. We can print the sequence to the result file straight away and skip everything else
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4205 # my $ambiguous_read_1 = join("\t",$identifier.'/1','256','*','0','0','*','*','0','0',$sequence_1,$quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4206 # my $ambiguous_read_2 = join("\t",$identifier.'/2','256','*','0','0','*','*','0','0',$sequence_2,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4207 # print "$ambiguous_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
4208 # print "$ambiguous_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
4209
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4210 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4211 # warn "Sequence is ambiguous, printing out to ambiguous BAM file:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4212 # replacing the first /1\t in the ID of R1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4213 # warn "Was\n$first_ambig_alignment_line1\n$first_ambig_alignment_line2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4214 $first_ambig_alignment_line1 =~ s/\/1\t/\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4215 $first_ambig_alignment_line2 =~ s/\/2\t/\t/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4216 # warn "Is:\n$first_ambig_alignment_line1\n$first_ambig_alignment_line2\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4217
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4218 print AMBIBAM "$first_ambig_alignment_line1\n$first_ambig_alignment_line2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4219 # print "$first_ambig_alignment_line1\n$first_ambig_alignment_line2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4220 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4221
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4222 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4223 return 2; # => exits to next sequence pair, and prints it out to _ambiguous_reads_1.txt and _ambiguous_reads_2.txt if '--ambiguous' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4224 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4225 elsif ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4226 return 1; # => exits to next sequence pair, and prints it out to _unmapped_reads_1.txt and _unmapped_reads_2.txt if '--unmapped' but not '--ambiguous' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4227 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4228 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4229 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4230 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4231 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4232
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4233 ### if no alignment was found for a certain sequence at all we continue with the next sequence in the sequence file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4234 unless (%alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4235 $counting{no_single_alignment_found}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4236
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4237 # my $unmapped_read_1 = join("\t",$identifier.'/1','77','*','0','0','*','*','0','0',$sequence_1,$quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4238 # my $unmapped_read_2 = join("\t",$identifier.'/2','141','*','0','0','*','*','0','0',$sequence_2,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4239 # print "$unmapped_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
4240 # print "$unmapped_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
4241 if ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4242 return 1; # => exits to next sequence pair, and prints it out to _unmapped_reads_1.txt and _unmapped_read_2.txt if '--unmapped' was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4243 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4244 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4245 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4246 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4247 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4251 ### If the sequence pair was not rejected so far we are now looking if there is a unique best alignment among all alignment instances. If there is only one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4252 ### single best position we are going to store the alignment information in the $meth_call variable. If there are multiple hits with the same (highest)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4253 ### alignment score we are discarding the sequence pair altogether.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4254 ### For end-to-end alignments the maximum alignment score is 0, each mismatch receives a penalty of 6, and each gap receives penalties for opening (5)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4255 ### and extending (3 per bp) the gap.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4256
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4257 #######################################################################################################################################################
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 ### Declaring an empty hash reference which will store all information we need for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4260 my $methylation_call_params; # hash reference
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4261 my $sequence_pair_fails = 0; # using $sequence_pair_fails as a 'memory' if a sequence could not be aligned uniquely (set to 1 then)
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 ### print contents of %alignments for debugging
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4264 ## if (scalar keys %alignments >= 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4265 # print "\n******\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4266 # foreach my $alignment_location (sort {$a cmp $b} keys %alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4267 # print "Loc: $alignment_location\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4268 # print "ID: $alignments{$alignment_location}->{seq_id}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4269 # print "AS_1: $alignments{$alignment_location}->{alignment_score_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4270 # print "AS_2: $alignments{$alignment_location}->{alignment_score_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4271 # print "Seq_1: $alignments{$alignment_location}->{bowtie_sequence_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4272 # print "Seq_2: $alignments{$alignment_location}->{bowtie_sequence_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4273 # print "Index $alignments{$alignment_location}->{index}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4274 # print "Chr: $alignments{$alignment_location}->{chromosome}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4275 # print "Pos_1: $alignments{$alignment_location}->{position_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4276 # print "Pos_2: $alignments{$alignment_location}->{position_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4277 # print "CIGAR_1: $alignments{$alignment_location}->{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
4278 # print "CIGAR_2: $alignments{$alignment_location}->{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
4279 # print "MD_1: $alignments{$alignment_location}->{mismatch_info_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4280 # print "MD_2: $alignments{$alignment_location}->{mismatch_info_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4281 # print "Flag 1: $alignments{$alignment_location}->{flag_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4282 # print "Flag 2: $alignments{$alignment_location}->{flag_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4283 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4284 # print "\n******\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4285 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4286
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4287 ### if there is only 1 entry in the %alignments hash we accept it as the best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4288 if (scalar keys %alignments == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4289 for my $unique_best_alignment (keys %alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4290 $methylation_call_params->{$identifier}->{bowtie_sequence_1} = $alignments{$unique_best_alignment}->{bowtie_sequence_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4291 $methylation_call_params->{$identifier}->{bowtie_sequence_2} = $alignments{$unique_best_alignment}->{bowtie_sequence_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4292 $methylation_call_params->{$identifier}->{chromosome} = $alignments{$unique_best_alignment}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4293 $methylation_call_params->{$identifier}->{position_1} = $alignments{$unique_best_alignment}->{position_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4294 $methylation_call_params->{$identifier}->{position_2} = $alignments{$unique_best_alignment}->{position_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4295 $methylation_call_params->{$identifier}->{index} = $alignments{$unique_best_alignment}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4296 $methylation_call_params->{$identifier}->{alignment_score_1} = $alignments{$unique_best_alignment}->{alignment_score_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4297 $methylation_call_params->{$identifier}->{alignment_score_2} = $alignments{$unique_best_alignment}->{alignment_score_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4298 $methylation_call_params->{$identifier}->{sum_of_alignment_scores} = $alignments{$unique_best_alignment}->{sum_of_alignment_scores};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4299 $methylation_call_params->{$identifier}->{sum_of_alignment_scores_second_best} = $alignments{$unique_best_alignment}->{sum_of_alignment_scores_second_best};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4300 $methylation_call_params->{$identifier}->{mismatch_info_1} = $alignments{$unique_best_alignment}->{mismatch_info_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4301 $methylation_call_params->{$identifier}->{mismatch_info_2} = $alignments{$unique_best_alignment}->{mismatch_info_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4302 $methylation_call_params->{$identifier}->{CIGAR_1} = $alignments{$unique_best_alignment}->{CIGAR_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4303 $methylation_call_params->{$identifier}->{CIGAR_2} = $alignments{$unique_best_alignment}->{CIGAR_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4304 $methylation_call_params->{$identifier}->{flag_1} = $alignments{$unique_best_alignment}->{flag_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4305 $methylation_call_params->{$identifier}->{flag_2} = $alignments{$unique_best_alignment}->{flag_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4306 }
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 ### otherwise we are going to find out if there is a best match among the multiple alignments, or whether there are 2 or more equally good alignments (in which case
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4310 ### we boot the sequence pair altogether)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4311 elsif (scalar keys %alignments >= 2 and scalar keys %alignments <= 4){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4312 my $best_sum_of_alignment_scores;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4313 my $best_alignment_location;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4314 foreach my $alignment_location (sort {$alignments{$b}->{sum_of_alignment_scores} <=> $alignments{$a}->{sum_of_alignment_scores}} keys %alignments){
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 # warn "$alignments{$alignment_location}->{sum_of_alignment_scores}\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
4317
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4318 unless (defined $best_sum_of_alignment_scores){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4319 $best_sum_of_alignment_scores = $alignments{$alignment_location}->{sum_of_alignment_scores};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4320 $best_alignment_location = $alignment_location;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4321 # print "setting best alignment score to: $best_sum_of_alignment_scores\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4322 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4323 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4324 ### if the second best alignment has the same sum of alignment scores as the first one, the sequence pair will get booted
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4325 if ($alignments{$alignment_location}->{sum_of_alignment_scores} == $best_sum_of_alignment_scores){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4326 # warn "Same sum of alignment scores for 2 different alignments, the sequence pair will get booted!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4327 $sequence_pair_fails = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4328 last; # exiting since we know that the sequence has ambiguous alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4329 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4330 ### else we are going to store the best alignment for further processing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4331 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4332 $methylation_call_params->{$identifier}->{bowtie_sequence_1} = $alignments{$best_alignment_location}->{bowtie_sequence_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4333 $methylation_call_params->{$identifier}->{bowtie_sequence_2} = $alignments{$best_alignment_location}->{bowtie_sequence_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4334 $methylation_call_params->{$identifier}->{chromosome} = $alignments{$best_alignment_location}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4335 $methylation_call_params->{$identifier}->{position_1} = $alignments{$best_alignment_location}->{position_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4336 $methylation_call_params->{$identifier}->{position_2} = $alignments{$best_alignment_location}->{position_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4337 $methylation_call_params->{$identifier}->{index} = $alignments{$best_alignment_location}->{index};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4338 $methylation_call_params->{$identifier}->{alignment_score_1} = $alignments{$best_alignment_location}->{alignment_score_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4339 $methylation_call_params->{$identifier}->{alignment_score_2} = $alignments{$best_alignment_location}->{alignment_score_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4340 $methylation_call_params->{$identifier}->{sum_of_alignment_scores} = $alignments{$best_alignment_location}->{sum_of_alignment_scores};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4341 $methylation_call_params->{$identifier}->{mismatch_info_1} = $alignments{$best_alignment_location}->{mismatch_info_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4342 $methylation_call_params->{$identifier}->{mismatch_info_2} = $alignments{$best_alignment_location}->{mismatch_info_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4343 $methylation_call_params->{$identifier}->{CIGAR_1} = $alignments{$best_alignment_location}->{CIGAR_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4344 $methylation_call_params->{$identifier}->{CIGAR_2} = $alignments{$best_alignment_location}->{CIGAR_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4345 $methylation_call_params->{$identifier}->{flag_1} = $alignments{$best_alignment_location}->{flag_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4346 $methylation_call_params->{$identifier}->{flag_2} = $alignments{$best_alignment_location}->{flag_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4347
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4348 if (defined $alignments{$best_alignment_location}->{sum_of_alignment_scores_second_best} and ( $alignments{$best_alignment_location}->{sum_of_alignment_scores_second_best} > $alignments{$alignment_location}->{sum_of_alignment_scores} )) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4349 $methylation_call_params->{$identifier}->{sum_of_alignment_scores_second_best} = $alignments{$best_alignment_location}->{sum_of_alignment_scores_second_best};
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4352 $methylation_call_params->{$identifier}->{sum_of_alignment_scores_second_best} = $alignments{$alignment_location}->{sum_of_alignment_scores};
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 last; # exiting since the sequence produced a unique best alignment
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4358 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4361 die "There are too many potential hits for this sequence pair (1-4 expected, but found: '",scalar keys %alignments,"')\n";;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4362 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4363
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4364 ### skipping the sequence completely if there were multiple alignments with the same best sum of alignment scores at different positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4365 if ($sequence_pair_fails == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4366 $counting{unsuitable_sequence_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4367
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4368 ### report that the sequence has multiple hits with bitwise flag 256. We can print the sequence to the result file straight away and skip everything else
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4369 # my $ambiguous_read_1 = join("\t",$identifier.'/1','256','*','0','0','*','*','0','0',$sequence_1,$quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4370 # my $ambiguous_read_2 = join("\t",$identifier.'/2','256','*','0','0','*','*','0','0',$sequence_2,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4371 # warn "$ambiguous_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
4372 # warn "$ambiguous_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
4373
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4374 if ($ambiguous){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4375 return 2; # => exits to next sequence pair, and prints it out (in FastQ format) to _ambiguous_reads_1.txt and _ambiguous_reads_2.txt if '--ambiguous' was specified
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 elsif ($unmapped){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4378 return 1; # => exits to next sequence pair, and prints it out (in FastQ format) to _unmapped_reads_1.txt and _unmapped_reads_2.txt if '--unmapped' but not '--ambiguous' was specified
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4381 return 0; # => exits to next sequence pair (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4382 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4385 ### --DIRECTIONAL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4386 ### If the option --directional has been specified the user wants to consider only alignments to the original top strand or the original bottom strand. We will therefore
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4387 ### discard all alignments to strands complementary to the original strands, as they should not exist in reality due to the library preparation protocol
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4388 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4389 if ( ($methylation_call_params->{$identifier}->{index} == 1) or ($methylation_call_params->{$identifier}->{index} == 2) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4390 # warn "Alignment rejected! (index was: $methylation_call_params->{$identifier}->{index})\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4391 $counting{alignments_rejected_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4392 return 0;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4395
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4396 ### If the sequence pair has not been rejected so far it does have a unique best alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4397 $counting{unique_best_alignment_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4398 extract_corresponding_genomic_sequence_paired_ends_bowtie2($identifier,$methylation_call_params);
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 ### check to see if the genomic sequences we extracted has the same length as the observed sequences +2, and only then we perform the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4401 if (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence_1}) != length($sequence_1)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4402 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{position_1}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4403 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4404 return 0;
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 if (length($methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2}) != length($sequence_2)+2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4407 warn "Chromosomal sequence could not be extracted for\t$identifier\t$methylation_call_params->{$identifier}->{chromosome}\t$methylation_call_params->{$identifier}->{position_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4408 $counting{genomic_sequence_could_not_be_extracted_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4409 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4410 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4411
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4412 ### Compute MAPQ value
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4413 $methylation_call_params->{$identifier}->{mapq} = calc_mapq (length($sequence_1), length($sequence_2),
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4414 $methylation_call_params->{$identifier}->{sum_of_alignment_scores},
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4415 $methylation_call_params->{$identifier}->{sum_of_alignment_scores_second_best});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4416
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4417
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4418 ### now we are set to perform the actual methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4419 $methylation_call_params->{$identifier}->{methylation_call_1} = methylation_call($identifier,$sequence_1,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_1},$methylation_call_params->{$identifier}->{read_conversion_1});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4420 $methylation_call_params->{$identifier}->{methylation_call_2} = methylation_call($identifier,$sequence_2,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2},$methylation_call_params->{$identifier}->{read_conversion_2});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4421 # warn "$methylation_call_params->{$identifier}->{read_conversion_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4422 # warn " $sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4423 # warn "$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4424 # warn " $methylation_call_params->{$identifier}->{methylation_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
4425
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4426 print_bisulfite_mapping_results_paired_ends_bowtie2($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4427 return 0; ## otherwise 1 will be returned by default, which would print the sequence pair to unmapped_1 and _2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4428 }
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 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4431
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4432 # Compute MAPQ value for a read or read pair as in Bowtie2-2.2.2 (specifically, V2 of the MAPQ calculator: "class BowtieMapq2")
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4433 # assuming end-to-end alignment with the default calculation of the minimum alignment score
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 sub calc_mapq {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4436 my ($read1Len, $read2Len, $AS_best, $AS_secBest) = @_;
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 my $scMin = $score_min_intercept + $score_min_slope * $read1Len;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4439 ### read2Len is only defined for paired-end reads, so for single-end mode we can just a score min value 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
4440 if (defined $read2Len){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4441 $scMin += $score_min_intercept + $score_min_slope * $read2Len;
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 my $diff = abs$scMin; # scores can vary by up to this much (since max AS is 0 for end-to-end alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4445 my $bestOver = $AS_best - $scMin;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4446
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4447 if (!defined $AS_secBest) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4448 if ($bestOver >= $diff * 0.8) { return 42; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4449 elsif ($bestOver >= $diff * 0.7) { return 40; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4450 elsif ($bestOver >= $diff * 0.6) { return 24; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4451 elsif ($bestOver >= $diff * 0.5) { return 23; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4452 elsif ($bestOver >= $diff * 0.4) { return 8; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4453 elsif ($bestOver >= $diff * 0.3) { return 3; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4454 else { return 0; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4455 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4456 my $bestDiff = abs(abs($AS_best) - abs($AS_secBest));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4457 if ($bestDiff >= $diff * 0.9) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4458 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4459 return 39;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4460 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4461 return 33;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4462 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4463 } elsif ($bestDiff >= $diff * 0.8) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4464 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4465 return 38;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4466 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4467 return 27;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4468 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4469 } elsif ($bestDiff >= $diff * 0.7) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4470 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4471 return 37;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4472 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4473 return 26;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4474 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4475 } elsif ($bestDiff >= $diff * 0.6) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4476 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4477 return 36;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4478 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4479 return 22;
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 ($bestDiff >= $diff * 0.5) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4482 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4483 return 35;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4484 } elsif ($bestOver >= $diff * 0.84) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4485 return 25;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4486 } elsif ($bestOver >= $diff * 0.68) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4487 return 16;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4488 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4489 return 5;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4490 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4491 } elsif ($bestDiff >= $diff * 0.4) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4492 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4493 return 34;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4494 } elsif ($bestOver >= $diff * 0.84) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4495 return 21;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4496 } elsif ($bestOver >= $diff * 0.68) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4497 return 14;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4498 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4499 return 4;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4500 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4501 } elsif ($bestDiff >= $diff * 0.3) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4502 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4503 return 32;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4504 } elsif ($bestOver >= $diff * 0.88) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4505 return 18;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4506 } elsif ($bestOver >= $diff * 0.67) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4507 return 15;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4508 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4509 return 3;
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 } elsif ($bestDiff >= $diff * 0.2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4512 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4513 return 31;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4514 } elsif ($bestOver >= $diff * 0.88) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4515 return 17;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4516 } elsif ($bestOver >= $diff * 0.67) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4517 return 11;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4518 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4519 return 0;
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 } elsif ($bestDiff >= $diff * 0.1) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4522 if ($bestOver == $diff) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4523 return 30;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4524 } elsif ($bestOver >= $diff * 0.88) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4525 return 12;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4526 } elsif ($bestOver >= $diff * 0.67) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4527 return 7;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4528 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4529 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4530 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4531 } elsif ($bestDiff > 0) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4532 if ($bestOver >= $diff * 0.67) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4533 return 6;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4534 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4535 return 2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4536 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4537 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4538 if ($bestOver >= $diff * 0.67) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4539 return 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4540 } else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4541 return 0;
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4544 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4545 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4546
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4547
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4548 ###
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 sub decide_whether_paired_end_alignment_is_valid{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4551 my ($index,$identifier) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4552 my ($id_1,$strand_1,$mapped_chromosome_1,$position_1,$bowtie_sequence_1,$mismatch_info_1) = (split (/\t/,$fhs[$index]->{last_line_1},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4553 my ($id_2,$strand_2,$mapped_chromosome_2,$position_2,$bowtie_sequence_2,$mismatch_info_2) = (split (/\t/,$fhs[$index]->{last_line_2},-1))[0,1,2,3,4,7];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4554 chomp $mismatch_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4555 chomp $mismatch_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4556 my $seq_id_1 = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4557 my $seq_id_2 = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4558 $seq_id_1 =~ s/\/1$//; # removing the read /1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4559 $seq_id_2 =~ s/\/1$//; # removing the read /1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4560
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4561 ### ensuring that the current entry is the correct sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4562 if ($seq_id_1 eq $identifier or $seq_id_2 eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4563 ### checking the orientation of the alignment. We need to discriminate between 8 different conditions, however only 4 of them are theoretically
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4564 ### sensible alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4565 my $orientation = ensure_sensical_alignment_orientation_paired_ends ($index,$id_1,$strand_1,$id_2,$strand_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4566 ### If the orientation was correct can we move on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4567 if ($orientation == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4568 return 1; ### 1st possibility for A SEQUENCE-PAIR TO PASS
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 ### If the alignment was in the wrong orientation we need to read in two new lines
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4571 elsif($orientation == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4572 my $newline_1 = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4573 my $newline_2 = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4574 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4575 ### extract detailed information about the alignment again (from $newline_1 and $newline_2 this time)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4576 ($id_1,$strand_1) = (split (/\t/,$newline_1))[0,1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4577 ($id_2,$strand_2) = (split (/\t/,$newline_2))[0,1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4578
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4579 my $seqid;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4580 $seq_id_1 = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4581 $seq_id_2 = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4582 # we need to capture the first read (ending on /1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4583 if ($seq_id_1 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4584 $seqid = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4585 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4586 elsif ($seq_id_2 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4587 $seqid = $seq_id_2;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4590 die "One of the two reads needs to end on /1!!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4591 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4592
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4593 ### ensuring that the next entry is still the correct sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4594 if ($seq_id_1 eq $identifier or $seq_id_2 eq $identifier){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4595 ### checking orientation again
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4596 $orientation = ensure_sensical_alignment_orientation_paired_ends ($index,$id_1,$strand_1,$id_2,$strand_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4597 ### If the orientation was correct can we move on
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4598 if ($orientation == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4599 ### Writing the current sequence to last_line_1 and last_line_2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4600 $fhs[$index]->{last_seq_id} = $seqid;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4601 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4602 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4603 return 1; ### 2nd possibility for a SEQUENCE-PAIR TO PASS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4604 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4605 ### If the alignment was in the wrong orientation again we need to read in yet another 2 new lines and store them in @fhs (this must be
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4606 ### the next entry)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4607 elsif ($orientation == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4608 $newline_1 = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4609 $newline_2 = $fhs[$index]->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4610 if ($newline_1 and $newline_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4611 ($seq_id_1) = split (/\t/,$newline_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4612 ($seq_id_2) = split (/\t/,$newline_2);
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 $seqid = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4615 if ($seq_id_1 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4616 $seqid = $seq_id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4617 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4618 elsif ($seq_id_2 =~ s/\/1$//){ # removing the read /1 tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4619 $seqid = $seq_id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4620 }
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 "One of the two reads needs to end on /1!!";
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 ### check if the next 2 lines still have the same seq ID (must not happen), and if not overwrite the current seq-ID and bowtie output with
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4626 ### the same fields of the just read next entry
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4627 die "Same seq ID 3 or more times in a row!(should be 2 max)" if ($seqid eq $identifier);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4628 $fhs[$index]->{last_seq_id} = $seqid;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4629 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4630 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4631 return 0; # not processing anything this round as the alignment currently stored in last_line_1 and _2 was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4632 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4633 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4634 ### assigning undef to last_seq_id and last_line (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4635 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4636 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4637 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4638 return 0; # not processing anything as the alignment currently stored in last_line_1 and _2 was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4639 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4640 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4641 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4642 die "The orientation of the alignment must be either correct or incorrect\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4643 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4644 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4645 ### the sequence pair we just read in is already the next sequence pair to be analysed -> store it in @fhs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4646 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4647 $fhs[$index]->{last_seq_id} = $seqid;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4648 $fhs[$index]->{last_line_1} = $newline_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4649 $fhs[$index]->{last_line_2} = $newline_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4650 return 0; # processing the new alignment result only in the next round
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4651 }
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4654 # assigning undef to last_seq_id and both last_lines (end of bowtie output)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4655 $fhs[$index]->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4656 $fhs[$index]->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4657 $fhs[$index]->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4658 return 0; # not processing anything as the alignment currently stored in last_line_1 and _2 was in the wrong orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4659 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4660 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4661 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4662 die "The orientation of the alignment must be either correct or incorrect\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4663 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4664 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4665 ### the sequence pair stored in @fhs as last_line_1 and last_line_2 is already the next sequence pair to be analysed -> analyse next round
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4666 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4667 return 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4668 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4669 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4670
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4671 ### EXTRACT GENOMIC SEQUENCE | BOWTIE 1 | PAIRED-END
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 sub extract_corresponding_genomic_sequence_paired_ends {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4674 my ($sequence_identifier,$methylation_call_params) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4675 ### A bisulfite sequence pair for 1 location in the genome can theoretically be on any of the 4 possible converted strands. We are also giving the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4676 ### sequence a 'memory' of the conversion we are expecting which we will need later for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4677 my $alignment_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4678 my $alignment_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4679 my $read_conversion_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4680 my $read_conversion_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4681 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
4682
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4683 ### Now extracting the same sequence from the mouse genomic sequence, +2 extra bases at oone of the ends so that we can also make a CpG, CHG or CHH methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4684 ### if the C happens to be at the first or last position of the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4685 my $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4686 my $non_bisulfite_sequence_2;
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 ### all alignments reported by bowtie have the + alignment first and the - alignment as the second one irrespective of whether read 1 or read 2 was
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4689 ### the + alignment. We however always read in sequences read 1 then read 2, so if read 2 is the + alignment we need to swap the extracted genomic
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4690 ### sequences around!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4691 ### results from CT converted read 1 plus GA converted read 2 vs. CT converted genome (+/- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4692 if ($methylation_call_params->{$sequence_identifier}->{index} == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4693 ### [Index 0, sequence originated from (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4694 $counting{CT_GA_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4695 $alignment_read_1 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4696 $alignment_read_2 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4697 $read_conversion_info_1 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4698 $read_conversion_info_2 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4699 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4700 ### SEQUENCE 1 (this is always the forward hit, in this case it is read 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4701 ### for hits on the forward strand we need to capture 2 extra bases at the 3' end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4702
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4703 $non_bisulfite_sequence_1 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{start_seq_1},length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_1})+2); ##CHH change
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4704
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4705 ### SEQUENCE 2 (this will always be on the reverse strand, in this case it is read 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4706 ### As the second conversion is GA we need to capture 1 base 3', so that it is a 5' base after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4707 if (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) > $methylation_call_params->{$sequence_identifier}->{start_seq_2}+length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_2})+1){ ## CHH change to +1
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 $non_bisulfite_sequence_2 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_2}),length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_2})+2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4710 ### the reverse strand sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4711 $non_bisulfite_sequence_2 = reverse_complement($non_bisulfite_sequence_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4712 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4713 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4714 $non_bisulfite_sequence_2 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4715 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4716 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4717
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4718 ### results from GA converted read 1 plus CT converted read 2 vs. GA converted genome (+/- orientation alignments are reported only)
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_call_params->{$sequence_identifier}->{index} == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4720 ### [Index 1, sequence originated from complementary to (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4721 $counting{GA_CT_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4722 $alignment_read_1 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4723 $alignment_read_2 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4724 $read_conversion_info_1 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4725 $read_conversion_info_2 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4726 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4727
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4728 ### SEQUENCE 1 (this is always the forward hit, in this case it is read 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4729 ### as we need to make the methylation call for the base 5' of the first base (GA conversion!) we need to capture 2 extra bases at the 5' end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4730 if ($methylation_call_params->{$sequence_identifier}->{start_seq_1}-1 > 0){ ## CHH change to -1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4731 $non_bisulfite_sequence_1 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{start_seq_1}-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_1})+2); ### CHH change to -2/+2
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4734 $non_bisulfite_sequence_1 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4735 }
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 ### SEQUENCE 2 (this will always be on the reverse strand, in this case it is read 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4738 ### As we are doing a CT comparison for the reverse strand we are taking 2 bases extra at the 5' end, so it is a 3' base after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4739 $non_bisulfite_sequence_2 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_2})-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_2})+2); ### CHH change to -2/+2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4740 ### the reverse strand sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4741 $non_bisulfite_sequence_2 = reverse_complement($non_bisulfite_sequence_2);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4744 ### results from GA converted read 1 plus CT converted read 2 vs. CT converted genome (-/+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4745 elsif ($methylation_call_params->{$sequence_identifier}->{index} == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4746 ### [Index 2, sequence originated from the complementary to (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4747 $counting{GA_CT_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4748 $alignment_read_1 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4749 $alignment_read_2 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4750 $read_conversion_info_1 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4751 $read_conversion_info_2 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4752 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4753
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4754 ### Here we switch the sequence information round!! non_bisulfite_sequence_1 will later correspond to the read 1!!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4755 ### SEQUENCE 1 (this is always the forward hit, in this case it is READ 2), read 1 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
4756 ### As read 1 is GA converted we need to capture 2 extra 3' bases which will be 2 extra 5' base after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4757 $non_bisulfite_sequence_1 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_2}),length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_2})+2); ### CHH change to +2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4758 ### the reverse strand sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4759 $non_bisulfite_sequence_1 = reverse_complement($non_bisulfite_sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4760
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4761 ### SEQUENCE 2 (this will always be on the reverse strand, in this case it is READ 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4762 ### non_bisulfite_sequence_2 will later correspond to the read 2!!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4763 ### Read 2 is CT converted so we need to capture 2 extra 3' bases
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4764 if (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) > ($methylation_call_params->{$sequence_identifier}->{start_seq_1})+length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_1})+1){ ## CHH change to +1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4765 $non_bisulfite_sequence_2 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_1}),length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_1})+2); ## CHH changed from +1 to +2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4766 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4767 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4768 $non_bisulfite_sequence_2 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4770 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4771
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4772 ### results from CT converted read 1 plus GA converted read 2 vs. GA converted genome (-/+ orientation alignments are reported only)
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_call_params->{$sequence_identifier}->{index} == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4774 ### [Index 3, sequence originated from the (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4775 $counting{CT_GA_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4776 $alignment_read_1 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4777 $alignment_read_2 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4778 $read_conversion_info_1 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4779 $read_conversion_info_2 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4780 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4781
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4782 ### Here we switch the sequence information round!! non_bisulfite_sequence_1 will later correspond to the read 1!!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4783 ### SEQUENCE 1 (this is always the forward hit, in this case it is READ 2), read 1 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
4784 ### As read 1 is CT converted we need to capture 2 extra 5' bases which will be 2 extra 3' base after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4785 if ( ($methylation_call_params->{$sequence_identifier}->{start_seq_2}-1) > 0){ ## CHH changed to -1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4786 $non_bisulfite_sequence_1 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_2})-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_2})+2); ### CHH changed to -2/+2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4787 ### the reverse strand sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4788 $non_bisulfite_sequence_1 = reverse_complement($non_bisulfite_sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4789 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4790 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4791 $non_bisulfite_sequence_1 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4792 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4793
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4794 ### SEQUENCE 2 (this will always be on the reverse strand, in this case it is READ 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4795 ### non_bisulfite_sequence_2 will later correspond to the read 2!!!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4796 ### Read 2 is GA converted so we need to capture 2 extra 5' bases
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4797 $non_bisulfite_sequence_2 = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},($methylation_call_params->{$sequence_identifier}->{start_seq_1})-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence_1})+2); ### CHH changed to -2/+2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4798 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4799 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4800 die "Too many bowtie result filehandles\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4801 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4802 ### the alignment_strand information is needed to determine which strand of the genomic sequence we are comparing the read against,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4803 ### the read_conversion information is needed to know whether we are looking for C->T or G->A substitutions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4804
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4805 $methylation_call_params->{$sequence_identifier}->{alignment_read_1} = $alignment_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4806 $methylation_call_params->{$sequence_identifier}->{alignment_read_2} = $alignment_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4807 $methylation_call_params->{$sequence_identifier}->{genome_conversion} = $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4808 $methylation_call_params->{$sequence_identifier}->{read_conversion_1} = $read_conversion_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4809 $methylation_call_params->{$sequence_identifier}->{read_conversion_2} = $read_conversion_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4810 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4811 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_2} = $non_bisulfite_sequence_2;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4814 ### EXTRACT GENOMIC SEQUENCE BOWTIE 2 | PAIRED-END
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4815
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4816 sub extract_corresponding_genomic_sequence_paired_ends_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4817 my ($sequence_identifier,$methylation_call_params) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4818 ### A bisulfite sequence pair for 1 location in the genome can theoretically be on any of the 4 possible converted strands. We are also giving the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4819 ### sequence a 'memory' of the conversion we are expecting which we will need later for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4820
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4821 my $cigar_1 = $methylation_call_params->{$sequence_identifier}->{CIGAR_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4822 my $cigar_2 = $methylation_call_params->{$sequence_identifier}->{CIGAR_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4823 my $flag_1 = $methylation_call_params->{$sequence_identifier}->{flag_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4824 my $flag_2 = $methylation_call_params->{$sequence_identifier}->{flag_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4825
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4826 my $contains_deletion_1 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4827 my $contains_deletion_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4828 if ($cigar_1 =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4829 $contains_deletion_1 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4830 if ($verbose){ warn "$cigar_1\n$methylation_call_params->{$sequence_identifier}->{mismatch_info_1}\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4831 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4832 if ($cigar_2 =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4833 $contains_deletion_2 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4834 if ($verbose){ warn "$cigar_2\n$methylation_call_params->{$sequence_identifier}->{mismatch_info_2}\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4835 }
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 # warn "$cigar_1\t$cigar_2\t$flag_1\t$flag_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4838 ### We are now extracting the corresponding genomic sequence, +2 extra bases at the end (or start) so that we can also make a CpG methylation call and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4839 ### in addition make differential calls for Cs in CHG or CHH context if the C happens to be at the last (or first) position of the actually observed sequence
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 ### the alignment_strand information is needed to determine which strand of the genomic sequence we are comparing the read against,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4842 ### the read_conversion information is needed to know whether we are looking for C->T or G->A substitutions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4843 my $alignment_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4844 my $alignment_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4845 my $read_conversion_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4846 my $read_conversion_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4847 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
4848
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4849 ### Now extracting the same sequence from the mouse genomic sequence, +2 extra bases at one of the ends so that we can also make a CpG, CHG or CHH methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4850 ### if the C happens to be at the last position of the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4851 my $non_bisulfite_sequence_1 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4852 my $non_bisulfite_sequence_2 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4853 my $genomic_seq_for_MD_tag_1 = ''; # this sequence contains potential deletions in the genome as well so that we can generate a proper MD tag for the SAM output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4854 my $genomic_seq_for_MD_tag_2 = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4855
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4856 ### Positions in SAM format are 1 based, so we need to subract 1 when getting substrings
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4857 my $pos_1 = $methylation_call_params->{$sequence_identifier}->{position_1}-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4858 my $pos_2 = $methylation_call_params->{$sequence_identifier}->{position_2}-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4859
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4860 # parsing CIGAR 1 string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4861 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
4862 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
4863 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
4864 die "CIGAR 1 string contained a non-matching number of lengths and operations\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
4865 # parsing CIGAR 2 string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4866 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
4867 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
4868 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
4869 die "CIGAR 2 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
4870
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4871 my $indels_1 = 0; # adding these to the hemming distance value (needed for the NM field in the final SAM output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4872 my $indels_2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4873
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4874 ### Extracting read 1 genomic sequence ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4875
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4876 # extracting 2 additional bp at the 5' 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
4877 if ( ($methylation_call_params->{$sequence_identifier}->{index} == 1) or ($methylation_call_params->{$sequence_identifier}->{index} == 3) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4878 # checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4879 unless ( ($pos_1-2) > 0){# exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4880 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4881 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag_1} = $genomic_seq_for_MD_tag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4882 return;
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 $non_bisulfite_sequence_1 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_1-2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4885 }
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 foreach (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
4888 if ($ops_1[$_] eq 'M'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4889 # extracting genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4890 $non_bisulfite_sequence_1 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_1,$len_1[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4891 if ($contains_deletion_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4892 $genomic_seq_for_MD_tag_1 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_1,$len_1[$_]);
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 # warn "$non_bisulfite_sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4895 # adjusting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4896 $pos_1 += $len_1[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4897 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4898 elsif ($ops_1[$_] 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
4899 # we simply add padding Xs instead of finding genomic sequence. This will not be used to infer methylation calls, and we can later ignore it for the generation of the MD;Z: tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4900 $non_bisulfite_sequence_1 .= 'X' x $len_1[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4901 if ($contains_deletion_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4902 $genomic_seq_for_MD_tag_1 .= 'X' x $len_1[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4903 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4904 # warn "$non_bisulfite_sequence_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4905 # position doesn't need adjusting
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4906
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4907 ### 03 06 2014: In fact we don't need to add anything to the hemming distance for insertions since we use padding Xs which will fail a base by base comparison in hemming_dist()
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4908 # indels_1 += $len_1[$_]; # adding to $indels_1 to determine the hemming distance (= single base mismatches, insertions or deletions) for the SAM output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4909 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4910 elsif ($ops_1[$_] 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
4911 # we do not add any genomic sequence but only adjust the position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4912 # we do however need to add the genomic sequence to $genomic_seq_for_MD-tag so we can create a proper MD tag later
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4913 if ($contains_deletion_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4914 $genomic_seq_for_MD_tag_1 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_1,$len_1[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4915 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4916 # warn "Just adjusting the position by: ",$len_1[$_],"bp\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4917 $pos_1 += $len_1[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4918 $indels_1 += $len_1[$_]; # adding to $indels_1 to determine the hemming distance (= single base mismatches, insertions or deletions) for the SAM output
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 elsif($cigar_1 =~ tr/[NSHPX=]//){ # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4921 die "The CIGAR 1 string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $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
4922 }
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 die "The CIGAR 1 string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $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
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4928 ### 3' end of read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4929 if ( ($methylation_call_params->{$sequence_identifier}->{index} == 0) or ($methylation_call_params->{$sequence_identifier}->{index} == 2) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4930 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4931 unless (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) >= $pos_1+2){# exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4932 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4933 return;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4936 $non_bisulfite_sequence_1 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_1,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4937 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4940 ### Extracting read 2 genomic sequence ###
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 ### 5' end of read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4943 if ( ($methylation_call_params->{$sequence_identifier}->{index} == 1) or ($methylation_call_params->{$sequence_identifier}->{index} == 3) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4944 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4945 unless ( ($pos_2-2) >= 0){# exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4946 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4947 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_2} = $non_bisulfite_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4948 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag_2} = $genomic_seq_for_MD_tag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4949 return;
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 $non_bisulfite_sequence_2 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_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
4952 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4953
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4954 foreach (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
4955 if ($ops_2[$_] eq 'M'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4956 # extracting genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4957 $non_bisulfite_sequence_2 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_2,$len_2[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4958 if ($contains_deletion_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4959 $genomic_seq_for_MD_tag_2 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_2,$len_2[$_]);
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 # warn "$non_bisulfite_sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4962 # adjusting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4963 $pos_2 += $len_2[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4964 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4965 elsif ($ops_2[$_] 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
4966 # we simply add padding Xs instead of finding genomic sequence. This will not be used to infer methylation calls and we can ignore this later during the generation of the MD:Z: tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4967 $non_bisulfite_sequence_2 .= 'X' x $len_2[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4968 if ($contains_deletion_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4969 $genomic_seq_for_MD_tag_2 .= 'X' x $len_2[$_];
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 # warn "$non_bisulfite_sequence_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4972 # position doesn't need adjusting
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4973
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4974 ### 03 06 2014: In fact we don't need to add anything to the hemming distance for insertions since we use padding Xs which will fail a base by base comparison in hemming_dist()
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4975 # $indels_2 += $len_2[$_]; # adding to $indels_1 to determine the hemming distance (= single base mismatches, insertions or deletions) for the SAM output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4976 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4977 elsif ($ops_2[$_] 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
4978 # we do not add any genomic sequence but only adjust the position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4979 # we do however need to add the genomic sequence to $genomic_seq_for_MD-tag so we can create a proper MD tag later
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4980 if ($contains_deletion_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4981 $genomic_seq_for_MD_tag_2 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_2,$len_2[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4982 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4983 # warn "Just adjusting the position by: ",$len_2[$_],"bp\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4984 $pos_2 += $len_2[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4985 $indels_2 += $len_2[$_]; # adding to $indels_1 to determine the hemming distance (= single base mismatches, insertions or deletions) for the SAM output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4986 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4987 elsif($cigar_2 =~ tr/[NSHPX=]//){ # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4988 die "The CIGAR 2 string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $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
4989 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4990 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4991 die "The CIGAR 2 string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $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
4992 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4993 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4994
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4995 ### 3' end of read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4996 if ( ($methylation_call_params->{$sequence_identifier}->{index} == 0) or ($methylation_call_params->{$sequence_identifier}->{index} == 2) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4997 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4998 unless (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) >= $pos_2+2){# exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
4999 # need to set read 1 as well now to prevent warning
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5000 # warn "'$non_bisulfite_sequence_1'\n'$non_bisulfite_sequence_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
5001 # sleep(5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5002 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5003 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_2} = $non_bisulfite_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5004 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5005 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5006 $non_bisulfite_sequence_2 .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos_2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5007 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5008
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5009 ### all paired-end alignments reported by Bowtie 2 have the Read 1 alignment first and the Read 2 alignment as the second one irrespective of whether read 1 or read 2 was
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5010 ### the + alignment. We also read in sequences read 1 then read 2 so they should correspond perfectly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5012 ### results from CT converted read 1 plus GA converted read 2 vs. CT converted genome (+/- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5013 if ($methylation_call_params->{$sequence_identifier}->{index} == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5014 ### [Index 0, sequence originated from (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5015 $counting{CT_GA_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5016 $alignment_read_1 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5017 $alignment_read_2 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5018 $read_conversion_info_1 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5019 $read_conversion_info_2 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5020 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5021 ### Read 1 is always the forward hit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5022 ### Read 2 is will always on the reverse strand, so it needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5023 $non_bisulfite_sequence_2 = reverse_complement($non_bisulfite_sequence_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5024 if ($contains_deletion_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5025 $genomic_seq_for_MD_tag_2 = reverse_complement($genomic_seq_for_MD_tag_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5026 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5029 ### results from GA converted read 1 plus CT converted read 2 vs. GA converted genome (+/- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5030 elsif ($methylation_call_params->{$sequence_identifier}->{index} == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5031 ### [Index 1, sequence originated from complementary to (converted) bottom strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5032 $counting{GA_CT_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5033 $alignment_read_1 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5034 $alignment_read_2 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5035 $read_conversion_info_1 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5036 $read_conversion_info_2 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5037 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5038 ### Read 1 is always the forward hit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5039 ### Read 2 is will always on the reverse strand, so it needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5040 $non_bisulfite_sequence_2 = reverse_complement($non_bisulfite_sequence_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5041 if ($contains_deletion_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5042 $genomic_seq_for_MD_tag_2 = reverse_complement($genomic_seq_for_MD_tag_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5043 }
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 ### results from GA converted read 1 plus CT converted read 2 vs. CT converted genome (-/+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5047 elsif ($methylation_call_params->{$sequence_identifier}->{index} == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5048 ### [Index 2, sequence originated from the complementary to (converted) top strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5049 $counting{GA_CT_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5050 $alignment_read_1 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5051 $alignment_read_2 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5052 $read_conversion_info_1 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5053 $read_conversion_info_2 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5054 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5055
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5056 ### Read 1 (the reverse strand) genomic sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5057 $non_bisulfite_sequence_1 = reverse_complement($non_bisulfite_sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5058 if ($contains_deletion_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5059 $genomic_seq_for_MD_tag_1 = reverse_complement($genomic_seq_for_MD_tag_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5060 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5061 }
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 ### results from CT converted read 1 plus GA converted read 2 vs. GA converted genome (-/+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5064 elsif ($methylation_call_params->{$sequence_identifier}->{index} == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5065 ### [Index 3, sequence originated from the (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5066 $counting{CT_GA_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5067 $alignment_read_1 = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5068 $alignment_read_2 = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5069 $read_conversion_info_1 = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5070 $read_conversion_info_2 = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5071 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5072 ### Read 1 (the reverse strand) genomic sequence needs to be reverse complemented
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5073 $non_bisulfite_sequence_1 = reverse_complement($non_bisulfite_sequence_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5074 if ($contains_deletion_1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5075 $genomic_seq_for_MD_tag_1 = reverse_complement($genomic_seq_for_MD_tag_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5076 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5077 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5078 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5079 die "Too many bowtie result filehandles\n";
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 ### the alignment_strand information is needed to determine which strand of the genomic sequence we are comparing the read against,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5082 ### the read_conversion information is needed to know whether we are looking for C->T or G->A substitutions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5083
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5084 $methylation_call_params->{$sequence_identifier}->{alignment_read_1} = $alignment_read_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5085 $methylation_call_params->{$sequence_identifier}->{alignment_read_2} = $alignment_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5086 $methylation_call_params->{$sequence_identifier}->{genome_conversion} = $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5087 $methylation_call_params->{$sequence_identifier}->{read_conversion_1} = $read_conversion_info_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5088 $methylation_call_params->{$sequence_identifier}->{read_conversion_2} = $read_conversion_info_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5089 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_1} = $non_bisulfite_sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5090 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence_2} = $non_bisulfite_sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5091 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag_1} = $genomic_seq_for_MD_tag_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5092 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag_2} = $genomic_seq_for_MD_tag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5093
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5094 ## the end position of a read is stored in $pos
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5095 $methylation_call_params->{$sequence_identifier}->{end_position_1} = $pos_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5096 $methylation_call_params->{$sequence_identifier}->{end_position_2} = $pos_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5097 $methylation_call_params->{$sequence_identifier}->{indels_1} = $indels_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5098 $methylation_call_params->{$sequence_identifier}->{indels_2} = $indels_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5101 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5102 ### PRINT SINGLE END RESULTS: Bowtie 1 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5103 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5104
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5105 sub print_bisulfite_mapping_result_single_end{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5106 my ($identifier,$sequence,$methylation_call_params,$quality_value)= @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5107
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5108 ### we will output the FastQ quality in Sanger encoding (Phred 33 scale)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5109 if ($phred64){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5110 $quality_value = convert_phred64_quals_to_phred33($quality_value);
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 elsif ($solexa){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5113 $quality_value = convert_solexa_quals_to_phred33($quality_value);
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5116 ### We will add +1 bp to the starting position of single-end reads, as Bowtie 1 reports the index and not the bp position.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5117 $methylation_call_params->{$identifier}->{position} += 1;
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 ### writing every uniquely mapped read and its methylation call to the output file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5120 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5121 my $bowtie1_output = join("\t",$identifier,$methylation_call_params->{$identifier}->{alignment_strand},$methylation_call_params->{$identifier}->{chromosome},$methylation_call_params->{$identifier}->{position},$methylation_call_params->{$identifier}->{end_position},$sequence,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence},$methylation_call_params->{$identifier}->{methylation_call},$methylation_call_params->{$identifier}->{read_conversion},$methylation_call_params->{$identifier}->{genome_conversion},$quality_value);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5122 print OUT "$bowtie1_output\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5124 else{ # SAM output, default since Bismark v1.0.0
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5125 single_end_SAM_output($identifier,$sequence,$methylation_call_params,$quality_value); # at the end of the script
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5126 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5129 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5130 ### PRINT SINGLE END RESULTS: Bowtie 2 ###
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5133 sub print_bisulfite_mapping_result_single_end_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5134 my ($identifier,$sequence,$methylation_call_params,$quality_value)= @_;
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 ### we will output the FastQ quality in Sanger encoding (Phred 33 scale)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5137 if ($phred64){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5138 $quality_value = convert_phred64_quals_to_phred33($quality_value);
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 elsif ($solexa){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5141 $quality_value = convert_solexa_quals_to_phred33($quality_value);
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 ### writing every mapped read and its methylation call to the SAM output file (unmapped and ambiguous reads were already printed)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5145 single_end_SAM_output($identifier,$sequence,$methylation_call_params,$quality_value); # at the end of the script
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5146 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5147
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5148 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5149 ### PRINT PAIRED END ESULTS: Bowtie 1 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5150 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5151
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5152 sub print_bisulfite_mapping_results_paired_ends{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5153 my ($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2)= @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5154
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5155 ### we will output the FastQ quality in Sanger encoding (Phred 33 scale)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5156 if ($phred64){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5157 $quality_value_1 = convert_phred64_quals_to_phred33($quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5158 $quality_value_2 = convert_phred64_quals_to_phred33($quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5159 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5160 elsif ($solexa){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5161 $quality_value_1 = convert_solexa_quals_to_phred33($quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5162 $quality_value_2 = convert_solexa_quals_to_phred33($quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5163 }
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 ### We will add +1 bp to the start position of paired-end reads, as Bowtie 1 reports the index and not the bp position. (End position is already 1-based)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5166 $methylation_call_params->{$identifier}->{start_seq_1} += 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5167
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5168 ### writing every single aligned read and its methylation call to the output file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5169 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5170 my $bowtie1_output_paired_end = join("\t",$identifier,$methylation_call_params->{$identifier}->{alignment_read_1},$methylation_call_params->{$identifier}->{chromosome},$methylation_call_params->{$identifier}->{start_seq_1},$methylation_call_params->{$identifier}->{alignment_end},$sequence_1,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_1},$methylation_call_params->{$identifier}->{methylation_call_1},$sequence_2,$methylation_call_params->{$identifier}->{unmodified_genomic_sequence_2},$methylation_call_params->{$identifier}->{methylation_call_2},$methylation_call_params->{$identifier}->{read_conversion_1},$methylation_call_params->{$identifier}->{genome_conversion},$quality_value_1,$quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5171 print OUT "$bowtie1_output_paired_end\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5172 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5173 else{ # SAM output, default since Bismark v1.0.0
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5174 paired_end_SAM_output($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2); # at the end of the script
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5177 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5178
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 ### PRINT PAIRED END ESULTS: Bowtie 2 ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5181 ##########################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5182
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5183 sub print_bisulfite_mapping_results_paired_ends_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5184 my ($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2)= @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5185
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5186 ### we will output the FastQ quality in Sanger encoding (Phred 33 scale)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5187 if ($phred64){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5188 $quality_value_1 = convert_phred64_quals_to_phred33($quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5189 $quality_value_2 = convert_phred64_quals_to_phred33($quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5190 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5191 elsif ($solexa){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5192 $quality_value_1 = convert_solexa_quals_to_phred33($quality_value_1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5193 $quality_value_2 = convert_solexa_quals_to_phred33($quality_value_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5194 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5195
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5196 ### writing every single aligned read and its methylation call to the output file (unmapped and ambiguous reads were already printed)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5197 paired_end_SAM_output($identifier,$sequence_1,$sequence_2,$methylation_call_params,$quality_value_1,$quality_value_2); # at the end of the script
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5198
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5199 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5200
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 sub convert_phred64_quals_to_phred33{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5203
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5204 my $qual = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5205 my @quals = split (//,$qual);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5206 my @new_quals;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5207
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5208 foreach my $index (0..$#quals){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5209 my $phred_score = convert_phred64_quality_string_into_phred_score ($quals[$index]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5210 my $phred33_quality_string = convert_phred_score_into_phred33_quality_string ($phred_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5211 $new_quals[$index] = $phred33_quality_string;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5212 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5213
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5214 my $phred33_quality = join ("",@new_quals);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5215 return $phred33_quality;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5216 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5217
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5218 sub convert_solexa_quals_to_phred33{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5219
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5220 my $qual = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5221 my @quals = split (//,$qual);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5222 my @new_quals;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5223
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5224 foreach my $index (0..$#quals){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5225 my $phred_score = convert_solexa_pre1_3_quality_string_into_phred_score ($quals[$index]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5226 my $phred33_quality_string = convert_phred_score_into_phred33_quality_string ($phred_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5227 $new_quals[$index] = $phred33_quality_string;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5228 }
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 my $phred33_quality = join ("",@new_quals);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5231 return $phred33_quality;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5232 }
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 sub convert_phred_score_into_phred33_quality_string{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5235 my $qual = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5236 $qual = chr($qual+33);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5237 return $qual;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5238 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5239
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5240 sub convert_phred64_quality_string_into_phred_score{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5241 my $string = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5242 my $qual = ord($string)-64;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5243 return $qual;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5246 sub convert_solexa_pre1_3_quality_string_into_phred_score{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5247 ### We will just use 59 as the offset here as all Phred Scores between 10 and 40 look exactly the same, there is only a minute difference for values between 0 and 10
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5248 my $string = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5249 my $qual = ord($string)-59;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5250 return $qual;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5251 }
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 sub extract_corresponding_genomic_sequence_single_end {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5255 my ($sequence_identifier,$methylation_call_params) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5256 ### A bisulfite sequence for 1 location in the genome can theoretically be any of the 4 possible converted strands. We are also giving the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5257 ### sequence a 'memory' of the conversion we are expecting which we will need later for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5258
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5259 ### the alignment_strand information is needed to determine which strand of the genomic sequence we are comparing the read against,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5260 ### the read_conversion information is needed to know whether we are looking for C->T or G->A substitutions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5261 my $alignment_strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5262 my $read_conversion_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5263 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
5264 ### Also extracting the corresponding genomic sequence, +2 extra bases at the end so that we can also make a CpG methylation call and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5265 ### in addition make differential calls for Cs non-CpG context, which will now be divided into CHG and CHH methylation,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5266 ### if the C happens to be at the last position of the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5267 my $non_bisulfite_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5268 ### depending on the conversion we want to make need to capture 1 extra base at the 3' end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5269
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5270 my $pbat_index_modifier = 0;
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 if ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5273 $pbat_index_modifier += 2; # (we are simply not running indexes 0 or 1!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5274 }
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 ### results from CT converted read vs. CT converted genome (+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5277 if ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5278 ### [Index 0, sequence originated from (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5279 $counting{CT_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5280 $alignment_strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5281 $read_conversion_info = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5282 $genome_conversion = 'CT';
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 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5285 if (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) > $methylation_call_params->{$sequence_identifier}->{position}+length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+1){ ## CHH changed to +1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5286 ### + 2 extra base at the 3' end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5287 $non_bisulfite_sequence = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{position},length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+2); ## CHH changed to +2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5288 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5289 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5290 $non_bisulfite_sequence = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5291 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5292 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5293
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5294 ### results from CT converted reads vs. GA converted genome (- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5295 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5296 ### [Index 1, sequence originated from (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5297 $counting{CT_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5298 $alignment_strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5299 $read_conversion_info = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5300 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5301
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5302 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5303 if ($methylation_call_params->{$sequence_identifier}->{position}-2 >= 0){ ## CHH changed to -2 # 02 02 2012 Changed this to >= from >
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5304 ### Extracting 2 extra 5' bases on forward strand which will become 2 extra 3' bases after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5305 $non_bisulfite_sequence = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{position}-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+2); ## CHH changed to -2/+2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5306 ## reverse complement!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5307 $non_bisulfite_sequence = reverse_complement($non_bisulfite_sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5308 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5309 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5310 $non_bisulfite_sequence = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5311 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5312 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5313
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5314 ### results from GA converted reads vs. CT converted genome (- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5315 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5316 ### [Index 2, sequence originated from complementary to (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5317 $counting{GA_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5318 $alignment_strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5319 $read_conversion_info = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5320 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5321
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5322 ### +2 extra bases on the forward strand 3', which will become 2 extra 5' bases after reverse complementation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5323 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5324 if (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) > $methylation_call_params->{$sequence_identifier}->{position}+length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+1){ ## changed to +1 on 02 02 2012
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5325 $non_bisulfite_sequence = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{position},length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+2); ## CHH changed to +2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5326 ## reverse complement!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5327 $non_bisulfite_sequence = reverse_complement($non_bisulfite_sequence);
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5330 $non_bisulfite_sequence = '';
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5334 ### results from GA converted reads vs. GA converted genome (+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5335 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5336 ### [Index 3, sequence originated from complementary to (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5337 $counting{GA_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5338 $alignment_strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5339 $read_conversion_info = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5340 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5341
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5342 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5343 if ($methylation_call_params->{$sequence_identifier}->{position}-2 >= 0){ ## CHH changed to +2 # 02 02 2012 Changed this to >= from >
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5344 ### +2 extra base at the 5' end as we are nominally checking the converted reverse strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5345 $non_bisulfite_sequence = substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$methylation_call_params->{$sequence_identifier}->{position}-2,length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence})+2); ## CHH changed to -2/+2
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5348 $non_bisulfite_sequence = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5349 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5352 die "Too many bowtie result filehandles\n";
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 $methylation_call_params->{$sequence_identifier}->{alignment_strand} = $alignment_strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5356 $methylation_call_params->{$sequence_identifier}->{read_conversion} = $read_conversion_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5357 $methylation_call_params->{$sequence_identifier}->{genome_conversion} = $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5358 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence} = $non_bisulfite_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5359
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5360 ### at this point we can also determine the end position of a read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5361 $methylation_call_params->{$sequence_identifier}->{end_position} = $methylation_call_params->{$sequence_identifier}->{position}+length($methylation_call_params->{$sequence_identifier}->{bowtie_sequence});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5362 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5363
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 sub extract_corresponding_genomic_sequence_single_end_bowtie2{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5366 my ($sequence_identifier,$methylation_call_params) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5367
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5368 my $MD_tag = $methylation_call_params->{$sequence_identifier}->{MD_tag};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5369 my $cigar = $methylation_call_params->{$sequence_identifier}->{CIGAR};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5370
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5371 my $contains_deletion = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5372 if ($cigar =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5373 $contains_deletion = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5374 # warn "$cigar\n$MD_tag\n";
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 ### A bisulfite sequence for 1 location in the genome can theoretically be any of the 4 possible converted strands. We are also giving the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5377 ### sequence a 'memory' of the conversion we are expecting which we will need later for the methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5378
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5379 ### the alignment_strand information is needed to determine which strand of the genomic sequence we are comparing the read against,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5380 ### the read_conversion information is needed to know whether we are looking for C->T or G->A substitutions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5381 my $alignment_strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5382 my $read_conversion_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5383 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
5384
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5385 ### We are now extracting the corresponding genomic sequence, +2 extra bases at the end (or start) so that we can also make a CpG methylation call and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5386 ### in addition make differential calls for Cs in CHG or CHH context if the C happens to be at the last (or first) position of the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5387 my $non_bisulfite_sequence = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5388 my $genomic_seq_for_MD_tag = ''; # this sequence contains potential deletions in the genome as well so that we can generate a proper MD tag for the SAM output
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 ### Positions in SAM format are 1 based, so we need to subract 1 when getting substrings
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5391 my $pos = $methylation_call_params->{$sequence_identifier}->{position}-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5392
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5393 # 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
5394 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
5395 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
5396 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
5397 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
5398
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5399 my $pbat_index_modifier = 0;
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 if ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5402 $pbat_index_modifier += 2; # (we are simply not running indexes 0 or 1!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5403 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5404
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5405 ### If the sequence aligns best as CT converted reads vs. GA converted genome (OB, index 1) or GA converted reads vs. GA converted genome (CTOB, index 3)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5406 if ( (($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 1) or (($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 3) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5407 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5408 unless ( ($pos-2) >= 0){ # exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5409 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence} = $non_bisulfite_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5410 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag} = $genomic_seq_for_MD_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5411 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5412 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5413 $non_bisulfite_sequence .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos-2,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5414 }
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 my $indels = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5417
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5418 foreach (0..$#len){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5419 if ($ops[$_] eq 'M'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5420 #extracting genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5421 $non_bisulfite_sequence .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos,$len[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5422 if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5423 $genomic_seq_for_MD_tag .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos,$len[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5424 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5425 # adjusting position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5426 $pos += $len[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5427 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5428 elsif ($ops[$_] 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
5429 # we simply add padding Xs instead of finding genomic sequence. This will not be used to infer methylation calls and we can later ignore it better during the generation of the MD:Z-tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5430 $non_bisulfite_sequence .= 'X' x $len[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5431 if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5432 $genomic_seq_for_MD_tag .= 'X' x $len[$_];
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 # warn "$non_bisulfite_sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5435 # position doesn't need to be adjusting
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5436
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5437 ### 03 06 2014: In fact we don't need to add anything to the hemming distance for insertions since we use padding Xs which will fail the base by base comparison in hemming_dist()
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5438 # $indels += $len[$_]; # adding this to $indels so we can determine the hemming distance for the SAM output (= single-base substitutions (mismatches, insertions, deletions)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5439 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5440 elsif ($ops[$_] 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
5441 # we do not add any genomic sequence but only adjust the position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5442
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5443 # we do however add the genomic sequence to the $genomic_sequence for MD-tag determination if the CIGAR string contained a deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5444 if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5445 $genomic_seq_for_MD_tag .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos,$len[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5446 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5447 $pos += $len[$_];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5448 $indels += $len[$_]; # adding this to $indels so we can determine the hemming distance for the SAM output (= single-base substitutions (mismatches, insertions, deletions)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5449 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5450 elsif($cigar =~ tr/[NSHPX=]//){ # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5451 die "The CIGAR string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5452 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5453 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5454 die "The CIGAR string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $cigar\n";
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5457
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5458 ### If the sequence aligns best as CT converted reads vs. CT converted genome (OT, index 0) or GA converted reads vs. CT converted genome (CTOT, index 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5459 if ( ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 0) or ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 2) ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5460 ## checking if the substring will be valid or if we can't extract the sequence because we are right at the edge of a chromosome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5461 unless (length($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}}) >= $pos+2){ # exiting with en empty genomic sequence otherwise
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5462 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence} = $non_bisulfite_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5463 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag} = $genomic_seq_for_MD_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5464 return;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5465 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5466 $non_bisulfite_sequence .= substr ($chromosomes{$methylation_call_params->{$sequence_identifier}->{chromosome}},$pos,2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5467 # print "$methylation_call_params->{$sequence_identifier}->{bowtie_sequence}\n$non_bisulfite_sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5468 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5469
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 ### results from CT converted read vs. CT converted genome (+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5472 if ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5473 ### [Index 0, sequence originated from (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5474 $counting{CT_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5475 $alignment_strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5476 $read_conversion_info = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5477 $genome_conversion = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5478 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5479
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5480 ### results from CT converted reads vs. GA converted genome (- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5481 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5482 ### [Index 1, sequence originated from (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5483 $counting{CT_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5484 $alignment_strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5485 $read_conversion_info = 'CT';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5486 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5487
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5488 ### reverse complement!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5489 $non_bisulfite_sequence = reverse_complement($non_bisulfite_sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5490 if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5491 $genomic_seq_for_MD_tag = reverse_complement($genomic_seq_for_MD_tag);
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5494
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5495 ### results from GA converted reads vs. CT converted genome (- orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5496 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5497 ### [Index 2, sequence originated from complementary to (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5498 $counting{GA_CT_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5499 $alignment_strand = '-';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5500 $read_conversion_info = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5501 $genome_conversion = 'CT';
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 ### reverse complement!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5504 $non_bisulfite_sequence = reverse_complement($non_bisulfite_sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5505 if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5506 $genomic_seq_for_MD_tag = reverse_complement($genomic_seq_for_MD_tag);
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5509
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5510 ### results from GA converted reads vs. GA converted genome (+ orientation alignments are reported only)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5511 elsif ( ($methylation_call_params->{$sequence_identifier}->{index} + $pbat_index_modifier) == 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5512 ### [Index 3, sequence originated from complementary to (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5513 $counting{GA_GA_count}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5514 $alignment_strand = '+';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5515 $read_conversion_info = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5516 $genome_conversion = 'GA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5517
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5518 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5519 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5520 die "Too many Bowtie 2 result filehandles\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5521 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5522
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5523 $methylation_call_params->{$sequence_identifier}->{alignment_strand} = $alignment_strand;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5524 $methylation_call_params->{$sequence_identifier}->{read_conversion} = $read_conversion_info;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5525 $methylation_call_params->{$sequence_identifier}->{genome_conversion} = $genome_conversion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5526 $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence} = $non_bisulfite_sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5527 $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag} = $genomic_seq_for_MD_tag;
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 # if ($contains_deletion){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5530 # warn "non-bis: $methylation_call_params->{$sequence_identifier}->{unmodified_genomic_sequence}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5531 # warn "MD-seq: $methylation_call_params->{$sequence_identifier}->{genomic_seq_for_MD_tag}\n";
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5534 ### the end position of a read is stored in $pos
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5535 $methylation_call_params->{$sequence_identifier}->{end_position} = $pos;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5536 $methylation_call_params->{$sequence_identifier}->{indels} = $indels;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5537 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5538
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5539 ### METHYLATION CALL
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5540
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5541 sub methylation_call{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5542 my ($identifier,$sequence_actually_observed,$genomic_sequence,$read_conversion) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5543 ### splitting both the actually observed sequence and the genomic sequence up into single bases so we can compare them one by one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5544 my @seq = split(//,$sequence_actually_observed);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5545 my @genomic = split(//,$genomic_sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5546 # print join ("\n",$identifier,$sequence_actually_observed,$genomic_sequence,$read_conversion),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5547 ### Creating a match-string with different characters for non-cytosine bases (disregarding mismatches here), methyl-Cs or non-methyl Cs in either
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5548 ### CpG, CHH or CHG context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5549
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 ### . 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
5552 ### 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
5553 ### 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
5554 ### 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
5555 ### 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
5556 ### 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
5557 ### 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
5558 ### 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
5559 ### u for not methylated C in unknwon 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
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 my @match =();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5563 warn "length of \@seq: ",scalar @seq,"\tlength of \@genomic: ",scalar @genomic,"\n" unless (scalar @seq eq (scalar@genomic-2)); ## CHH changed to -2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5564 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
5565 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
5566 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
5567 my $methyl_C_unknown_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5568 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
5569 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
5570 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
5571 my $unmethylated_C_unknown_count = 0;
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 ($read_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
5574 for my $index (0..$#seq) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5575 if ($seq[$index] eq $genomic[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5576 ### The residue can only be a C if it was not converted to T, i.e. protected my methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5577 if ($genomic[$index] eq 'C') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5578 ### If the residue is a C we want to know if it was in CpG context or in any other context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5579 my $downstream_base = $genomic[$index+1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5580
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5581 if ($downstream_base eq 'G'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5582 ++$methyl_CpG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5583 push @match,'Z'; # protected C, methylated, 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
5584 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5585 elsif ($downstream_base eq 'N'){ # if the downstream base was an N we cannot really be sure about the sequence context (as it might have been a CG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5586 ++$methyl_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5587 push @match,'U'; # protected C, methylated, in Unknown context
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 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5590 ### C in not in CpG-context, determining the second downstream base context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5591 my $second_downstream_base = $genomic[$index+2];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5592
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5593 if ($second_downstream_base eq 'G'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5594 ++$methyl_CHG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5595 push @match,'X'; # protected C, methylated, 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
5596 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5597 elsif ($second_downstream_base eq 'N'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5598 ++$methyl_C_unknown_count; # if the second downstream base was an N we cannot really be sure about the sequence context (as it might have been a CHH or CHG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5599 push @match,'U'; # protected C, methylated, in Unknown context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5600 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5601 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5602 ++$methyl_CHH_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5603 push @match,'H'; # protected C, methylated, 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
5604 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5605 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5606 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5607 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5608 push @match, '.';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5609 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5610 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5611 elsif ($seq[$index] ne $genomic[$index]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5612 ### for the methylation call we are only interested in mismatches involving cytosines (in the genomic sequence) which were converted into Ts
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5613 ### in the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5614 if ($genomic[$index] eq 'C' and $seq[$index] eq 'T') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5615 ### If the residue was converted to T we want to know if it was in 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
5616 my $downstream_base = $genomic[$index+1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5617
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5618 if ($downstream_base eq 'G'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5619 ++$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
5620 push @match,'z'; # converted C, not methylated, 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
5621 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5622 elsif ($downstream_base eq 'N'){ # if the downstream base was an N we cannot really be sure about the sequence context (as it might have been a CG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5623 ++$unmethylated_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5624 push @match,'u'; # converted C, not methylated, in Unknown context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5625 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5626 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5627 ### C in not in CpG-context, determining the second downstream base context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5628 my $second_downstream_base = $genomic[$index+2];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5629
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5630 if ($second_downstream_base eq 'G'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5631 ++$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
5632 push @match,'x'; # converted C, not methylated, 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
5633 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5634 elsif ($second_downstream_base eq 'N'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5635 ++$unmethylated_C_unknown_count; # if the second downstream base was an N we cannot really be sure about the sequence context (as it might have been a CHH or CHG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5636 push @match,'u'; # converted C, not methylated, in Unknown context
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5639 ++$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
5640 push @match,'h'; # converted C, not methylated, 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
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5644 ### all other mismatches are not of interest for a methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5645 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5646 push @match,'.';
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5650 die "There can be only 2 possibilities\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5651 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5652 }
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 elsif ($read_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
5655 # print join ("\n",'***',$identifier,$sequence_actually_observed,$genomic_sequence,$read_conversion,'***'),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5656
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5657 for my $index (0..$#seq) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5658 if ($seq[$index] eq $genomic[$index+2]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5659 ### The residue can only be a G if the C on the other strand was not converted to T, i.e. protected my methylation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5660 if ($genomic[$index+2] eq 'G') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5661 ### If the residue is a G we want to know if the C on the other strand was in CpG, CHG or CHH context, therefore we need
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5662 ### to look if the base upstream is a C
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 my $upstream_base = $genomic[$index+1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5665
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5666 if ($upstream_base eq 'C'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5667 ++$methyl_CpG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5668 push @match,'Z'; # protected C on opposing strand, methylated, 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
5669 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5670 elsif ($upstream_base eq 'N'){ # if the upstream base was an N we cannot really be sure about the sequence context (as it might have been a CG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5671 ++$methyl_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5672 push @match,'U'; # protected C on opposing strand, methylated, in Unknown context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5673 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5674 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5675 ### C in not in CpG-context, determining the second upstream base context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5676 my $second_upstream_base = $genomic[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5677
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5678 if ($second_upstream_base eq 'C'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5679 ++$methyl_CHG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5680 push @match,'X'; # protected C on opposing strand, methylated, 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
5681 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5682 elsif ($second_upstream_base eq 'N'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5683 ++$methyl_C_unknown_count; # if the second upstream base was an N we cannot really be sure about the sequence context (as it might have been a CHH or CHG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5684 push @match,'U'; # protected C, methylated, in Unknown context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5685 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5686 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5687 ++$methyl_CHH_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5688 push @match,'H'; # protected C on opposing strand, methylated, 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
5689 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5690 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5691 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5692 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5693 push @match, '.';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5694 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5695 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5696 elsif ($seq[$index] ne $genomic[$index+2]) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5697 ### for the methylation call we are only interested in mismatches involving cytosines (in the genomic sequence) which were converted to Ts
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5698 ### on the opposing strand, so G to A conversions in the actually observed sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5699 if ($genomic[$index+2] eq 'G' and $seq[$index] eq 'A') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5700 ### If the C residue on the opposing strand was converted to T then we will see an A in the currently observed sequence. We want to know if
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5701 ### the C on the opposing strand was it was in CpG, CHG or CHH context, therefore we need to look one (or two) bases upstream!
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 my $upstream_base = $genomic[$index+1];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5704
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5705 if ($upstream_base eq 'C'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5706 ++$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
5707 push @match,'z'; # converted C on opposing strand, not methylated, 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
5708 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5709 elsif ($upstream_base eq 'N'){ # if the upstream base was an N we cannot really be sure about the sequence context (as it might have been a CG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5710 ++$unmethylated_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5711 push @match,'u'; # converted C on opposing strand, not methylated, in Unknown 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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5714 ### C in not in CpG-context, determining the second upstream base context
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5715 my $second_upstream_base = $genomic[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5716
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5717 if ($second_upstream_base eq 'C'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5718 ++$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
5719 push @match,'x'; # converted C on opposing strand, not methylated, 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
5720 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5721 elsif ($second_upstream_base eq 'N'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5722 ++$unmethylated_C_unknown_count; # if the second upstream base was an N we cannot really be sure about the sequence context (as it might have been a CHH or CHG)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5723 push @match,'u'; # converted C on opposing strand, not methylated, in Unknown context
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5726 ++$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
5727 push @match,'h'; # converted C on opposing strand, not methylated, 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
5728 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5729 }
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 ### all other mismatches are not of interest for a methylation call
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5732 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5733 push @match,'.';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5734 }
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5737 die "There can be only 2 possibilities\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5738 }
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 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5741 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5742 die "Strand conversion info is required to perform a methylation call\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5743 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5744
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5745 my $methylation_call = join ("",@match);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5746
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5747 $counting{total_meCHH_count} += $methyl_CHH_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5748 $counting{total_meCHG_count} += $methyl_CHG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5749 $counting{total_meCpG_count} += $methyl_CpG_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5750 $counting{total_meC_unknown_count} += $methyl_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5751 $counting{total_unmethylated_CHH_count} += $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
5752 $counting{total_unmethylated_CHG_count} += $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
5753 $counting{total_unmethylated_CpG_count} += $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
5754 $counting{total_unmethylated_C_unknown_count} += $unmethylated_C_unknown_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5755
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5756 # print "\n$sequence_actually_observed\n$genomic_sequence\n",@match,"\n$read_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
5757
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5758 return $methylation_call;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5759 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5760
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5761 sub read_genome_into_memory{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5762
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5763 ## working directoy
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5764 my $cwd = shift;
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 ## reading in and storing the specified genome in the %chromosomes hash
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5767 chdir ($genome_folder) or die "Can't move to $genome_folder: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5768 warn "Now reading in and storing sequence information of the genome specified in: $genome_folder\n\n";
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 my @chromosome_filenames = <*.fa>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5771
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5772 ### if there aren't any genomic files with the extension .fa we will look for files with the extension .fasta
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5773 unless (@chromosome_filenames){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5774 @chromosome_filenames = <*.fasta>;
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5777 unless (@chromosome_filenames){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5778 die "The specified genome folder $genome_folder does not contain any sequence files in FastA format (with .fa or .fasta file extensions)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5779 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5780
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5781 my $SQ_count = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5782
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5783 foreach my $chromosome_filename (@chromosome_filenames){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5784
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5785 open (CHR_IN,$chromosome_filename) or die "Failed to read from sequence file $chromosome_filename $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5786 ### first line needs to be a fastA header
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5787 my $first_line = <CHR_IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5788 chomp $first_line;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5789 $first_line =~ s/\r//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5790 ### Extracting chromosome name from the FastA header
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5791 my $chromosome_name = extract_chromosome_name($first_line);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5792 my $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5793
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5794 while (<CHR_IN>){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5795 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5796 $_ =~ s/\r//; # removing carriage returns if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5797 if ($_ =~ /^>/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5798
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5799 ### storing the previous chromosome in the %chromosomes hash, only relevant for Multi-Fasta-Files (MFA)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5800 if (exists $chromosomes{$chromosome_name}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5801 print "chr $chromosome_name (",length $sequence ," bp)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5802 die "Exiting because chromosome name already exists. Please make sure all chromosomes have a unique name!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5803 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5804 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5805 if (length($sequence) == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5806 warn "Chromosome $chromosome_name in the multi-fasta file $chromosome_filename did not contain any sequence information!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5807 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5808 print "chr $chromosome_name (",length $sequence ," bp)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5809 $chromosomes{$chromosome_name} = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5810 $SQ_order{$SQ_count} = $chromosome_name;
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 ++$SQ_count;
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 ### resetting the sequence variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5816 $sequence = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5817 ### setting new chromosome name
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5818 $chromosome_name = extract_chromosome_name($_);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5819 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5820 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5821 $sequence .= uc$_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5822 }
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5825 ### Processing last chromosome of a multi Fasta File or the only entry in case of single entry FastA files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5826
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5827 if (exists $chromosomes{$chromosome_name}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5828 print "chr $chromosome_name (",length $sequence ," bp)\t";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5829 die "Exiting because chromosome name already exists. Please make sure all chromosomes have a unique name.\n";
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5832 if (length($sequence) == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5833 warn "Chromosome $chromosome_name in the file $chromosome_filename did not contain any sequence information!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5834 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5835
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5836 ++$SQ_count;
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 print "chr $chromosome_name (",length $sequence ," bp)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5839 $chromosomes{$chromosome_name} = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5840 $SQ_order{$SQ_count} = $chromosome_name;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5841 }
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 print "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5844 chdir $cwd or die "Failed to move to directory $cwd\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5845
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5846 ### If no single multi-FastA genome file was specified explicitely we will generate one here and write it to the output directory
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5847 if ($cram){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5848 unless (defined $cram_ref){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5849 warn "Reconstituting a single multi-FastA genome file as CRAM reference (you may specify such a file using --cram_ref <file> explicitely to prevent this behaviour)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5850
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5851 $cram_ref = "${output_dir}Bismark_genome_CRAM_reference.mfa";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5852 warn "Writing multi-FastA file to $cram_ref\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5853 open (REF,'>',"$cram_ref") or die "Failed to write to file $cram_ref\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5854 foreach my $chr(keys %chromosomes){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5855 print REF ">$chr\n$chromosomes{$chr}\n";
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 warn "Complete\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5858 close REF or warn "Failed to close filehandle REF: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5859 }
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
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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5867 sub extract_chromosome_name {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5868 ## Bowtie seems to extract the first string after the inition > in the FASTA file, so we are doing this as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5869 my $fasta_header = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5870 if ($fasta_header =~ s/^>//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5871 my ($chromosome_name) = split (/\s+/,$fasta_header);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5872 return $chromosome_name;
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 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5875 die "The specified chromosome ($fasta_header) file doesn't seem to be in FASTA format as required!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5876 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5877 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5878
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5879 sub reverse_complement{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5880 my $sequence = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5881 $sequence =~ tr/CATG/GTAC/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5882 $sequence = reverse($sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5883 return $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5884 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5885
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5886 sub biTransformFastAFiles {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5887 my $file = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5888 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5889 if ($file =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5890 ($dir,$filename) = $file =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5891 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5892 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5893 $filename = $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5894 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5895
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5896 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5897 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
5898 open (IN,"gunzip -c $file |") or die "Couldn't read from 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
5899 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5900 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5901 open (IN,$file) or die "Couldn't read from 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
5902 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5903
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5904 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5905 warn "Skipping the first $skip reads 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
5906 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5907 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5908 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5909 warn "Processing reads up to sequence no. $upto 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
5910 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5911 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5912
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5913 my $C_to_T_infile = my $G_to_A_infile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5914
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5915 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5916 $C_to_T_infile =~ s/$/_C_to_T.fa.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5917 $G_to_A_infile =~ s/$/_G_to_A.fa.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5918 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5919 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5920 $C_to_T_infile =~ s/$/_C_to_T.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5921 $G_to_A_infile =~ s/$/_G_to_A.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5922 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5923
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5924 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5925 # warn "Prefixing $prefix:\nold: $C_to_T_infile\nold: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5926 $C_to_T_infile = "$prefix.$C_to_T_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5927 $G_to_A_infile = "$prefix.$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5928 # warn "Prefixing $prefix:\nnew: $C_to_T_infile\nnew: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5929 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5930
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5931 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5932
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5933 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5934 open (CTOT,"| gzip -c - > ${temp_dir}${C_to_T_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5935 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5936 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5937 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5938 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5939
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5940 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5941 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5942 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5943 open (GTOA,"| gzip -c - > ${temp_dir}${G_to_A_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5944 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5945 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5946 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5947 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5948 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5949
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5950 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
5951
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5952 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5953 my $header = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5954 my $sequence= <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5955 last unless ($header and $sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5956
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5957 $header = fix_IDs($header); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5958
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5959 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5960
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5961 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5962 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5963 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5964 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5965 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5966 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5967
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5968 $sequence = uc$sequence; # make input file case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5969
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5970 # detecting if the input file contains tab stops, as this is likely to result in no alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5971 if (index($header,"\t") != -1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5972 $seqID_contains_tabs++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5973 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5974
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5975 ### small check if the sequence seems to be in FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5976 die "Input file doesn't seem to be in FastA format at sequence $count: $!\n" unless ($header =~ /^>.*/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5977
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5978 my $sequence_C_to_T = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5979 $sequence_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5980 print CTOT "$header$sequence_C_to_T";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5981
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5982 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5983 my $sequence_G_to_A = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5984 $sequence_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5985 print GTOA "$header$sequence_G_to_A";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5986 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5987 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5988 close CTOT or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5989
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5990 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5991 warn "\nCreated C -> T converted versions of the FastA file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5992 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5993 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5994 close GTOA or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5995 warn "\nCreated C -> T as well as G -> A converted versions of the FastA file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5996 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5997 return ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5998 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
5999
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6000 sub biTransformFastAFiles_paired_end {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6001 my ($file,$read_number) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6002
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6003 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6004 warn "GZIP compression of temporary files is not supported for paired-end FastA data. Continuing to write uncompressed files\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6005 sleep (2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6006 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6007
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6008 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6009 if ($file =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6010 ($dir,$filename) = $file =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6011 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6012 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6013 $filename = $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6014 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6015
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6016 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6017 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
6018 open (IN,"gunzip -c $file |") or die "Couldn't read from 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
6019 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6020 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6021 open (IN,$file) or die "Couldn't read from 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
6022 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6023
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6024 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6025 warn "Skipping the first $skip reads 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
6026 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6027 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6028 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6029 warn "Processing reads up to sequence no. $upto 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
6030 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6031 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6032
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6033 my $C_to_T_infile = my $G_to_A_infile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6034
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6035 $C_to_T_infile =~ s/$/_C_to_T.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6036 $G_to_A_infile =~ s/$/_G_to_A.fa/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6037
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6038 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6039 # warn "Prefixing $prefix:\nold: $C_to_T_infile\nold: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6040 $C_to_T_infile = "$prefix.$C_to_T_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6041 $G_to_A_infile = "$prefix.$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6042 # warn "Prefixing $prefix:\nnew: $C_to_T_infile\nnew: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6043 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6044
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6045 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6046 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6047 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6048 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6049 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6050 elsif ($read_number == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6051 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6052 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6053 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6054 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6055 die "Read number needs to be 1 or 2, but was: $read_number\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6056 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6057 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6058 else{ # all four strand output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6059 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6060 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6061 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6062 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6063 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6064
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6065 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
6066
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6067 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6068 my $header = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6069 my $sequence= <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6070 last unless ($header and $sequence);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6071
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6072 $header = fix_IDs($header); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6073
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6074 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6075
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6076 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6077 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6078 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6079 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6080 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6081 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6082
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6083 $sequence = uc$sequence; # make input file case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6084
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6085 # detecting if the input file contains tab stops, as this is likely to result in no alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6086 if (index($header,"\t") != -1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6087 $seqID_contains_tabs++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6088 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6089
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6090 ## small check if the sequence seems to be in FastA format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6091 die "Input file doesn't seem to be in FastA format at sequence $count: $!\n" unless ($header =~ /^>/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6092
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6093 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6094 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6095 $header =~ s/$/\/1\/1/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6096 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6097 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6098 $header =~ s/$/\/1/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6100 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6101 elsif ($read_number == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6102 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6103 $header =~ s/$/\/2\/2/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6104 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6105 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6106 $header =~ s/$/\/2/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6107 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6108 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6109 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6110 die "Read number needs to be 1 or 2, but was: $read_number\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6111 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6112 my $sequence_C_to_T = my $sequence_G_to_A = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6113
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6114 $sequence_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6115 $sequence_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6116
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6117 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6118
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6119 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6120 print CTOT "$header$sequence_C_to_T";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6121 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6122 elsif ($read_number == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6123 print GTOA "$header$sequence_G_to_A";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6124 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6125 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6126 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6127 print CTOT "$header$sequence_C_to_T";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6128 print GTOA "$header$sequence_G_to_A";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6129 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6130 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6132 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6133 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6134 warn "\nCreated C -> T converted version of the FastA file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6135 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6136 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6137 warn "\nCreated G -> A converted version of the FastA file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6138 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6139 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6140 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6141 warn "\nCreated C -> T as well as G -> A converted versions of the FastA file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6142 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6143
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6144 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6145 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6146 return ($C_to_T_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6147 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6148 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6149 return ($G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6150 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6151 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6152 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6153 return ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6154 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6155 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6156
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6157
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6158 sub biTransformFastQFiles {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6159 my $file = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6160 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6161 if ($file =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6162 ($dir,$filename) = $file =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6163 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6164 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6165 $filename = $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6166 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6167
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6168 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6169 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
6170 open (IN,"gunzip -c $file |") or die "Couldn't read from 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
6171 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6172 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6173 open (IN,$file) or die "Couldn't read from 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
6174 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6175
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6176 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6177 warn "Skipping the first $skip reads 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
6178 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6179 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6180 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6181 warn "Processing reads up to sequence no. $upto 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
6182 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6183 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6184
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6185 my $C_to_T_infile = my $G_to_A_infile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6186
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6187 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6188 # warn "Prefixing $prefix:\nold: $C_to_T_infile\nold: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6189 $C_to_T_infile = "$prefix.$C_to_T_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6190 $G_to_A_infile = "$prefix.$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6191 # warn "Prefixing $prefix:\nnew: $C_to_T_infile\nnew: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6192 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6193
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6194 if ($pbat){ # PBAT-Seq
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6195 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6196 $G_to_A_infile =~ s/$/_G_to_A.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6197 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6198 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6199 $G_to_A_infile =~ s/$/_G_to_A.fastq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6200 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6201
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6202 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6203
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6204 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6205 open (GTOA,"| gzip -c - > ${temp_dir}${G_to_A_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6206 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6207 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6208 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6209 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6210 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6211 else{ # directional or non-directional
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6212 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6213 $C_to_T_infile =~ s/$/_C_to_T.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6214 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6215 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6216 $C_to_T_infile =~ s/$/_C_to_T.fastq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6217 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6218
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6219 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6220
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6221 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6222 open (CTOT,"| gzip -c - > ${temp_dir}${C_to_T_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6223 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6224 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6225 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n"; # uncompressed option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6226 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6227
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6228 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6229 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6230 $G_to_A_infile =~ s/$/_G_to_A.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6231 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6232 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6233 $G_to_A_infile =~ s/$/_G_to_A.fastq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6234 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6235
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6236 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6237
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6238 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6239 open (GTOA,"| gzip -c - > ${temp_dir}${G_to_A_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6240 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6241 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6242 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6243 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6244 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6245 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6246
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6247 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
6248 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6249 my $identifier = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6250 my $sequence = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6251 my $identifier2 = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6252 my $quality_score = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6253 last unless ($identifier and $sequence and $identifier2 and $quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6254
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6255 $identifier = fix_IDs($identifier); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6256
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6257 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6258
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6259 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6260 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6261 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6262 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6263 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6264 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6265
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6266 $sequence = uc$sequence; # make input file case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6267
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6268 # detecting if the input file contains tab stops, as this is likely to result in no alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6269 if (index($identifier,"\t") != -1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6270 $seqID_contains_tabs++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6271 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6272
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6273 ## small check if the sequence file appears to be a FastQ file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6274 if ($count == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6275 if ($identifier !~ /^\@/ or $identifier2 !~ /^\+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6276 die "Input file doesn't seem to be in FastQ format at sequence $count: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6278 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6280 if ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6281 my $sequence_G_to_A = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6282 $sequence_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6283 print GTOA join ('',$identifier,$sequence_G_to_A,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6284 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6285 else{ # directional or non-directional
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6286 my $sequence_C_to_T = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6287 $sequence_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6288 print CTOT join ('',$identifier,$sequence_C_to_T,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6289
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6290 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6291 my $sequence_G_to_A = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6292 $sequence_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6293 print GTOA join ('',$identifier,$sequence_G_to_A,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6294 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6295 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6296 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6297
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6298 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6299 close CTOT or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6300 warn "\nCreated C -> T converted version of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6301 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6302 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6303 warn "\nCreated G -> A converted version of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6304 close GTOA or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6305 return ($G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6306 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6307 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6308 close CTOT or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6309 close GTOA or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6310 warn "\nCreated C -> T as well as G -> A converted versions of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6311 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6312
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6313 return ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6314 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6315
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6316 sub biTransformFastQFiles_paired_end {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6317 my ($file,$read_number) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6318 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6319
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6320 if ($file =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6321 ($dir,$filename) = $file =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6322 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6323 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6324 $filename = $file;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6325 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6326
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6327 ### gzipped version of the infile
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6328 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
6329 open (IN,"gunzip -c $file |") or die "Couldn't read from 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
6330 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6331 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6332 open (IN,$file) or die "Couldn't read from 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
6333 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6334
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6335 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6336 warn "Skipping the first $skip reads 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
6337 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6338 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6339 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6340 warn "Processing reads up to sequence no. $upto 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
6341 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6342 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6343
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6344 my $C_to_T_infile = my $G_to_A_infile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6345
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6346 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6347 $C_to_T_infile =~ s/$/_C_to_T.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6348 $G_to_A_infile =~ s/$/_G_to_A.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6349 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6350 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6351 $C_to_T_infile =~ s/$/_C_to_T.fastq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6352 $G_to_A_infile =~ s/$/_G_to_A.fastq/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6353 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6354
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6355 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6356 # warn "Prefixing $prefix:\nold: $C_to_T_infile\nold: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6357 $C_to_T_infile = "$prefix.$C_to_T_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6358 $G_to_A_infile = "$prefix.$G_to_A_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6359 # warn "Prefixing $prefix:\nnew: $C_to_T_infile\nnew: $G_to_A_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6360 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6361
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6362 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6363 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6364 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6365 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6366 open (CTOT,"| gzip -c - > ${temp_dir}${C_to_T_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6367 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6368 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6369 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6370 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6371 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6372 elsif ($read_number == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6373 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6374 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6375 open (GTOA,"| gzip -c - > ${temp_dir}${G_to_A_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6376 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6377 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6378 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6379 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6380 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6381 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6382 die "Read number needs to be 1 or 2, but was $read_number!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6383 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6384 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6385 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6386 warn "Writing a C -> T converted version of the input file $filename to $temp_dir$C_to_T_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6387 warn "Writing a G -> A converted version of the input file $filename to $temp_dir$G_to_A_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6388 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6389 open (CTOT,"| gzip -c - > ${temp_dir}${C_to_T_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6390 open (GTOA,"| gzip -c - > ${temp_dir}${G_to_A_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6391 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6392 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6393 open (CTOT,'>',"$temp_dir$C_to_T_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6394 open (GTOA,'>',"$temp_dir$G_to_A_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6395 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6396 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6397
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6398 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
6399 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6400 my $identifier = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6401 my $sequence = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6402 my $identifier2 = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6403 my $quality_score = <IN>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6404 last unless ($identifier and $sequence and $identifier2 and $quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6405 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6406
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6407 $identifier = fix_IDs($identifier); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6408
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6409 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6410 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6411 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6412 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6413 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6414 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6415
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6416 $sequence= uc$sequence; # make input file case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6417
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6418 ## small check if the sequence file appears to be a FastQ file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6419 if ($count == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6420 if ($identifier !~ /^\@/ or $identifier2 !~ /^\+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6421 die "Input file doesn't seem to be in FastQ format at sequence $count: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6423 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6424 my $sequence_C_to_T = my $sequence_G_to_A = $sequence;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6425
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6426 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6427 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6428 $identifier =~ s/$/\/1\/1/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6429 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6430 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6431 $identifier =~ s/$/\/1/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6432 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6433 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6434 elsif ($read_number == 2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6435 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6436 $identifier =~ s/$/\/2\/2/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6437 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6438 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6439 $identifier =~ s/$/\/2/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6441 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6442 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6443 die "Read number needs to be 1 or 2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6444 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6445
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6446 $sequence_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6447 $sequence_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6448
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6449 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6450 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6451 print CTOT join ('',$identifier,$sequence_C_to_T,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6452 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6453 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6454 print GTOA join ('',$identifier,$sequence_G_to_A,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6455 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6456 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6457 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6458 print CTOT join ('',$identifier,$sequence_C_to_T,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6459 print GTOA join ('',$identifier,$sequence_G_to_A,$identifier2,$quality_score);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6460 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6461 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6462
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6463 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6464 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6465 warn "\nCreated C -> T converted version of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6466 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6467 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6468 warn "\nCreated G -> A converted version of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6469 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6470 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6471 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6472 warn "\nCreated C -> T as well as G -> A converted versions of the FastQ file $filename ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6473 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6474 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6475 if ($read_number == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6476 close CTOT or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6477 return ($C_to_T_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6478 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6479 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6480 close GTOA or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6481 return ($G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6482 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6483 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6484 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6485 close CTOT or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6486 close GTOA or die "Failed to close filehandle $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6487 return ($C_to_T_infile,$G_to_A_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6488 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6489 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6490
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6491
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6492 ### SPECIAL BOWTIE 1 PAIRED-END FORMAT FOR GZIPPED OUTPUT FILES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6493
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6494 sub biTransformFastQFiles_paired_end_bowtie1_gzip {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6495 my ($file_1,$file_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6496 my ($dir,$filename);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6497
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6498 if ($file_1 =~ /\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6499 ($dir,$filename) = $file_1 =~ m/(.*\/)(.*)$/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6500 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6501 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6502 $filename = $file_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6503 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6504
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6505 ### gzipped version of infile 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6506 if ($file_1 =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6507 open (IN_1,"gunzip -c $file_1 |") or die "Couldn't read from file $file_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6508 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6509 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6510 open (IN_1,$file_1) or die "Couldn't read from file $file_1: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6511 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6512 ### gzipped version of infile 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6513 if ($file_2 =~ /\.gz$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6514 open (IN_2,"gunzip -c $file_2 |") or die "Couldn't read from file $file_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6515 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6516 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6517 open (IN_2,$file_2) or die "Couldn't read from file $file_2: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6518 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6519
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6520
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6521 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6522 warn "Skipping the first $skip reads from $file_1 and $file_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6523 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6524 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6525 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6526 warn "Processing reads up to sequence no. $upto from $file_1 and $file_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6527 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6528 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6529
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6530 my $CT_plus_GA_infile = my $GA_plus_CT_infile = $filename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6531
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6532 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6533 # warn "Prefixing $prefix:\nold: $CT_plus_GA_infile\nold: $GA_plus_CT_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6534 $CT_plus_GA_infile = "$prefix.$CT_plus_GA_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6535 $GA_plus_CT_infile = "$prefix.$GA_plus_CT_infile";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6536 # warn "Prefixing $prefix:\nnew: $CT_plus_GA_infile\nnew: $GA_plus_CT_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6537 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6538
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6539 $CT_plus_GA_infile =~ s/$/.CT_plus_GA.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6540 $GA_plus_CT_infile =~ s/$/.GA_plus_CT.fastq.gz/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6541 # warn "Prefixing $prefix:\nnew: $CT_plus_GA_infile\nnew: $GA_plus_CT_infile\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6542
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6543 warn "Writing a C -> T converted version of $file_1 and a G -> A converted version of $file_2 to $temp_dir$CT_plus_GA_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6544 open (CTPLUSGA,"| gzip -c - > ${temp_dir}${CT_plus_GA_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6545 # open (CTPLUSGA,'>',"$temp_dir$CT_plus_GA_infile") or die "Couldn't write to file $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6546
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6547 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6548 print "Writing a G -> A converted version of $file_1 and a C -> T converted version of $file_2 to $temp_dir$GA_plus_CT_infile\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6549 open (GAPLUSCT,"| gzip -c - > ${temp_dir}${GA_plus_CT_infile}") or die "Can't write to file: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6550 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6551
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6552 ### for Bowtie 1 we need to write a single gzipped file with 1 line per pair of sequences in the 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
6553 ### <seq-ID> <sequence #1 mate> <quality #1 mate> <sequence #2 mate> <quality #2 mate>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6554
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6555 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
6556 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6557 my $identifier_1 = <IN_1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6558 my $sequence_1 = <IN_1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6559 my $identifier2_1 = <IN_1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6560 my $quality_score_1 = <IN_1>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6561
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6562 my $identifier_2 = <IN_2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6563 my $sequence_2 = <IN_2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6564 my $identifier2_2 = <IN_2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6565 my $quality_score_2 = <IN_2>;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6566
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6567 last unless ($identifier_1 and $sequence_1 and $identifier2_1 and $quality_score_1 and $identifier_2 and $sequence_2 and $identifier2_2 and $quality_score_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6568
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6569 ++$count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6570
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6571 ## small check if the sequence file appears to be a FastQ file
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6572 if ($count == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6573 if ($identifier_1 !~ /^\@/ or $identifier2_1 !~ /^\+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6574 die "Input file 1 doesn't seem to be in FastQ format at sequence $count: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6575 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6576 if ($identifier_2 !~ /^\@/ or $identifier2_2 !~ /^\+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6577 die "Input file 2 doesn't seem to be in FastQ format at sequence $count: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6578 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6579 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6580
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6581 $identifier_1 = fix_IDs($identifier_1); # this is to avoid problems with truncated read ID when they contain white spaces
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6582 chomp $identifier_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6583 chomp $sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6584 chomp $sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6585 chomp $quality_score_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6586 chomp $quality_score_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6587
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6588 $identifier_1 =~ s/^\@//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6589 $identifier_1 =~ s/$/\/1/; #adding an extra /1 to the end which is being removed by Bowtie otherwise (which leads to no sequences alignments whatsoever)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6590
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6591 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6592 next unless ($count > $skip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6593 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6594 if ($upto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6595 last if ($count > $upto);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6596 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6597
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6598 $sequence_1 = uc$sequence_1; # make input file 1 case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6599 $sequence_2 = uc$sequence_2; # make input file 2 case insensitive
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6600
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6601 # print "$identifier_1\t$sequence_1\t$quality_score_1\t$sequence_2\t$quality_score_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6602 my $sequence_1_C_to_T = $sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6603 my $sequence_2_G_to_A = $sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6604 $sequence_1_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6605 $sequence_2_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6606
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6607 print CTPLUSGA "$identifier_1\t$sequence_1_C_to_T\t$quality_score_1\t$sequence_2_G_to_A\t$quality_score_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6608
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6609 unless ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6610 my $sequence_1_G_to_A = $sequence_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6611 my $sequence_2_C_to_T = $sequence_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6612 $sequence_1_G_to_A =~ tr/G/A/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6613 $sequence_2_C_to_T =~ tr/C/T/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6614 print GAPLUSCT "$identifier_1\t$sequence_1_G_to_A\t$quality_score_1\t$sequence_2_C_to_T\t$quality_score_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6615 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6616 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6617
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6618 close CTPLUSGA or die "Couldn't close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6619 warn "\nCreated C -> T converted version of FastQ file '$file_1' and G -> A converted version of FastQ file '$file_2' ($count sequences 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
6620
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6621 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6622 warn "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6623 return ($CT_plus_GA_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6624 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6625 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6626 close GAPLUSCT or die "Couldn't close filehandle\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6627 warn "Created G -> A converted version of FastQ file '$file_1' and C -> T converted version of FastQ file '$file_2' ($count sequences in total)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6628 return ($CT_plus_GA_infile,$GA_plus_CT_infile);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6629 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6630 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6631
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6632
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6633 sub fix_IDs{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6634 my $id = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6635 $id =~ s/[ \t]+/_/g; # replace spaces or tabs with underscores
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6636 return $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6637 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6638
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6639 sub ensure_sensical_alignment_orientation_single_end{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6640 my $index = shift; # index number if the sequence produced an alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6641 my $strand = shift;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6642 ### setting $orientation to 1 if it is in the correct orientation, and leave it 0 if it is the nonsensical wrong one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6643 my $orientation = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6644 ##############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6645 ## FORWARD converted read against FORWARD converted genome (read: C->T.....C->T.. genome:C->T.......C->T)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6646 ## here we only want reads in the forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6647 if ($fhs[$index]->{name} eq 'CTreadCTgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6648 ### if the alignment is (+) we count it, and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6649 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
6650 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6651 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6652 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6653 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6654 ### if the orientation equals (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6655 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
6656 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6657 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6658 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6659 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6660 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6661 ## FORWARD converted read against reverse converted genome (read: C->T.....C->T.. genome: G->A.......G->A)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6662 ## here we only want reads in the forward (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6663 elsif ($fhs[$index]->{name} eq 'CTreadGAgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6664 ### if the alignment is (-) we count it and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6665 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
6666 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6667 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6668 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6669 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6670 ### if the orientation equals (+) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6671 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
6672 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6673 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6674 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6675 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6676 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6677 ## Reverse converted read against FORWARD converted genome (read: G->A.....G->A.. genome: C->T.......C->T)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6678 ## here we only want reads in the forward (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6679 elsif ($fhs[$index]->{name} eq 'GAreadCTgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6680 ### if the alignment is (-) we count it and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6681 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
6682 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6683 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6684 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6685 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6686 ### if the orientation equals (+) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6687 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
6688 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6689 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6690 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6691 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6692 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6693 ## Reverse converted read against reverse converted genome (read: G->A.....G->A.. genome: G->A.......G->A)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6694 ## here we only want reads in the forward (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6695 elsif ($fhs[$index]->{name} eq 'GAreadGAgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6696 ### if the alignment is (+) we count it and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6697 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
6698 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6699 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6700 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6701 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6702 ### if the orientation equals (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6703 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
6704 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6705 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6706 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6707 } else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6708 die "One of the above conditions must be true\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6709 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6710 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6711
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6712 sub ensure_sensical_alignment_orientation_paired_ends{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6713 my ($index,$id_1,$strand_1,$id_2,$strand_2) = @_; # index number if the sequence produced an alignment
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6714 ### setting $orientation to 1 if it is in the correct orientation, and leave it 0 if it is the nonsensical wrong one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6715 my $orientation = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6716 ##############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6717 ## [Index 0, sequence originated from (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6718 ## CT converted read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6719 ## GA converted read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6720 ## CT converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6721 ## here we only want read 1 in (+) orientation and read 2 in (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6722 if ($fhs[$index]->{name} eq 'CTread1GAread2CTgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6723 ### if the paired-end alignment is read1 (+) and read2 (-) we count it, and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6724 if ($id_1 =~ /1$/ and $strand_1 eq '+' and $id_2 =~ /2$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6725 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6726 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6727 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6728 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6729 ### if the read 2 is in (+) orientation and read 1 in (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6730 elsif ($id_1 =~ /2$/ and $strand_1 eq '+' and $id_2 =~ /1$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6731 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6732 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6733 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6734 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6735 die "id1: $id_1\tid2: $id_2\tThis should be impossible\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6736 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6737 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6738 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6739 ## [Index 1, sequence originated from (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6740 ## GA converted read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6741 ## CT converted read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6742 ## GA converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6743 ## here we only want read 1 in (+) orientation and read 2 in (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6744 elsif ($fhs[$index]->{name} eq 'GAread1CTread2GAgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6745 ### if the paired-end alignment is read1 (+) and read2 (-) we count it, and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6746 if ($id_1 =~ /1$/ and $strand_1 eq '+' and $id_2 =~ /2$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6747 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6748 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6749 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6750 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6751 ### if the read 2 is in (+) orientation and read 1 in (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6752 elsif ($id_1 =~ /2$/ and $strand_1 eq '+' and $id_2 =~ /1$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6753 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6754 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6755 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6756 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6757 die "id1: $id_1\tid2: $id_2\tThis should be impossible\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6758 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6759 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6760 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6761 ## [Index 2, sequence originated from complementary to (converted) forward strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6762 ## GA converted read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6763 ## CT converted read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6764 ## CT converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6765 ## here we only want read 1 in (-) orientation and read 2 in (+) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6766 elsif ($fhs[$index]->{name} eq 'GAread1CTread2CTgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6767 ### if the paired-end alignment is read1 (-) and read2 (+) we count it, and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6768 if ($id_1 =~ /2$/ and $strand_1 eq '+' and $id_2 =~ /1$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6769 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6770 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6771 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6772 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6773 ### if the read 2 is in (+) orientation and read 1 in (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6774 elsif ($id_1 =~ /1$/ and $strand_1 eq '+' and $id_2 =~ /2$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6775 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6776 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6777 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6778 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6779 die "id1: $id_1\tid2: $id_2\tThis should be impossible\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6780 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6781 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6782 ###############################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6783 ## [Index 3, sequence originated from complementary to (converted) reverse strand]
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6784 ## CT converted read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6785 ## GA converted read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6786 ## GA converted genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6787 ## here we only want read 1 in (+) orientation and read 2 in (-) orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6788 elsif ($fhs[$index]->{name} eq 'CTread1GAread2GAgenome') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6789 ### if the paired-end alignment is read1 (-) and read2 (+) we count it, and return 1 for a correct orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6790 if ($id_1 =~ /2$/ and $strand_1 eq '+' and $id_2 =~ /1$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6791 $fhs[$index]->{seen}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6792 $orientation = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6793 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6794 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6795 ### if the read 2 is in (+) orientation and read 1 in (-) the alignment is nonsensical
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6796 elsif ($id_1 =~ /1$/ and $strand_1 eq '+' and $id_2 =~ /2$/ and $strand_2 eq '-') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6797 $fhs[$index]->{wrong_strand}++;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6798 return $orientation;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6799 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6800 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6801 die "id1: $id_1\tid2: $id_2\tThis should be impossible\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6802 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6803 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6804 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6805 die "One of the above conditions must be true\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6806 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6807 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6808
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6809 #####################################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6810
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6811 ### Bowtie 1 (default) | PAIRED-END | FASTA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6812
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6813 sub paired_end_align_fragments_to_bisulfite_genome_fastA {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6814
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6815 my ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6816
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6817 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6818 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_2 (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6819 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6820 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6821 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_1 and $C_to_T_infile_2 and $G_to_A_infile_2 (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6822 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6823
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6824 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6825 ## data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6826 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6827 warn "Now running 2 instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6828 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6829 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6830 warn "Now running 4 individual instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6831 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6832
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6833 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6834
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6835 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6836 unless ($fh->{inputfile_1}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6837 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6838 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6839 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6840 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6841 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6842 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6843
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6844 my $bt_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6845 if ($fh->{name} eq 'CTread1GAread2CTgenome' or $fh->{name} eq 'GAread1CTread2GAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6846 $bt_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6847 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6848 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6849 $bt_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6850 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6851
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6852 warn "Now starting a Bowtie paired-end alignment for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile_1} and $temp_dir$fh->{inputfile_2}, with the options: $bt_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6853 open ($fh->{fh},"$path_to_bowtie $bt_options $fh->{bisulfiteIndex} -1 $temp_dir$fh->{inputfile_1} -2 $temp_dir$fh->{inputfile_2} |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6854
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6855 my $line_1 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6856 my $line_2 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6857
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6858 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6859 if ($line_1 and $line_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6860 chomp $line_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6861 chomp $line_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6862 my $id_1 = (split(/\t/,$line_1))[0]; # this is the first element of the first bowtie output line (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6863 my $id_2 = (split(/\t/,$line_2))[0]; # this is the first element of the second bowtie output line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6864
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6865 ### Bowtie always reports the alignment with the smaller chromosomal position first. This can be either sequence 1 or sequence 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6866 ### We will thus identify which sequence was read 1 and store this ID as last_seq_id
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6867
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6868 if ($id_1 =~ s/\/1$//){ # removing the read 1 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6869 $fh->{last_seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6870 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6871 elsif ($id_2 =~ s/\/1$//){ # removing the read 1 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6872 $fh->{last_seq_id} = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6873 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6874 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6875 die "Either the first or the second id need to be read 1! ID1 was: $id_1; ID2 was: $id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6876 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6877
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6878 $fh->{last_line_1} = $line_1; # this contains either read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6879 $fh->{last_line_2} = $line_2; # this contains either read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6880 warn "Found first alignment:\n$fh->{last_line_1}\n$fh->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6881 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6882 # otherwise we just initialise last_seq_id and last_lines as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6883 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6884 warn "Found no alignment, assigning undef to last_seq_id and last_lines\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6885 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6886 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6887 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6888 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6889 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6890 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6891
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6892 ### Bowtie 2 | PAIRED-END | FASTA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6893
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6894 sub paired_end_align_fragments_to_bisulfite_genome_fastA_bowtie2 {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6895 my ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6896 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6897 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_2 (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6898 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6899 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6900 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_1 and $C_to_T_infile_2 and $G_to_A_infile_2 (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6901 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6902
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6903 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6904 ## data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6905 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6906 warn "Now running 2 instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6907 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6908 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6909 warn "Now running 4 individual instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6910 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6911
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6912 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6913
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6914 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6915 unless ($fh->{inputfile_1}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6916 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6917 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6918 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6919 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6920 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6921 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6922
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6923 my $bt2_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6924 if ($fh->{name} eq 'CTread1GAread2CTgenome' or $fh->{name} eq 'GAread1CTread2GAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6925 $bt2_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6926 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6927 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6928 $bt2_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6929 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6930
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6931 warn "Now starting a Bowtie 2 paired-end alignment for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile_1} and $temp_dir$fh->{inputfile_2}, with the options: $bt2_options))\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6932 open ($fh->{fh},"$path_to_bowtie $bt2_options -x $fh->{bisulfiteIndex} -1 $temp_dir$fh->{inputfile_1} -2 $temp_dir$fh->{inputfile_2} |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6933
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6934 ### Bowtie 2 outputs out SAM format, so we need to skip everything until the first sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6935 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6936 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6937 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6938 last unless ($_ =~ /^\@/); # SAM headers start with @
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6939 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6940 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6941 last; # no alignment output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6942 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6943 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6944
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6945 my $line_1 = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6946 my $line_2 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6947
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6948 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6949 if ($line_1 and $line_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6950 chomp $line_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6951 chomp $line_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6952 my $id_1 = (split(/\t/,$line_1))[0]; # this is the first element of the first bowtie output line (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6953 my $id_2 = (split(/\t/,$line_2))[0]; # this is the first element of the second bowtie output line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6954
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6955 ### Bowtie always reports the alignment with the smaller chromosomal position first. This can be either sequence 1 or sequence 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6956 ### We will thus identify which sequence was read 1 and store this ID as last_seq_id
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6957
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6958 if ($id_1 =~ s/\/1$//){ # removing the read 1 /1 tag if present (remember that Bowtie2 clips off /1 or /2 line endings itself, so we added /1/1 or /2/2 to start with
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6959 $fh->{last_seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6960 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6961 elsif ($id_2 =~ s/\/1$//){ # removing the read 1 /2 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6962 $fh->{last_seq_id} = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6963 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6964 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6965 warn "Either the first or the second id need to be read 1! ID1 was: $id_1; ID2 was: $id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6966 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6967
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6968 $fh->{last_line_1} = $line_1; # this contains either read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6969 $fh->{last_line_2} = $line_2; # this contains either read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6970 warn "Found first alignment:\n$fh->{last_line_1}\n$fh->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6971 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6972 # otherwise we just initialise last_seq_id and last_lines as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6973 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6974 warn "Found no alignment, assigning undef to last_seq_id and last_lines\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6975 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6976 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6977 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6978 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6979 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6980 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6981
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6982 ### Bowtie 1 (default) | PAIRED-END | FASTQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6983
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6984 sub paired_end_align_fragments_to_bisulfite_genome_fastQ {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6985 my ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6986
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6987 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6988 warn "Input file is $C_to_T_infile_1 and $G_to_A_infile_2 (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6989 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6990 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6991 warn "Input file is $G_to_A_infile_1 and $C_to_T_infile_2 (FastQ; PBAT-Seq)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6992 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6993 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6994 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_2 and $G_to_A_infile_1 and $C_to_T_infile_2 (non-directional; FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6995 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6996
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6997 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in the data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6998 if ($directional or $pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
6999 warn "Now running 2 instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7000 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7001 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7002 warn "Now running 4 individual instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7003 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7004
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7005 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7007 if ($directional or $pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7008 unless ($fh->{inputfile_1}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7009 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7010 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7011 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7012 next; # skipping unwanted filehandles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7013 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7014 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7015
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7016 my $bt_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7017 if ($fh->{name} eq 'CTread1GAread2CTgenome' or $fh->{name} eq 'GAread1CTread2GAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7018 $bt_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7019 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7020 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7021 $bt_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7022 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7023
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7024 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7025 warn "Now starting a Bowtie paired-end alignment for $fh->{name} (reading in sequences from ${temp_dir}$fh->{inputfile_1}, with the options: $bt_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7026 open ($fh->{fh},"gunzip -c ${temp_dir}$fh->{inputfile_1} | $path_to_bowtie $bt_options $fh->{bisulfiteIndex} --12 - |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7027 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7028 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7029 warn "Now starting a Bowtie paired-end alignment for $fh->{name} (reading in sequences from ${temp_dir}$fh->{inputfile_1} and ${temp_dir}$fh->{inputfile_2}, with the options: $bt_options))\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7030 sleep(5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7031 open ($fh->{fh},"$path_to_bowtie $bt_options $fh->{bisulfiteIndex} -1 $temp_dir$fh->{inputfile_1} -2 $temp_dir$fh->{inputfile_2} |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7032 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7033
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7034 my $line_1 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7035 my $line_2 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7036
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7037 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7038 if ($line_1 and $line_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7039 chomp $line_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7040 chomp $line_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7041 ### Bowtie always reports the alignment with the smaller chromosomal position first. This can be either sequence 1 or sequence 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7042 ### We will thus identify which sequence was read 1 and store this ID as last_seq_id
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7043
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7044 my $id_1 = (split(/\t/,$line_1))[0]; # this is the first element of the first bowtie output line (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7045 my $id_2 = (split(/\t/,$line_2))[0]; # this is the first element of the second bowtie output line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7046
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7047 if ($id_1 =~ s/\/1$//){ # removing the read 1 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7048 $fh->{last_seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7049 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7050 elsif ($id_2 =~ s/\/1$//){ # removing the read 1 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7051 $fh->{last_seq_id} = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7052 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7053 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7054 die "Either the first or the second id need to be read 1! ID1 was: $id_1; ID2 was: $id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7055 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7056
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7057 $fh->{last_line_1} = $line_1; # this contains read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7058 $fh->{last_line_2} = $line_2; # this contains read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7059 warn "Found first alignment:\n$fh->{last_line_1}\n$fh->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7060 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7061
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7062 # otherwise we just initialise last_seq_id and last_lines as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7063 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7064 warn "Found no alignment, assigning undef to last_seq_id and last_lines\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7065 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7066 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7067 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7068 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7069 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7071
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7072 ### Bowtie 2 | PAIRED-END | FASTQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7073
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7074 sub paired_end_align_fragments_to_bisulfite_genome_fastQ_bowtie2 {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7075
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7076 my ($C_to_T_infile_1,$G_to_A_infile_1,$C_to_T_infile_2,$G_to_A_infile_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7077 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7078 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_2 (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7079 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7080 elsif ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7081 warn "Input files are $G_to_A_infile_1 and $C_to_T_infile_2 (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7082 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7083 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7084 warn "Input files are $C_to_T_infile_1 and $G_to_A_infile_1 and $C_to_T_infile_2 and $G_to_A_infile_2 (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7085 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7086
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7087 ## Now starting up 4 instances of Bowtie 2 feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7088 ## data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7089 if ($directional or $pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7090 warn "Now running 2 instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7091 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7092 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7093 warn "Now running 4 individual instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7094 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7095
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7096 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7097
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7098 if ($directional or $pbat){ # skipping unwanted filehandles
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7099 unless ($fh->{inputfile_1}){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7100 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7101 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7102 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7103 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7104 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7105 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7106
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7107 my $bt2_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7108 if ($fh->{name} eq 'CTread1GAread2CTgenome' or $fh->{name} eq 'GAread1CTread2GAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7109 $bt2_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7110 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7111 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7112 $bt2_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7113 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7114
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7115 warn "Now starting a Bowtie 2 paired-end alignment for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile_1} and $temp_dir$fh->{inputfile_2}, with the options: $bt2_options))\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7116 open ($fh->{fh},"$path_to_bowtie $bt2_options -x $fh->{bisulfiteIndex} -1 $temp_dir$fh->{inputfile_1} -2 $temp_dir$fh->{inputfile_2} |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7117
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7118 ### Bowtie 2 outputs out SAM format, so we need to skip everything until the first sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7119 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7120 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7121 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7122 last unless ($_ =~ /^\@/); # SAM headers start with @
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7124 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7125 last; # no alignment output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7126 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7127 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7128
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7129 my $line_1 = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7130 my $line_2 = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7132 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7133 if ($line_1 and $line_2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7134 chomp $line_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7135 chomp $line_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7136 ### Bowtie always reports the alignment with the smaller chromosomal position first. This can be either sequence 1 or sequence 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7137 ### We will thus identify which sequence was read 1 and store this ID as last_seq_id
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7138
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7139 my $id_1 = (split(/\t/,$line_1))[0]; # this is the first element of the first bowtie output line (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7140 my $id_2 = (split(/\t/,$line_2))[0]; # this is the first element of the second bowtie output line
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7141
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7142 if ($id_1 =~ s/\/1$//){ # removing the read 1 tag if present (remember that Bowtie2 clips off /1 or /2 line endings itself, so we added /1/1 or /2/2 to start with
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7143 $fh->{last_seq_id} = $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7144 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7145 elsif ($id_2 =~ s/\/1$//){ # removing the read 1 tag if present
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7146 $fh->{last_seq_id} = $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7147 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7148 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7149 die "Either the first or the second id need to be read 1! ID1 was: $id_1; ID2 was: $id_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7150 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7151
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7152 $fh->{last_line_1} = $line_1; # this contains read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7153 $fh->{last_line_2} = $line_2; # this contains read 1 or read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7154 warn "Found first alignment:\n$fh->{last_line_1}\n$fh->{last_line_2}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7155 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7156
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7157 # otherwise we just initialise last_seq_id and last_lines as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7158 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7159 warn "Found no alignment, assigning undef to last_seq_id and last_lines\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7160 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7161 $fh->{last_line_1} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7162 $fh->{last_line_2} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7163 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7164 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7165 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7166
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7167 #####################################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7168
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7169 ### Bowtie 1 (default) | SINGLE-END | FASTA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7170 sub single_end_align_fragments_to_bisulfite_genome_fastA {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7171 my ($C_to_T_infile,$G_to_A_infile) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7172 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7173 warn "Input file is $C_to_T_infile (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7174 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7175 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7176 warn "Input files are $C_to_T_infile and $G_to_A_infile (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7177 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7178
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7179 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7180 ## data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7181 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7182 warn "Now running 2 instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7183 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7184 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7185 warn "Now running 4 individual instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7186 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7187
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7188 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7189
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7190 my $bt_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7191 if ($fh->{name} eq 'CTreadCTgenome' or $fh->{name} eq 'GAreadGAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7192 $bt_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7193 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7194 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7195 $bt_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7196 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7197
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7198 warn "Now starting the Bowtie aligner for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile} with options: $bt_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7199 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7200 open ($fh->{fh},"gunzip -c $temp_dir$fh->{inputfile} | $path_to_bowtie $bt_options $fh->{bisulfiteIndex} - |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7201 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7202 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7203 open ($fh->{fh},"$path_to_bowtie $bt_options $fh->{bisulfiteIndex} $temp_dir$fh->{inputfile} |") or die "Can't open pipe to bowtie: $!"; # command for uncompressed data
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7204 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7205
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7206 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7207 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7208 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7209 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7210 my $id = (split(/\t/))[0]; # this is the first element of the bowtie output (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7211 $fh->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7212 $fh->{last_line} = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7213 warn "Found first alignment:\t$fh->{last_line}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7214 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7215 # otherwise we just initialise last_seq_id and last_line as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7216 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7217 warn "Found no alignment, assigning undef to last_seq_id and last_line\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7218 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7219 $fh->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7220 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7221 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7222 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7223
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7224 ### Bowtie 2 | SINGLE-END | FASTA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7225 sub single_end_align_fragments_to_bisulfite_genome_fastA_bowtie2 {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7226 my ($C_to_T_infile,$G_to_A_infile) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7227 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7228 warn "Input file is $C_to_T_infile (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7229 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7230 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7231 warn "Input files are $C_to_T_infile and $G_to_A_infile (FastA)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7232 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7233
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7234 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7235 ## data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7236 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7237 warn "Now running 2 instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7238 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7239 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7240 warn "Now running 4 individual instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7241 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7242
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7243 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7244
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7245 my $bt2_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7246 if ($fh->{name} eq 'CTreadCTgenome' or $fh->{name} eq 'GAreadGAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7247 $bt2_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7248 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7249 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7250 $bt2_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7251 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7252
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7253 warn "Now starting the Bowtie 2 aligner for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile} with options: $bt2_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7254 open ($fh->{fh},"$path_to_bowtie $bt2_options -x $fh->{bisulfiteIndex} -U $temp_dir$fh->{inputfile} |") or die "Can't open pipe to bowtie 2: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7255
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7256 ### Bowtie 2 outputs out SAM format, so we need to skip everything until the first sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7257 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7258 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7259 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7260 last unless ($_ =~ /^\@/); # SAM headers start with @
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7261 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7262 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7263 last; # no alignment output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7264 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7265 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7266
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7267 # Bowtie 2 outputs a result line even for sequences without any alignments. We thus store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7268 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7269 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7270 my $id = (split(/\t/))[0]; # this is the first element of the Bowtie output (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7271 $fh->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7272 $fh->{last_line} = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7273 warn "Found first alignment:\t$fh->{last_line}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7274 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7275 # otherwise we just initialise last_seq_id and last_line as undefinded. This should only happen at the end of a file for Bowtie 2 output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7276 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7277 warn "Found no alignment, assigning undef to last_seq_id and last_line\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7278 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7279 $fh->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7280 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7281 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7282 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7283
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7284
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7285 ### Bowtie 1 (default) | SINGLE-END | FASTQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7286 sub single_end_align_fragments_to_bisulfite_genome_fastQ {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7287 my ($C_to_T_infile,$G_to_A_infile) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7288 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7289 warn "Input file is $C_to_T_infile (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7290 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7291 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7292 warn "Input file is $G_to_A_infile (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7293 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7294 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7295 warn "Input files are $C_to_T_infile and $G_to_A_infile (FastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7296 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7297
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7298
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7299 ## Now starting up to 4 instances of Bowtie feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7300 ## the data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7301 if ($directional or $pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7302 warn "Now running 2 instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7303 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7304 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7305 warn "Now running 4 individual instances of Bowtie against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7306 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7307
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7308 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7309 my $bt_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7310 if ($fh->{name} eq 'CTreadCTgenome' or $fh->{name} eq 'GAreadGAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7311 $bt_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7312 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7313 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7314 $bt_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7315 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7316
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7317 warn "Now starting the Bowtie aligner for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile} with options: $bt_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7318 sleep (5);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7319
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7320 if ($gzip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7321 open ($fh->{fh},"gunzip -c $temp_dir$fh->{inputfile} | $path_to_bowtie $bowtie_options $fh->{bisulfiteIndex} - |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7322 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7323 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7324 open ($fh->{fh},"$path_to_bowtie $bowtie_options $fh->{bisulfiteIndex} $temp_dir$fh->{inputfile} |") or die "Can't open pipe to bowtie: $!"; # command for uncompressed data
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7325 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7326
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7327 # if Bowtie produces an alignment we store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7328 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7329 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7330 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7331 my $id = (split(/\t/))[0]; # this is the first element of the Bowtie output (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7332 $fh->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7333 $fh->{last_line} = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7334 warn "Found first alignment:\t$fh->{last_line}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7335 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7336 # otherwise we just initialise last_seq_id and last_line as undefined
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7337 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7338 warn "Found no alignment, assigning undef to last_seq_id and last_line\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7339 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7340 $fh->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7341 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7342 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7343 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7344
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7345 ### Bowtie 2 | SINGLE-END | FASTQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7346 sub single_end_align_fragments_to_bisulfite_genome_fastQ_bowtie2 {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7347
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7348 my ($C_to_T_infile,$G_to_A_infile) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7349 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7350 warn "Input file is $C_to_T_infile (FastQ)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7351 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7352 elsif ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7353 warn "Input file is $G_to_A_infile (FastQ)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7354 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7355 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7356 warn "Input files are $C_to_T_infile and $G_to_A_infile (FastQ)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7357 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7358
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7359 ## Now starting up to 4 instances of Bowtie 2 feeding in the converted sequence files and reading in the first line of the bowtie output, and storing it in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7360 ## the data structure above
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7361 if ($directional or $pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7362 warn "Now running 2 instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7363 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7364 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7365 warn "Now running 4 individual instances of Bowtie 2 against the bisulfite genome of $genome_folder with the specified options: $bowtie_options\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7366 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7367
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7368 foreach my $fh (@fhs) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7369 my $bt2_options = $bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7370 if ($fh->{name} eq 'CTreadCTgenome' or $fh->{name} eq 'GAreadGAgenome'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7371 $bt2_options .= ' --norc'; ### ensuring the alignments are only reported in a sensible manner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7372 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7373 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7374 $bt2_options .= ' --nofw';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7375 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7376 warn "Now starting the Bowtie 2 aligner for $fh->{name} (reading in sequences from $temp_dir$fh->{inputfile} with options $bt2_options)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7377 warn "Using Bowtie 2 index: $fh->{bisulfiteIndex}\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7378
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7379 open ($fh->{fh},"$path_to_bowtie $bt2_options -x $fh->{bisulfiteIndex} -U $temp_dir$fh->{inputfile} |") or die "Can't open pipe to bowtie: $!";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7380 ### Bowtie 2 outputs out SAM format, so we need to skip everything until the first sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7381 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7382 $_ = $fh->{fh}->getline();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7383 # warn "$_\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7384 # sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7385 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7386 last unless ($_ =~ /^\@/); # SAM headers start with @
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7387 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7388 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7389 last;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7390 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7391 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7392
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7393 # Bowtie 2 outputs a result line even for sequences without any alignments. We thus store the first line of the output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7394 if ($_) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7395 chomp;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7396 my $id = (split(/\t/))[0]; # this is the first element of the Bowtie 2 output (= the sequence identifier)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7397 $fh->{last_seq_id} = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7398 $fh->{last_line} = $_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7399 warn "Found first alignment:\t$fh->{last_line}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7400 # warn "storing $id and\n$_\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7401 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7402 # otherwise we just initialise last_seq_id and last_line as undefined. This should only happen at the end of a file for Bowtie 2 output
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7403 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7404 warn "Found no alignment, assigning undef to last_seq_id and last_line\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7405 $fh->{last_seq_id} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7406 $fh->{last_line} = undef;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7407 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7408 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7409 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7410
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7411 ###########################################################################################################################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7412
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7413 sub reset_counters_and_fhs{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7414 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
7415 %counting=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7416 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
7417 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
7418 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
7419 total_meC_unknown_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7420 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
7421 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
7422 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
7423 total_unmethylated_C_unknown_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7424 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
7425 no_single_alignment_found => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7426 unsuitable_sequence_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7427 genomic_sequence_could_not_be_extracted_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7428 unique_best_alignment_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7429 low_complexity_alignments_overruled_count => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7430 CT_CT_count => 0, #(CT read/CT genome, 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
7431 CT_GA_count => 0, #(CT read/GA genome, 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
7432 GA_CT_count => 0, #(GA read/CT genome, 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
7433 GA_GA_count => 0, #(GA read/GA genome, 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
7434 CT_GA_CT_count => 0, #(CT read1/GA read2/CT genome, 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
7435 GA_CT_GA_count => 0, #(GA read1/CT read2/GA genome, 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
7436 GA_CT_CT_count => 0, #(GA read1/CT read2/CT genome, 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
7437 CT_GA_GA_count => 0, #(CT read1/GA read2/GA genome, 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
7438 alignments_rejected_count => 0, # only relevant if --directional was specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7439 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7440
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7441 if ($directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7442 if ($filename =~ ','){ # 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
7443 @fhs=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7444 { name => 'CTreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7445 strand_identity => 'con ori forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7446 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7447 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7448 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7449 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7450 { name => 'CTreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7451 strand_identity => 'con ori reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7452 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7453 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7454 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7455 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7456 { name => 'GAreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7457 strand_identity => 'compl ori con forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7458 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7459 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7460 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7461 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7462 { name => 'GAreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7463 strand_identity => 'compl ori con reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7464 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7465 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7466 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7467 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7468 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7469 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7470 else{ # single-end files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7471 @fhs=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7472 { name => 'CTreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7473 strand_identity => 'con ori forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7474 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7475 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7476 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7477 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7478 { name => 'CTreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7479 strand_identity => 'con ori reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7480 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7481 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7482 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7483 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7484 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7485 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7486 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7487 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7488 if ($filename =~ ','){ # 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
7489 @fhs=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7490 { name => 'CTreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7491 strand_identity => 'con ori forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7492 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7493 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7494 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7495 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7496 { name => 'CTreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7497 strand_identity => 'con ori reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7498 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7499 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7500 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7501 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7502 { name => 'GAreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7503 strand_identity => 'compl ori con forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7504 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7505 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7506 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7507 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7508 { name => 'GAreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7509 strand_identity => 'compl ori con reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7510 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7511 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7512 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7513 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7514 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7515 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7516 else{ # single-end files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7517 @fhs=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7518 { name => 'GAreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7519 strand_identity => 'compl ori con forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7520 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7521 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7522 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7523 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7524 { name => 'GAreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7525 strand_identity => 'compl ori con reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7526 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7527 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7528 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7529 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7530 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7531 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7532 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7533 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7534 @fhs=(
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7535 { name => 'CTreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7536 strand_identity => 'con ori forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7537 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7538 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7539 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7540 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7541 { name => 'CTreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7542 strand_identity => 'con ori reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7543 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7544 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7545 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7546 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7547 { name => 'GAreadCTgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7548 strand_identity => 'compl ori con forward',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7549 bisulfiteIndex => $CT_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7550 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7551 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7552 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7553 { name => 'GAreadGAgenome',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7554 strand_identity => 'compl ori con reverse',
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7555 bisulfiteIndex => $GA_index_basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7556 seen => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7557 wrong_strand => 0,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7558 },
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7559 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7560 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7561 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7562
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7563
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7564 sub process_command_line{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7565 my @bowtie_options;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7566 my $help;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7567 my $mates1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7568 my $mates2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7569 my $path_to_bowtie;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7570 my $fastq;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7571 my $fasta;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7572 my $skip;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7573 my $qupto;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7574 my $phred64;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7575 my $phred33;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7576 my $solexa;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7577 my $mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7578 my $seed_length;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7579 my $best;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7580 my $sequence_format;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7581 my $version;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7582 my $quiet;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7583 my $chunk;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7584 my $non_directional;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7585 my $ceiling;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7586 my $maxins;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7587 my $minins;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7588 my $unmapped;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7589 my $multi_map;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7590 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
7591 my $bowtie2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7592 my $vanilla;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7593 my $sam_no_hd;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7594 my $seed_extension_fails;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7595 my $reseed_repetitive_seeds;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7596 my $most_valid_alignments;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7597 my $score_min;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7598 my $parallel;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7599 my $temp_dir;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7600 my $rdg;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7601 my $rfg;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7602 my $non_bs_mm;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7603 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
7604 my $bam;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7605 my $gzip;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7606 my $pbat;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7607 my $prefix;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7608 my $old_flag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7609 my $basename;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7610 my $sam;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7611 my $multicore;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7612 my $bowtie1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7613 my $rg_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7614 my $rg_id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7615 my $rg_sample;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7616 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
7617 my $singles;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7618 my $ambig_bam;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7619 my $cram;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7620 my $cram_ref;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7621 my $nucleotide_coverage;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7622 my $dovetail;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7623
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7624 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
7625 '1=s' => \$mates1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7626 '2=s' => \$mates2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7627 'path_to_bowtie=s' => \$path_to_bowtie,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7628 '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
7629 'f|fasta' => \$fasta,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7630 'q|fastq' => \$fastq,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7631 's|skip=i' => \$skip,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7632 'u|upto=i' => \$qupto,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7633 'phred33-quals' => \$phred33,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7634 'phred64-quals|solexa1' => \$phred64,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7635 'solexa-quals' => \$solexa,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7636 'n|seedmms=i' => \$mismatches,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7637 'l|seedlen=i' => \$seed_length,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7638 'no_best' => \$best,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7639 'version' => \$version,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7640 'quiet' => \$quiet,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7641 'chunkmbs=i' => \$chunk,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7642 'non_directional' => \$non_directional,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7643 'I|minins=i' => \$minins,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7644 'X|maxins=i' => \$maxins,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7645 'e|maqerr=i' => \$ceiling,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7646 'un|unmapped' => \$unmapped,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7647 'ambiguous' => \$multi_map,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7648 'o|output_dir=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
7649 'bowtie2' => \$bowtie2,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7650 'bowtie1' => \$bowtie1,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7651 'vanilla' => \$vanilla,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7652 'sam-no-hd' => \$sam_no_hd,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7653 'D=i' => \$seed_extension_fails,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7654 'R=i' => \$reseed_repetitive_seeds,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7655 'score_min=s' => \$score_min,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7656 'most_valid_alignments=i' => \$most_valid_alignments,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7657 'p=i' => \$parallel,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7658 'temp_dir=s' => \$temp_dir,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7659 'rdg=s' => \$rdg,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7660 'rfg=s' => \$rfg,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7661 'non_bs_mm' => \$non_bs_mm,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7662 '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
7663 'bam' => \$bam,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7664 'gzip' => \$gzip,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7665 'pbat' => \$pbat,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7666 'prefix=s' => \$prefix,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7667 'old_flag' => \$old_flag,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7668 'B|basename=s' => \$basename,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7669 'sam' => \$sam,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7670 '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
7671 'rg_tag' => \$rg_tag,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7672 'rg_id=s' => \$rg_id,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7673 'rg_sample=s' => \$rg_sample,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7674 'se|single_end=s' => \$singles,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7675 'ambig_bam' => \$ambig_bam,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7676 'cram' => \$cram,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7677 'cram_ref=s' => \$cram_ref,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7678 'nucleotide_coverage' => \$nucleotide_coverage,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7679 'dovetail' => \$dovetail,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7680 );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7681
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7682
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7683 ### 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
7684 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
7685 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
7686 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7687 ### HELPFILE
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7688 if ($help){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7689 print_helpfile();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7690 exit;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7691 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7692 if ($version){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7693 print << "VERSION";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7694
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7695
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7696 Bismark - Bisulfite Mapper and Methylation Caller.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7697
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7698 Bismark Version: $bismark_version
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7699 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
7700 www.bioinformatics.babraham.ac.uk/projects/
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7701
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7702
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7703 VERSION
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7704 exit;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7705 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7706
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7707
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7708 ##########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7709 ### PROCESSING OPTIONS ###
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7710 ##########################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7711
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7712 if ($bowtie1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7713 $bowtie2 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7714 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7715 else{ # Bowtie 2 is now the default mode (as of 27 July 2015)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7716 $bowtie2 = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7717 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7718
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7719 unless ($sam_no_hd){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7720 $sam_no_hd =0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7721 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7722
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7723 ### PATH TO BOWTIE
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7724 ### if a special path to Bowtie 1/2 was specified we will use that one, otherwise it is assumed that Bowtie 1/2 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
7725 if ($path_to_bowtie){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7726 unless ($path_to_bowtie =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7727 $path_to_bowtie =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7728 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7729 if (-d $path_to_bowtie){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7730 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7731 $path_to_bowtie = "${path_to_bowtie}bowtie2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7732 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7733 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7734 $path_to_bowtie = "${path_to_bowtie}bowtie";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7735 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7736 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7737 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7738 die "The path to bowtie provided ($path_to_bowtie) is invalid (not a directory)!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7739 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7740 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7741 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7742 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7743 $path_to_bowtie = 'bowtie2';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7744 warn "Path to Bowtie 2 specified as: $path_to_bowtie\n"; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7745 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7746 $path_to_bowtie = 'bowtie';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7747 warn "Path to Bowtie specified as: $path_to_bowtie\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7748 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7749 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7750
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7751
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7752 if ($sam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7753 warn "Output format manually set as SAM\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7754 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7755 elsif($cram){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7756 warn "Output format set to CRAM\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7757 if (defined $cram_ref){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7758 warn "CRAM reference given as: '$cram_ref'\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7759 unless (-e $cram_ref){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7760 die "There is a problem with the CRAM reference '$cram_ref': $!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7761 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7762
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7763 # determining full path information for the cram reference
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7764 if ($cram_ref =~/\//){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7765 if (chdir $cram_ref){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7766 my $absolute_cram_ref_folder = getcwd; ## making the genome folder path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7767 unless ($absolute_cram_ref_folder =~/\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7768 $absolute_cram_ref_folder =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7769 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7770 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7771 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7772 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7773 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7774 warn "CRAM reference not specified explicitely, regenerating from FastA reference files\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7775 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7776 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7777 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7778 $bam = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7779 warn "Output format is BAM (default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7780 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7781
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7782 ### OUTPUT REQUESTED AS BAM FILE (default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7783 if ($bam or $cram){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7784 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7785 die "Specifying BAM output is not compatible with \"--vanilla\" format. Please respecify\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7786 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7787
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7788 ### 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
7789 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
7790 # 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
7791 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
7792 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
7793 # 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
7794 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7795 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7796 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
7797 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7798 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7799 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7800 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
7801 $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
7802 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7803 $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
7804 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
7805 # 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
7806 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7807 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7808 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
7809 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7810 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7811
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7812 warn "Alignments will be written out in BAM format. Samtools path provided as: '$samtools_path'\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7813 $bam = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7814 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7815 # 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
7816 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7817 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
7818 $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
7819 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
7820 warn "Alignments will be written out in BAM format. Samtools found here: '$samtools_path'\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
7821 $bam = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7822 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7823 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7824
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7825 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
7826 $bam = 2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7827 warn "Did not find Samtools on the system. Alignments will be compressed with GZIP instead (.sam.gz)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7828 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7829 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7830 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7831
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7832 ### OPTION AMBIGUOUS BAM
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7833 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7834 unless ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7835 die "The option --ambig_bam is only available for Bowtie2 alignments\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7836 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7837 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7838
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7839
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7840 ####################################
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7841 ### PROCESSING ARGUMENTS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7842
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7843 ### GENOME FOLDER
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7844 if (defined $genome_folder){ # 25 11 2015 The genome folder may now also be defined with the option --genome_folder
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7845 # warn "Genome folder specified with --genome_folder $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
7846 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7847 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7848 $genome_folder = shift @ARGV; # mandatory
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7849 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7850
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7851 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
7852 warn "Genome folder was not specified!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7853 print_helpfile();
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7854 exit;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7855 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7856
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7857 ### checking that the genome folder, all subfolders and the required bowtie index files exist
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7858 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
7859 $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
7860 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7861
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7862 if (chdir $genome_folder){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7863 my $absolute_genome_folder = getcwd; ## making the genome folder path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7864 unless ($absolute_genome_folder =~/\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7865 $absolute_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
7866 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7867 warn "Reference genome folder provided is $genome_folder\t(absolute path is '$absolute_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
7868 $genome_folder = $absolute_genome_folder;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7869 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7870 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7871 die "Failed to move to $genome_folder: $!\nUSAGE: bismark [options] <genome_folder> {-1 <mates1> -2 <mates2> | <singles>} [<hits>] (--help for more details)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7872 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7873
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7874 my $CT_dir = "${genome_folder}Bisulfite_Genome/CT_conversion/";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7875 my $GA_dir = "${genome_folder}Bisulfite_Genome/GA_conversion/";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7876
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7877 my $bt2_small_index_present = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7878 my $bt2_large_index_present = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7879
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7880 my $bt_small_index_present = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7881 my $bt_large_index_present = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7882
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7883 if ($bowtie2){ ### Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7884
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7885 ### Checking for small indixes first (ending in .bt2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7886
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7887 # checking the integrity of $CT_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7888 chdir $CT_dir or die "Failed to move to directory $CT_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7889
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7890 my @CT_bowtie_index = ('BS_CT.1.bt2','BS_CT.2.bt2','BS_CT.3.bt2','BS_CT.4.bt2','BS_CT.rev.1.bt2','BS_CT.rev.2.bt2');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7891 foreach my $file(@CT_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7892 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7893 warn "The Bowtie 2 index of the C->T converted genome seems to be faulty or non-existant ('$file'). Please run the bismark_genome_preparation before running Bismark\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7894 $bt2_small_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7895 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7896 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7897 # checking the integrity of $GA_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7898 chdir $GA_dir or die "Failed to move to directory $GA_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7899 my @GA_bowtie_index = ('BS_GA.1.bt2','BS_GA.2.bt2','BS_GA.3.bt2','BS_GA.4.bt2','BS_GA.rev.1.bt2','BS_GA.rev.2.bt2');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7900
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7901 foreach my $file(@GA_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7902 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7903 warn "The Bowtie 2 index of the G->A converted genome seems to be faulty or non-existant ('$file'). Please run bismark_genome_preparation before running Bismark\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7904 $bt2_small_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7905 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7906 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7907
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7908 ### Using the small index preferentially
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7909 if ($bt2_small_index_present){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7910 $bt2_large_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7911 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7912 else{ # only checking for large indexes if the 'normal' one can't be found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7913 warn "\nCouldn't find a traditional small Bowtie 2 index for the genome specified (ending in .bt2). Now searching for a large index instead (64-bit index ending in .bt2l)...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7914
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7915 ### If no small small indexes were found we look for large indexes (64-bit indexes, ending in .bt2l)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7916
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7917 # checking the integrity of $CT_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7918 chdir $CT_dir or die "Failed to move to directory $CT_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7919
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7920 @CT_bowtie_index = ('BS_CT.1.bt2l','BS_CT.2.bt2l','BS_CT.3.bt2l','BS_CT.4.bt2l','BS_CT.rev.1.bt2l','BS_CT.rev.2.bt2l');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7921 foreach my $file(@CT_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7922 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7923 die "The Bowtie 2 index of the C->T converted genome seems to be faulty or non-existant ('$file'). Please run the bismark_genome_preparation before running Bismark\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7924 $bt2_large_index_present = 0; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7925 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7926
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7927 ### checking the integrity of $GA_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7928 chdir $GA_dir or die "Failed to move to directory $GA_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7929 @GA_bowtie_index = ('BS_GA.1.bt2l','BS_GA.2.bt2l','BS_GA.3.bt2l','BS_GA.4.bt2l','BS_GA.rev.1.bt2l','BS_GA.rev.2.bt2l');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7930
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7931 foreach my $file(@GA_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7932 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7933 die "The Bowtie 2 index of the G->A converted genome seems to be faulty or non-existant ('$file'). Please run bismark_genome_preparation before running Bismark\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7934 $bt2_large_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7935 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7936 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7937
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7938 if ($bt2_large_index_present){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7939 warn "64-bit large genome Bowtie 2 index found...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7940 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7941 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7942 die "Failed to detect either a standard (.bt2) or 64-bit (.bt2l) Bowtie 2 index for the genome specified. Please run the bismark_genome_preparation before launching Bismark\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7943 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7944 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7945
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7946 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7947
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7948 else{ ### Bowtie 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7949 ### Checking for small indixes first (ending in .ebwt)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7950 ### checking the integrity of $CT_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7951 chdir $CT_dir or die "Failed to move to directory $CT_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7952 my @CT_bowtie_index = ('BS_CT.1.ebwt','BS_CT.2.ebwt','BS_CT.3.ebwt','BS_CT.4.ebwt','BS_CT.rev.1.ebwt','BS_CT.rev.2.ebwt');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7953 foreach my $file(@CT_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7954 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7955 warn "The Bowtie index of the C->T converted genome seems to be faulty ($file doesn't exist). Please run bismark_genome_preparation --bowtie1 before running Bismark.\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7956 $bt_small_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7957 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7958 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7959
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7960 ### checking the integrity of $GA_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7961 chdir $GA_dir or die "Failed to move to directory $GA_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7962 my @GA_bowtie_index = ('BS_GA.1.ebwt','BS_GA.2.ebwt','BS_GA.3.ebwt','BS_GA.4.ebwt','BS_GA.rev.1.ebwt','BS_GA.rev.2.ebwt');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7963 foreach my $file(@GA_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7964 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7965 warn "The Bowtie index of the G->A converted genome seems to be faulty ($file doesn't exist). Please run bismark_genome_preparation --bowtie1 before running Bismark.\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7966 $bt_small_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7967 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7968 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7969
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7970 ### Using the small index preferentially
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7971 if ($bt_small_index_present){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7972 $bt_large_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7973 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7974 else{ # only checking for large indexes if the 'normal' one can't be found
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7975 warn "\nCouldn't find a traditional small Bowtie index for the genome specified (ending in .ebwt). Now searching for a large index instead (64-bit index ending in .ebwtl)...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7976
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7977 ### If no small small indexes were found we look for large indexes (64-bit indexes, ending in .ebwtl)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7978
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7979 ### checking the integrity of $CT_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7980 chdir $CT_dir or die "Failed to move to directory $CT_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7981 my @CT_bowtie_index = ('BS_CT.1.ebwtl','BS_CT.2.ebwtl','BS_CT.3.ebwtl','BS_CT.4.ebwtl','BS_CT.rev.1.ebwtl','BS_CT.rev.2.ebwtl');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7982 foreach my $file(@CT_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7983 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7984 warn "The Bowtie index of the C->T converted genome seems to be faulty ($file doesn't exist). Please run bismark_genome_preparation --bowtie1 before running Bismark.\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7985 $bt_large_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7986 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7987 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7988
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7989 ### checking the integrity of $GA_dir
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7990 chdir $GA_dir or die "Failed to move to directory $GA_dir: $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7991 my @GA_bowtie_index = ('BS_GA.1.ebwtl','BS_GA.2.ebwtl','BS_GA.3.ebwtl','BS_GA.4.ebwtl','BS_GA.rev.1.ebwtl','BS_GA.rev.2.ebwtl');
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7992 foreach my $file(@GA_bowtie_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7993 unless (-f $file){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7994 warn "The Bowtie index of the G->A converted genome seems to be faulty ($file doesn't exist). Please run bismark_genome_preparation --bowtie1 before running Bismark.\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7995 $bt_large_index_present = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7996 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7997 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7998
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
7999 if ($bt_large_index_present){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8000 warn "64-bit large genome Bowtie index found...\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8001 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8002 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8003 die "Failed to detect either a standard (.ebwt) or 64-bit (.ebwtl) Bowtie index for the genome specified. Please run the bismark_genome_preparation --bowtie1 before launching Bismark\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8004 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8005 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8007 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8008
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8009 my $CT_index_basename = "${CT_dir}BS_CT";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8010 my $GA_index_basename = "${GA_dir}BS_GA";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8012 ### INPUT OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8013
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8014 ### SEQUENCE FILE FORMAT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8015 ### exits if both fastA and FastQ were specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8016 if ($fasta and $fastq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8017 die "Only one sequence filetype can be specified (fastA or fastQ)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8018 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8019
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8020 ### unless fastA is specified explicitely, fastQ sequence format is expected by default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8021 if ($fasta){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8022 print "FastA 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
8023 $sequence_format = 'FASTA';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8024 push @bowtie_options, '-f';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8025 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8026 elsif ($fastq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8027 print "FastQ 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
8028 $sequence_format = 'FASTQ';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8029 push @bowtie_options, '-q';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8030 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8031 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8032 $fastq = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8033 print "FastQ format assumed (by default)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8034 $sequence_format = 'FASTQ';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8035 push @bowtie_options, '-q';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8036 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8037
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8038 ### SKIP
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8039 if ($skip){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8040 warn "Skipping the first $skip reads from the input file\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8041 # push @bowtie_options,"-s $skip";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8042 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8043
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8044 ### UPTO
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8045 if ($qupto){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8046 warn "Processing sequences up to read no. $qupto from the input file\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8047 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8048 # push @bowtie_options,"--upto $qupto"; ## slightly changed for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8049 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8050 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8051 # push @bowtie_options,"--qupto $qupto";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8052 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8053 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8054
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8055 ### QUALITY VALUES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8056 if (($phred33 and $phred64) or ($phred33 and $solexa) or ($phred64 and $solexa)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8057 die "You can only specify one type of quality value at a time! (--phred33-quals or --phred64-quals or --solexa-quals)";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8058 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8059 if ($phred33){ ## if nothing else is specified $phred33 will be used as default by both Bowtie 1 and 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8060 # Phred quality values work only when -q is specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8061 unless ($fastq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8062 die "Phred quality values works only when -q (FASTQ) is specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8063 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8064 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8065 push @bowtie_options,"--phred33";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8066 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8067 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8068 push @bowtie_options,"--phred33-quals";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8069 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8071 if ($phred64){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8072 # Phred quality values work only when -q is specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8073 unless ($fastq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8074 die "Phred quality values work only when -q (FASTQ) is specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8075 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8076 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8077 push @bowtie_options,"--phred64";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8078 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8079 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8080 push @bowtie_options,"--phred64-quals";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8081 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8082 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8083 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8084 $phred64 = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8085 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8086
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8087 if ($solexa){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8088 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8089 die "The option '--solexa-quals' is not compatible with Bowtie 2. 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
8090 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8091 # Solexa to Phred value conversion works only when -q is specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8092 unless ($fastq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8093 die "Conversion from Solexa to Phred quality values works only when -q (FASTQ) is specified\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8094 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8095 push @bowtie_options,"--solexa-quals";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8096 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8097 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8098 $solexa = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8099 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8101 ### ALIGNMENT OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8102
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8103 ### MISMATCHES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8104 if (defined $mismatches){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8105 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8106 if ($mismatches == 0 or $mismatches == 1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8107 push @bowtie_options,"-N $mismatches";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8108 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8109 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8110 die "Please set the number of multiseed mismatches for Bowtie 2 with '-N <int>' (where <int> can be 0 or 1)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8111 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8112 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8113 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8114 if ($mismatches >= 0 and $mismatches <= 3){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8115 push @bowtie_options,"-n $mismatches";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8116 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8117 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8118 die "Please set the number of seed mismatches for Bowtie 1 with '-n <int>' (where <int> can be 0,1,2 or 3)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8119 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8120 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8121 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8122 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8123 unless ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8124 push @bowtie_options,"-n 1"; # setting -n to 1 by default (for use with Bowtie only) because it is much quicker than the default mode of -n 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8125 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8126 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8127
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8128 ### SEED LENGTH
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8129 if (defined $seed_length){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8130 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8131 push @bowtie_options,"-L $seed_length";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8132 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8133 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8134 push @bowtie_options,"-l $seed_length";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8135 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8136 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8137
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8138 ### MISMATCH CEILING
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8139 if (defined $ceiling){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8140 die "The option '-e' is not compatible with Bowtie 2. Please respecify options\n" if ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8141 push @bowtie_options,"-e $ceiling";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8142 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8143
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8144
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8145 ### BOWTIE 2 EFFORT OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8146
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8147 ### CONSECUTIVE SEED EXTENSION FAILS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8148 if (defined $seed_extension_fails){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8149 die "The option '-D <int>' is only available when using Bowtie 2\n\n" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8150 push @bowtie_options,"-D $seed_extension_fails";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8151 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8152
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8153 ### RE-SEEDING REPETITIVE SEEDS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8154 if (defined $reseed_repetitive_seeds){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8155 die "The option '-R <int>' is only available when using Bowtie 2\n\n" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8156 push @bowtie_options,"-R $reseed_repetitive_seeds";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8157 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8158
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8159
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8160 ### BOWTIE 2 SCORING OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8161
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8162 my ($score_min_intercept, $score_min_slope);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8163
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8164 if ($score_min){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8165 die "The option '--score_min <func>' is only available when using Bowtie 2\n\n" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8166
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8167 unless ($score_min =~ /^L,(.+),(.+)$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8168 die "The option '--score_min <func>' needs to be in the format <L,value,value> . Please consult \"setting up functions\" in the Bowtie 2 manual for further information\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8169 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8170 ($score_min_intercept, $score_min_slope) = ($1, $2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8171 push @bowtie_options,"--score-min L,$score_min_intercept,$score_min_slope"; # default setting, more stringent than normal Bowtie2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8172 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8173 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8174 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8175 ($score_min_intercept, $score_min_slope) = (0, -0.2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8176 push @bowtie_options,"--score-min L,$score_min_intercept,$score_min_slope"; # default setting, more stringent than normal Bowtie2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8177 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8178 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8179
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8180 ### BOWTIE 2 READ GAP OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8181 my ($insertion_open,$insertion_extend,$deletion_open,$deletion_extend);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8182
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8183 if ($rdg){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8184 die "The option '--rdg <int1>,<int2>' is only available when using Bowtie 2\n\n" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8185 if ($rdg =~ /^(\d+),(\d+)$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8186 $deletion_open = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8187 $deletion_extend = $2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8188 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8189 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8190 die "The option '--rdg <int1>,<int2>' needs to be in the format <integer,integer> . Please consult \"setting up functions\" in the Bowtie 2 manual for further information\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8191 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8192 push @bowtie_options,"--rdg $rdg";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8193 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8194 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8195 $deletion_open = 5;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8196 $deletion_extend = 3;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8197 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8198
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8199 ### BOWTIE 2 REFERENCE GAP OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8200 if ($rfg){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8201 die "The option '--rfg <int1>,<int2>' is only available when using Bowtie 2\n\n" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8202 if ($rfg =~ /^(\d+),(\d+)$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8203 $insertion_open = $1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8204 $insertion_extend = $2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8205 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8206 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8207 die "The option '--rfg <int1>,<int2>' needs to be in the format <integer,integer> . Please consult \"setting up functions\" in the Bowtie 2 manual for further information\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8208 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8209 push @bowtie_options,"--rfg $rfg";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8210 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8211 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8212 $insertion_open = 5;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8213 $insertion_extend = 3;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8214 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8215
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8216
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8217 ### BOWTIE 2 PARALLELIZATION OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8218 if (defined $parallel){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8219 die "The parallelization switch '-p' only works for Bowtie 2. Please respecify!" unless ($bowtie2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8220 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8221 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8222 if ($parallel){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8223 die "Please select a value for -p of 2 or more!\n" unless ($parallel > 1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8224 if ($parallel > 4){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8225 warn "Attention: using more than 4 cores per alignment thread has been reported to have diminishing returns. If possible try to limit -p to a value of 4\n"; sleep(2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8226 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8227 push @bowtie_options,"-p $parallel";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8228 push @bowtie_options,'--reorder'; ## re-orders the bowtie 2 output so that it does match the input files. This is abolutely required for parallelization to work.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8229 print "Each Bowtie 2 instance is going to be run with $parallel threads. Please monitor performance closely and tune down if needed!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8230 sleep (2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8231 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8232 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8233
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8234 ### REPORTING OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8235
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8236 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8237 push @bowtie_options,'--ignore-quals'; ## All mismatches will receive penalty for mismatches as if they were of high quality, which is 6 by default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8238
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8239 ### Option -M is deprecated since Bowtie 2 version 2.0.0 beta7. I'll leave this option commented out for a while
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8240 if(defined $most_valid_alignments){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8241
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8242 warn "\nThe option -M is now deprecated (as of Bowtie 2 version 2.0.0 beta7). What used to be called -M mode is still the default mode. Use the -D and -R options to adjust the effort expended to find valid alignments.\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8243 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8244 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8245 else{ # Because of the way Bismark works we will always use the reporting option -k 2 (report up to 2 valid alignments) for Bowtie 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8246 push @bowtie_options,'-k 2';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8247 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8248
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8249 ### --BEST
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8250 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8251 if ($best){ # Bowtie 2 does away with the concept of --best, so one can also not select --no-best when Bowtie 2 is to be used
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8252 die "The option '--no-best' is not compatible with Bowtie 2. Please respecify options\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8253 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8254 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8255 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8256 # --best is the default option for Bowtie 1, specifying --no-best can turn it off (e.g. to speed up alignment process)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8257 unless ($best){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8258 push @bowtie_options,'--best';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8259 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8260 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8261
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8262 ### VANILLA BISMARK (BOWTIE 1) OUTPUT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8263 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8264 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8265 die "The options --bowtie2 and the --vanilla are not compatible. Please respecify!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8266 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8267 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8268 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8269 $vanilla = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8270 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8271
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8272 ### PAIRED-END MAPPING
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8273 if ($mates1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8274
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8275 if (defined $singles){ # if --single_end has been set explicitely
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8276 die "You cannot set --single_end and supply files in paired-end format (-1 <mates1> -2 <mates2>). 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
8277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8278
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8279 my @mates1 = (split (/,/,$mates1));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8280 die "Paired-end mapping requires the format: -1 <mates1> -2 <mates2>, please respecify!\n" unless ($mates2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8281 my @mates2 = (split(/,/,$mates2));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8282 unless (scalar @mates1 == scalar @mates2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8283 die "Paired-end mapping requires the same amounnt of mate1 and mate2 files, please respecify! (format: -1 <mates1> -2 <mates2>)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8284 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8285 while (1){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8286 my $mate1 = shift @mates1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8287 my $mate2 = shift @mates2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8288 last unless ($mate1 and $mate2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8289 push @filenames,"$mate1,$mate2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8290 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8291 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8292 push @bowtie_options,'--no-mixed'; ## By default Bowtie 2 is not looking for single-end alignments if it can't find concordant or discordant alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8293 push @bowtie_options,'--no-discordant';## By default Bowtie 2 is not looking for discordant alignments if it can't find concordant ones
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8294
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8295 if ($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8296 $dovetail = 1; # setting the option $dovetail for PBAT 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
8297 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8298
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8299 if ($dovetail){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8300 if ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8301 die "The option --dovetail may only be specified with the current SAM FLAG values. 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
8302 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8303 push @bowtie_options,'--dovetail'; ## 07 03 2016 Adding the option --dovetail, mainly for PBAT alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8304 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8305 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8306
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8307 if ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8308 warn "\nUsing FLAG values for paired-end SAM output used up to Bismark v0.8.2. In addition, paired-end sequences will have /1 and /2 appended to their read IDs\n\n" unless($vanilla);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8309 sleep(3);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8310 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8311 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8312 elsif ($mates2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8313 die "Paired-end mapping requires the format: -1 <mates1> -2 <mates2>, 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
8314 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8315
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8316 ### SINGLE-END MAPPING
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8317 # Single-end mapping will be performed if no mate pairs for paired-end mapping have been specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8318
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8319 unless ($mates1 and $mates2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8320 if (defined $singles){ # if --single_end has been set explicitely
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8321 warn "Mapping set to single-end mode (user defined). File names need to be separated by commas [,] or colons [:]! Supplied file names are: $singles\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8322 $singles =~ s/:/,/g; # replacing colons (:) with commas
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8323 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8324 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8325 $singles = join (',',@ARGV);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8326 unless ($singles){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8327 die "\nNo filename supplied! Please specify one or more files for single-end Bismark mapping!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8328 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8329 $singles =~ s/\s/,/g; # replacing spaces with commas
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8330 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8331
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8332 @filenames = (split(/,/,$singles));
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8333 warn "\nFiles to be analysed:\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8334 warn "@filenames\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8335 sleep (3);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8336 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8337
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8338 ### MININUM INSERT SIZE (PAIRED-END ONLY)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8339 if (defined $minins){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8340 die "-I/--minins can only be used for paired-end mapping!\n\n" if ($singles);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8341 push @bowtie_options,"--minins $minins";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8342 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8343
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8344 ### MAXIMUM INSERT SIZE (PAIRED-END ONLY)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8345 if (defined $maxins){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8346 die "-X/--maxins can only be used for paired-end mapping!\n\n" if ($singles);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8347 push @bowtie_options,"--maxins $maxins";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8348 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8349 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8350 unless ($singles){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8351 push @bowtie_options,'--maxins 500';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8352 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8353 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8354
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8355 ### QUIET prints nothing besides alignments (suppresses warnings)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8356 if ($quiet){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8357 push @bowtie_options,'--quiet';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8358 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8359
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8360 ### CHUNKMBS needed to be increased to avoid memory exhaustion warnings for Bowtie 1, particularly for --best (and 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
8361 unless ($bowtie2){ # Bowtie 2 does not have a chunkmbs option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8362 if (defined $chunk){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8363 push @bowtie_options,"--chunkmbs $chunk";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8364 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8365 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8366 push @bowtie_options,'--chunkmbs 512'; ## setting the default to 512MB (up from 64 default)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8367 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8368 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8369
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8370
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8371 ### SUMMARY OF ALL BOWTIE OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8372 my $bowtie_options = join (' ',@bowtie_options);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8373
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8374
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8375 ### STRAND-SPECIFIC LIBRARIES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8376 my $directional;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8377 if ($non_directional){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8378 die "A library can only be specified to be either non-directional or a PBAT-Seq library. Please respecify!\n\n" if ($pbat);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8379 warn "Library was specified to be not strand-specific (non-directional), therefore alignments to all four possible bisulfite strands (OT, CTOT, OB and CTOB) will be reported\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8380 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8381 $directional = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8382 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8383 elsif($pbat){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8384 die "The option --pbat is currently not compatible with --gzip. Please run alignments with uncompressed temporary files, i.e. lose the option --gzip\n" if ($gzip);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8385 die "The option --pbat is currently only working with FastQ files. Please respecify (i.e. lose the option -f)!\n" if ($fasta);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8386
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8387 warn "Library was specified as PBAT-Seq (Post-Bisulfite Adapter Tagging), only performing alignments to the complementary strands (CTOT and CTOB)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8388 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8389 $directional = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8390 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8391 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8392 warn "Library is assumed to be strand-specific (directional), alignments to strands complementary to the original top or bottom strands will be ignored (i.e. not performed!)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8393 sleep (1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8394 $directional = 1; # default behaviour
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8395 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8396
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8397 ### UNMAPPEDSEQUENCE OUTPUT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8398 $unmapped = 0 unless ($unmapped);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8399
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8400 ### AMBIGUOUS ALIGNMENT SEQUENCE OUTPUT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8401 $multi_map = 0 unless ($multi_map);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8402
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8403
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8404 ### OUTPUT DIRECTORY
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8405
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8406 chdir $parent_dir or die "Failed to move back to current working directory\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8407 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
8408 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
8409 $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
8410 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8411
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8412 if (chdir $output_dir){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8413 $output_dir = getcwd; # making the path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8414 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
8415 $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
8416 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8417 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8418 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8419 mkdir $output_dir or die "Unable to create directory $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
8420 warn "Created output directory $output_dir!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8421 chdir $output_dir or die "Failed to move to $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
8422 $output_dir = getcwd; # making the path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8423 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
8424 $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
8425 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8426 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8427 warn "Output will be written into the directory: $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
8428 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8429 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8430 $output_dir = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8431 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8432
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8433 ### TEMPORARY DIRECTORY for C->T and G->A transcribed files
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8434
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8435 chdir $parent_dir or die "Failed to move back to current working directory\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8436 if ($temp_dir){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8437 warn "\nUsing temp directory: $temp_dir\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8438 unless ($temp_dir =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8439 $temp_dir =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8441
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8442 if (chdir $temp_dir){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8443 $temp_dir = getcwd; # making the path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8444 unless ($temp_dir =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8445 $temp_dir =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8446 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8447 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8448 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8449 mkdir $temp_dir or die "Unable to create directory $temp_dir $!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8450 warn "Created temporary directory $temp_dir!\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8451 chdir $temp_dir or die "Failed to move to $temp_dir\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8452 $temp_dir = getcwd; # making the path absolute
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8453 unless ($temp_dir =~ /\/$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8454 $temp_dir =~ s/$/\//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8455 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8456 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8457 warn "Temporary files will be written into the directory: $temp_dir\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8458 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8459 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8460 $temp_dir = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8461 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8462
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8463 ### OPTIONAL NON-BS MISMATCH OUTPUT AS EXTRA COLUMN IN SAM FILE
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8464 if ($non_bs_mm){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8465 if ($vanilla){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8466 die "Option '--non_bs_mm' may only be specified for output in SAM format. 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
8467 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8468 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8469
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8470 ### PREFIX FOR OUTPUT FILES
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8471 if ($prefix){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8472 # removing trailing dots
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8473
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8474 $prefix =~ s/\.+$//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8475
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8476 warn "Using the following prefix for output files: $prefix\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8477 sleep(1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8478 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8479
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8480 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
8481 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
8482 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
8483 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8484 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
8485 warn "Core usage currently set to more than 20 threads. This might fail horribly but let's see how it 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
8486 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8487 if ($sam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8488 die "The multicore function currently requires the output to be in BAM format, so please lose either option --sam or --multi\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8489 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8490 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8491 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8492 $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
8493 warn "Setting parallelization to single-threaded (default)\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8494 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8495
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8496 if ($basename 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
8497 die "Specifying --basename in conjuction with --multicore is currently not supported (but we are aiming to fix this soon). Please lose either --basename or --multicore to proceed\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8498 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8499
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8500 # Read Group Tags for the @RG header
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8501 if (defined $rg_sample){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8502 if (defined $rg_id){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8503 warn "--rg_id set to '$rg_id', setting --rg_tag to TRUE\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8504 $rg_tag++; # implicitely setting $rg_tag as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8505 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8506 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8507 die "--rg_sample cannot be specified without without setting --rg_id. Please set both or none (which would result in the default name 'SAMPLE' for both)\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8508 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8509 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8510
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8511 if ($rg_tag){ # either true because of --rg_tag, or because --rg_id/--rg_sample were defined as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8512 unless (defined $rg_id){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8513 $rg_id = 'SAMPLE';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8514 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8515 unless (defined $rg_sample){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8516 $rg_sample = 'SAMPLE';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8517 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8518 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8519
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8520 return ($genome_folder,$CT_index_basename,$GA_index_basename,$path_to_bowtie,$sequence_format,$bowtie_options,$directional,$unmapped,$multi_map,$phred64,$solexa,$output_dir,$bowtie2,$vanilla,$sam_no_hd,$skip,$qupto,$temp_dir,$non_bs_mm,$insertion_open,$insertion_extend,$deletion_open,$deletion_extend,$gzip,$bam,$samtools_path,$pbat,$prefix,$old_flag,$basename,$score_min_intercept,$score_min_slope,$bt2_large_index_present,$multicore,$rg_tag,$rg_id,$rg_sample,$ambig_bam,$cram,$cram_ref,$nucleotide_coverage,$dovetail);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8521 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8522
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8523
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8524
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8525 sub generate_SAM_header{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8526
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8527 print OUT "\@HD\tVN:1.0\tSO:unsorted\n"; # @HD = header, VN = version, SO = sort order
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8528 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8529 print AMBIBAM "\@HD\tVN:1.0\tSO:unsorted\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8530 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8531
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8532 # Unordered printing of @SQ headers
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8533 # foreach my $chr (keys %chromosomes){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8534 # my $length = length ($chromosomes{$chr});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8535 # print "\@SQ\tSN:$chr\tLN:$length\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8536 # print OUT "\@SQ\tSN:$chr\tLN:$length\n"; # @SQ = sequence, SN = seq name, LN = length
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8537 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8538
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8539 foreach my $chr (sort {$a<=>$b} keys %SQ_order){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8540 # warn "$chr\t$SQ_order{$chr}\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8541 my $length = length ($chromosomes{$SQ_order{$chr}});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8542 print OUT "\@SQ\tSN:$SQ_order{$chr}\tLN:$length\n"; # @SQ = sequence, SN = seq name, LN = length
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8543 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8544 print AMBIBAM "\@SQ\tSN:$SQ_order{$chr}\tLN:$length\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8545 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8546 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8547
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8548 # 18 11 2015: Added @RG as a header line if --rg_tag or --rg_id/--rg_sample were set as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8549 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8550 print OUT "\@RG\tPL:ILLUMINA\tID:$rg_id\tSM:$rg_sample\n"; # @RG = Read Group, PL = Platform, ID: required, SM: sample, can be a description
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8551 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8552
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8553 print OUT "\@PG\tID:Bismark\tVN:$bismark_version\tCL:\"bismark $command_line\"\n"; # @PG = program, ID = unique identifier, PN = program name name, VN = program version
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8554 if ($ambig_bam){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8555 print AMBIBAM "\@PG\tID:Bismark\tVN:$bismark_version\tCL:\"bismark $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
8556 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8557 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8558
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8559 ### I would like to thank the following individuals for their valuable contributions to the Bismark SAM output format:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8560 ### O. Tam (2010), C. Whelan (2011), E. Vidal (2011), T. McBryan (2011), P. Hickey (2011), A. Dei Rossi (2014)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8561
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8562 sub single_end_SAM_output{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8563
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8564 my ($id,$actual_seq,$methylation_call_params,$qual) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8565 my $strand = $methylation_call_params->{$id}->{alignment_strand};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8566 my $chr = $methylation_call_params->{$id}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8567 my $start = $methylation_call_params->{$id}->{position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8568 my $stop = $methylation_call_params->{$id}->{end_position};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8569 my $ref_seq = $methylation_call_params->{$id}->{unmodified_genomic_sequence};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8570 my $methcall = $methylation_call_params->{$id}->{methylation_call};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8571 my $read_conversion = $methylation_call_params->{$id}->{read_conversion};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8572 my $genome_conversion = $methylation_call_params->{$id}->{genome_conversion};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8573 my $number_of_mismatches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8574
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8575 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8576 $number_of_mismatches= $methylation_call_params->{$id}->{alignment_score};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8577 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8578 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8579 $number_of_mismatches= $methylation_call_params->{$id}->{number_of_mismatches};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8580 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8581
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8582 ### This is a description of the bitwise FLAG field which needs to be set for the SAM file taken from: "The SAM Format Specification (v1.4-r985), September 7, 2011"
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8583 ## FLAG: bitwise FLAG. Each bit is explained in the following table:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8584 ## Bit Description Comment Value
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8585 ## 0x1 template has multiple segments in sequencing 0: single-end 1: paired end value: 2**0 ( 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8586 ## 0x2 each segment properly aligned according to the aligner true only for paired-end alignments value: 2**1 ( 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8587 ## 0x4 segment unmapped --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8588 ## 0x8 next segment in the template unmapped --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8589 ## 0x10 SEQ being reverse complemented value: 2**4 ( 16)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8590 ## 0x20 SEQ of the next segment in the template being reversed value: 2**5 ( 32)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8591 ## 0x40 the first segment in the template read 1 value: 2**6 ( 64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8592 ## 0x80 the last segment in the template read 2 value: 2**7 (128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8593 ## 0x100 secondary alignment --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8594 ## 0x200 not passing quality controls --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8595 ## 0x400 PCR or optical duplicate --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8596
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8597 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8598
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8599 my $flag; # FLAG variable used for SAM format.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8600 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
8601 if ($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
8602 $flag = 0; # 0 for "+" strand (OT)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8603 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8604 elsif ($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
8605 $flag = 16; # 16 for "-" strand (CTOB, yields information for the 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
8606 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8607 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8608 die "Unexpected strand and read/genome conversion: strand: $strand, read conversion: $read_conversion, genome_conversion: $genome_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
8609 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8610 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8611 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
8612 if ($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
8613 $flag = 16; # 16 for "-" strand (OB)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8614 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8615 elsif ($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
8616 $flag = 0; # 0 for "+" strand (CTOT, yields information for the 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
8617 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8618 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8619 die "Unexpected strand and read/genome conversion: strand: $strand, read conversion: $read_conversion, genome_conversion: $genome_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
8620 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8621 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8622 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8623 die "Unexpected strand information: $strand\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8624 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8625
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8626 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8627
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8628 my $mapq;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8629
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8630 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8631 $mapq = $methylation_call_params->{$id}->{mapq};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8632 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8633 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8634 $mapq = 255; # Mapping quality is unavailable for use with Bowtie
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8635 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8636
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8637 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8638
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8639 my $cigar;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8640 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8641 $cigar = $methylation_call_params->{$id}->{CIGAR}; # Actual CIGAR string reported by Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8642 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8643 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8644 $cigar = length($actual_seq) . "M"; # Bowtie 1 output does not contain indels (only matches and mismatches)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8645 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8646
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8647 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8648
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8649 my $rnext = "*"; # Paired-end variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8650
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8651 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8652
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8653 my $pnext = 0; # Paired-end variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8654
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8655 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8656
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8657 my $tlen = 0; # Paired-end variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8658
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8659 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8660
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8661 if ($read_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
8662 $ref_seq = substr($ref_seq, 0, length($ref_seq) - 2); # Removes additional nucleotides from the 3' end. This only works for the original top or bottom strands
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8663 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8664 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8665 $ref_seq = substr($ref_seq, 2, length($ref_seq) - 2); # Removes additional nucleotides from the 5' end. This works for the complementary strands in non-directional libraries
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8666 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8667
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8668 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
8669 $actual_seq = revcomp($actual_seq); # Sequence represented on the forward genomic strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8670 $ref_seq = revcomp($ref_seq); # Required for comparison with actual sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8671 if ($cigar =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8672 $methylation_call_params->{$id}->{genomic_seq_for_MD_tag} = revcomp( $methylation_call_params->{$id}->{genomic_seq_for_MD_tag} );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8673 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8674 $qual = reverse $qual; # if the sequence was reverse-complemented the quality string needs to be reversed as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8675 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8676
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8677 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8678
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8679 my $hemming_dist = hemming_dist($actual_seq,$ref_seq); # Edit distance to the reference, i.e. minimal number of one-nucleotide edits needed to transform the read string
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8680 # into the reference string. hemming_dist()
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8681 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8682 $hemming_dist += $methylation_call_params->{$id}->{indels}; # Adding the number of inserted/deleted bases which we parsed while getting the genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8683 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8684
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8685 my $NM_tag = "NM:i:$hemming_dist"; # Optional tag NM: edit distance based on nucleotide differences
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8686
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8687 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8688
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8689 my $MD_tag = make_mismatch_string($actual_seq, $ref_seq,$cigar,$methylation_call_params->{$id}->{genomic_seq_for_MD_tag}); # Optional tag MD: string providing mismatched reference bases in the alignment (this does include indel information)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8690 # my $XX_tag = make_mismatch_string($actual_seq, $ref_seq); # Optional tag XX: string providing mismatched reference bases in the alignment (NO indel information!)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8691
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8692 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8693
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8694 my $XM_tag; # Optional tag XM: 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
8695 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
8696 $XM_tag = "XM:Z:$methcall";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8697 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8698 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
8699 $XM_tag = 'XM:Z:'.reverse $methcall; # if the sequence was reverse-complemented the methylation call string needs to be reversed as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8700 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8701
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8702 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8703
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8704 my $XR_tag = "XR:Z:$read_conversion"; # Optional tag XR: Read Conversion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8705
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8706 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8707
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8708 my $XG_tag = "XG:Z:$genome_conversion"; # Optional tag XG: Genome Conversion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8709
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8710 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8711
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8712 # Optionally calculating number of mismatches for Bowtie 2 alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8713
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8714 if ($non_bs_mm) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8715 if ($bowtie2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8716
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8717 $number_of_mismatches =~ s/-//; # removing the minus sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8718
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8719 ### if Bowtie 2 was used we need to analyse the CIGAR string whether the read contained any indels to determine the number of mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8720 if ($cigar =~ /(D|I)/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8721 # warn "$cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8722
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8723 # 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
8724 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
8725 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
8726 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
8727 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
8728
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8729 foreach (0..$#len) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8730 if ($ops[$_] eq 'M') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8731 # warn "skipping\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8732 next; # irrelevant
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8733 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8734 elsif ($ops[$_] 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
8735 $number_of_mismatches -= $insertion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8736 $number_of_mismatches -= $len[$_] * $insertion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8737 # warn "Insertion: Subtracting $ops[$_], length $len[$_], open: $insertion_open, extend: $insertion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8738 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8739 elsif ($ops[$_] 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
8740 $number_of_mismatches -= $deletion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8741 $number_of_mismatches -= $len[$_] * $deletion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8742 # warn "Deletion: Subtracting $ops[$_], length $len[$_], open: $deletion_open, extend: $deletion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8743 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8744 elsif ($cigar =~ tr/[NSHPX=]//) { # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8745 die "The CIGAR string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8746 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8747 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8748 die "The CIGAR string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $cigar\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8749 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8750 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8751 # warn "Alignment score $number_of_mismatches\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8752 # print "Mismatches $number_of_mismatches\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8753 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8754 ### Now we have InDel corrected alignment scores
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8755
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8756 ### if the actual sequence contained Ns we need to adjust the number of mismatches. Ns receive a penalty of -1, but normal mismatches receive -6. This might still break if the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8757 ### sequence contained more than 5 Ns, but this should occur close to never
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8758
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8759 my $seq_N_count = $number_of_mismatches % 6; # modulo 6 will return the integer rest after the division
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8760 # warn "N count: $seq_N_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8761 $number_of_mismatches = int ($number_of_mismatches / 6) + $seq_N_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8762 # warn "MM $number_of_mismatches\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8763 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8764 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8765
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8766 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8767
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8768 my $XA_tag = "XA:Z:$number_of_mismatches";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8769
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8770 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8771
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8772 my $read_group; # optional
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8773 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8774 $read_group = "RG:Z:$rg_id";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8775 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8776
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8777 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8778
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8779 # SAM format: QNAME, FLAG, RNAME, 1-based POS, MAPQ, CIGAR, RNEXT, PNEXT, TLEN, SEQ, QUAL, optional fields
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8780 ### optionally print number of non-bisulfite mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8781 if ($non_bs_mm){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8782 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8783 print OUT join("\t",($id,$flag,$chr,$start,$mapq,$cigar,$rnext,$pnext,$tlen,$actual_seq,$qual,$NM_tag,$MD_tag,$XM_tag,$XR_tag,$XG_tag,$XA_tag,$read_group)),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8784 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8785 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8786 print OUT join("\t",($id,$flag,$chr,$start,$mapq,$cigar,$rnext,$pnext,$tlen,$actual_seq,$qual,$NM_tag,$MD_tag,$XM_tag,$XR_tag,$XG_tag,$XA_tag)),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8787 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8788 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8789 else{ # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8790 # SAM format: QNAME, FLAG, RNAME, 1-based POS, MAPQ, CIGAR, RNEXT, PNEXT, TLEN, SEQ, QUAL, optional fields
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8791 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8792 print OUT join("\t",($id,$flag,$chr,$start,$mapq,$cigar,$rnext,$pnext,$tlen,$actual_seq,$qual,$NM_tag,$MD_tag,$XM_tag,$XR_tag,$XG_tag,$read_group)),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8793 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8794 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8795 print OUT join("\t",($id,$flag,$chr,$start,$mapq,$cigar,$rnext,$pnext,$tlen,$actual_seq,$qual,$NM_tag,$MD_tag,$XM_tag,$XR_tag,$XG_tag)),"\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8796 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8797 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8798 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8799
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8800 sub paired_end_SAM_output{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8801
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8802 my ($id,$actual_seq_1,$actual_seq_2,$methylation_call_params,$qual_1,$qual_2) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8803 my $strand_1 = $methylation_call_params->{$id}->{alignment_read_1}; # Bowtie 1 only reports the read 1 alignment strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8804 my $strand_2 = $methylation_call_params->{$id}->{alignment_read_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8805 my $chr = $methylation_call_params->{$id}->{chromosome};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8806 my $ref_seq_1 = $methylation_call_params->{$id}->{unmodified_genomic_sequence_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8807 my $ref_seq_2 = $methylation_call_params->{$id}->{unmodified_genomic_sequence_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8808 my $methcall_1 = $methylation_call_params->{$id}->{methylation_call_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8809 my $methcall_2 = $methylation_call_params->{$id}->{methylation_call_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8810 my $read_conversion_1 = $methylation_call_params->{$id}->{read_conversion_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8811 my $read_conversion_2 = $methylation_call_params->{$id}->{read_conversion_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8812 my $genome_conversion = $methylation_call_params->{$id}->{genome_conversion};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8813
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8814 my $id_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8815 my $id_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8816
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8817 if ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8818 $id_1 = $id.'/1';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8819 $id_2 = $id.'/2';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8820 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8821 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8822 $id_1 = $id; # appending /1 or /2 confuses some downstream programs such as Picard
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8823 $id_2 = $id;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8824 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8825
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8826 # Allows all degenerate nucleotide sequences in reference genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8827 # die "Reference sequence ($ref_seq_1) contains invalid nucleotides!\n" if $ref_seq_1 =~ /[^ACTGNRYMKSWBDHVX]/i; # X are padded nucleotides in case of insertions 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
8828 # die "Reference sequence ($ref_seq_2) contains invalid nucleotides!\n" if $ref_seq_2 =~ /[^ACTGNRYMKSWBDHVX]/i;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8829
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8830 my $index; # used to store the srand origin of the alignment in a less convoluted way
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8831
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8832 if ($read_conversion_1 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
8833 $index = 0; ## this is 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
8834 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8835 elsif ($read_conversion_1 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
8836 $index = 1; ## this is CTOB (complementary to OB)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8837 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8838 elsif ($read_conversion_1 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
8839 $index = 2; ## this is CTOT (complementary to OT)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8840 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8841 elsif ($read_conversion_1 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
8842 $index = 3; ## this is OB (original bottom)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8843 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8844 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8845 die "Unexpected combination of read 1 and genome conversion: $read_conversion_1 / $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
8846 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8847
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8848 my $number_of_mismatches_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8849 my $number_of_mismatches_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8850
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8851 if ($bowtie2){ # Bowtie 2 reports always as read 1 then read 2, so this is fine
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8852 $number_of_mismatches_1 = $methylation_call_params->{$id}->{alignment_score_1}; # only needed for custom allele-specific output, not the default!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8853 $number_of_mismatches_2 = $methylation_call_params->{$id}->{alignment_score_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8854 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8855 else{ # Bowtie 1 reports always the leftmost read first. That means we have to reverse the strings if the first read aligned in reverse orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8856 if ($index == 2 or $index == 3){ # CTOT or OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8857 $number_of_mismatches_1 = $methylation_call_params->{$id}->{number_of_mismatches_2}; # only needed for custom allele-specific output, not the default!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8858 $number_of_mismatches_2 = $methylation_call_params->{$id}->{number_of_mismatches_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8859 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8860 else{ # if the first read aligned in forward direction it is like for Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8861 $number_of_mismatches_1 = $methylation_call_params->{$id}->{number_of_mismatches_1}; # only needed for custom allele-specific output, not the default!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8862 $number_of_mismatches_2 = $methylation_call_params->{$id}->{number_of_mismatches_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8863 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8864 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8865
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8866
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8867
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8868 ### 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
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8869 ### first or last position.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8870
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8871 if ($index == 0 or $index == 3){ # OT or OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8872 $ref_seq_1 = substr($ref_seq_1,0,length($ref_seq_1)-2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8873 $ref_seq_2 = substr($ref_seq_2,2,length($ref_seq_2)-2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8874 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8875 else{ # CTOT or CTOB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8876 $ref_seq_1 = substr($ref_seq_1,2,length($ref_seq_1)-2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8877 $ref_seq_2 = substr($ref_seq_2,0,length($ref_seq_2)-2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8878 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8879
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8880 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8881
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8882 my $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
8883 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
8884 # adjusting end positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8885
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8886 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8887 $start_read_1 = $methylation_call_params->{$id}->{position_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8888 $start_read_2 = $methylation_call_params->{$id}->{position_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8889 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8890 else{ # Bowtie 1 output. $strand_1 stores the alignment of Read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8891 if ($strand_1 eq '+'){ # Read 1 aligns to the + strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8892 $start_read_1 = $methylation_call_params->{$id}->{start_seq_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8893 $start_read_2 = $methylation_call_params->{$id}->{alignment_end} - length ($actual_seq_2) + 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8894 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8895 else{ # read 1 is on the - strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8896 $start_read_1 = $methylation_call_params->{$id}->{alignment_end} - length ($actual_seq_1) + 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8897 $start_read_2 = $methylation_call_params->{$id}->{start_seq_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8898 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8899 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8900
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8901 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8902
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8903 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
8904 my $end_read_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8905 # adjusting end positions
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8906
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8907 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8908 $end_read_1 = $methylation_call_params->{$id}->{end_position_1};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8909 $end_read_2 = $methylation_call_params->{$id}->{end_position_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8910 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8911 else{ # Bowtie 1 output. $strand_1 stores the alignment of Read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8912 if ($strand_1 eq '+'){ # Read 1 aligns to the + strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8913 $end_read_1 = $methylation_call_params->{$id}->{start_seq_1} + length ($actual_seq_1)-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8914 $end_read_2 = $methylation_call_params->{$id}->{alignment_end};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8915 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8916 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8917 $end_read_1 = $methylation_call_params->{$id}->{alignment_end};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8918 $end_read_2 = $methylation_call_params->{$id}->{start_seq_1} + length ($actual_seq_2)-1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8919 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8920 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8921
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8922 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8923
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8924 ### This is a description of the bitwise FLAG field which needs to be set for the SAM file taken from: "The SAM Format Specification (v1.4-r985), September 7, 2011"
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8925 ## FLAG: bitwise FLAG. Each bit is explained in the following table:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8926 ## Bit Description Comment Value
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8927 ## 0x1 template having multiple segments in sequencing 0: single-end 1: paired end value: 2^^0 ( 1)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8928 ## 0x2 each segment properly aligned according to the aligner true only for paired-end alignments value: 2^^1 ( 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8929 ## 0x4 segment unmapped --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8930 ## 0x8 next segment in the template unmapped --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8931 ## 0x10 SEQ being reverse complemented - strand alignment value: 2^^4 ( 16)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8932 ## 0x20 SEQ of the next segment in the template being reversed + strand alignment value: 2^^5 ( 32)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8933 ## 0x40 the first segment in the template read 1 value: 2^^6 ( 64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8934 ## 0x80 the last segment in the template read 2 value: 2^^7 (128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8935 ## 0x100 secondary alignment --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8936 ## 0x200 not passing quality controls --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8937 ## 0x400 PCR or optical duplicate --- ---
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8938
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8939 ### As the FLAG value do not consider that there might be 4 different bisulfite strands of DNA, we are trying to make FLAG tags which take the strand identity into account
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8940
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8941 # strands OT and CTOT will be treated as aligning to the top strand (both sequences are scored as aligning to the top strand)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8942 # strands OB and CTOB will be treated as aligning to the bottom strand (both sequences are scored as reverse complemented sequences)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8943
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8944 my $flag_1; # FLAG variable used for SAM format
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8945 my $flag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8946
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8947 ### The new default FLAG values were changed on 21 07 2015, so that reads do not ignored as discordant reads by the new SeqMonk BAM import
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8948 ### In essence we are going to flip the R1 R2 flags around for CTOT and CTOB reads. We still report the first and second read in the same
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8949 ### order and only change the actual FLAG value. This should not affect the methylation extraction in any way
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8950
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8951 if ($index == 0){ # OT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8952 unless ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8953 $flag_1 = 99; # Read 1 is on the + strand and Read 2 is reversed (1+2+32+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8954 $flag_2 = 147; # Read 2 is reverse complemented but informative for the OT (1+2+16+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8955 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8956 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8957 $flag_1 = 67; # Read 1 is on the + strand (1+2+64) (Read 2 is technically reverse-complemented, but we do not score it)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8958 $flag_2 = 131; # Read 2 is on - strand but informative for the OT (1+2+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8959 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8960 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8961 elsif ($index == 1){ # CTOB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8962 unless($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8963 $flag_1 = 163; # Read 1 is on the forward strand (CTOB) and Read 2 is reverse complemented but we swap round the FLAG
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8964 # for R1 and R2 so that we don't end up with discordant pairs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8965 # So Read 1 gets Paired read, mapped in proper pair, mate is reversed and second in pair (1+2+32+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8966 $flag_2 = 83; # Read 2 gets Read paired, mapped in proper pair, first in pair and Read 2 is reversed (1+2+16+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8967 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8968 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8969 $flag_1 = 115; # Read 1 is on the + strand, we score for OB (1+2+16+32+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8970 $flag_2 = 179; # Read 2 is on the - strand (1+2+16+32+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8971 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8972 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8973 elsif ($index == 2){ # CTOT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8974 unless ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8975 $flag_1 = 147; # Read 1 is reverse complemented (CTOT) and Read 2 is the forward read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8976 # but we swap round the FLAG for R1 and R2 so that we do not end up with discordant pairs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8977 # So Read 1 gets Read paired, read mapped in proper pair, read reverse complemented and second in pair (1+2+32+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8978 $flag_2 = 99; # Read 2 gets Read paired, read mapped in proper pair, mate reverse strand and First in Pair (1+2+32+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8979 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8980 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8981 $flag_1 = 67; # Read 1 is on the - strand (CTOT) strand, but we score it for OT (1+2+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8982 $flag_2 = 131; # Read 2 is on the + strand, score it for OT (1+2+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8983 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8984 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8985 elsif ($index == 3){ # OB
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8986 unless ($old_flag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8987 $flag_1 = 83; # Read 1 is on the - strand, mapped in proper pair and Read 1 is reversed (1+2+16+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8988 $flag_2 = 163; # Read 2 is on the - strand, mapped in proper pair and Read 1 is reversed (1+2+32+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8989 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8990 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8991 $flag_1 = 115; # Read 1 is on the - strand, we score for OB (1+2+16+32+64)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8992 $flag_2 = 179; # Read 2 is on the + strand (1+2+16+32+128)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8993 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8994 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8995
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8996 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8997
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8998 my $mapq;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
8999
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9000 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9001 $mapq = $methylation_call_params->{$id}->{mapq};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9002 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9003 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9004 $mapq = 255; # Mapping quality is unavailable for use with Bowtie
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9005 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9006
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9007 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9008
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9009 my $cigar_1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9010 my $cigar_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9012 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9013 $cigar_1 = $methylation_call_params->{$id}->{CIGAR_1}; # Actual CIGAR string reported by Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9014 $cigar_2 = $methylation_call_params->{$id}->{CIGAR_2};
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9015 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9016 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9017 $cigar_1 = length($actual_seq_1) . "M"; # Assume no indels for Bowtie 1 mapping (only matches and mismatches)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9018 $cigar_2 = length($actual_seq_2) . "M";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9019 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9020
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9021 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9022
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9023 my $rnext = '='; # Chromosome of mate; applies to both reads
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9024
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9025 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9026
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9027 my $pnext_1 = $start_read_2; # Leftmost position of mate
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9028 my $pnext_2 = $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
9029
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9030 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9031
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9032 my $tlen_1; # signed observed Template LENgth (or inferred fragment size)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9033 my $tlen_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9034
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9035 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9036
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9037 if ($start_read_1 <= $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
9038
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9039 # Read 1 alignment is leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9040
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9041 if ($end_read_2 >= $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
9042
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9043 if ($flag_1 == 83 and $dovetail){ # R1 has 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
9044 # -----------------> read 2 reads are dovetailing, that is one mate alignment extends past the beginning of the other
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9045 # <------------------- read 1 such that the wrong mate begins upstream
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9046 # warn "FLAG 1: $flag_1\nFLAG 2: $flag_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9047 # warn "Reads are dovetailing\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9048 $tlen_1 = $start_read_1 - $end_read_2 - 1; # Read 1 still receives a - sign even though it is the leftmost one
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9049 $tlen_2 = $end_read_2 - $start_read_1 + 1; # Read 2 receives a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9050 # warn "TLEN 1: $tlen_1\nTLEN 2: $tlen_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9051 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9052 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9053 # -------------> read 1 reads not overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9054 # <---------- read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9055 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9056 # -------------------> read 1 reads overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9057 # <------------------- read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9058 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9059 # -------------------------> read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9060 # <----------------------- read 2 read 2 contained within read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9061 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9062 # -------------------------> read 1 reads 1 and 2 exactly overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9063 # <------------------------- read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9064 #
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9065
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9066 $tlen_1 = $end_read_2 - $start_read_1 + 1; # Leftmost read has a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9067 $tlen_2 = $start_read_1 - $end_read_2 - 1; # Rightmost read has a - sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9068 # warn "Reads are non/overlapping\nTLEN 1: $tlen_1\nTLEN 2: $tlen_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9069 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9070 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9071 elsif ($end_read_2 < $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
9072
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9073 # -------------------------> read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9074 # <----------- read 2 read 2 contained within read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9075 #
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9076 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9077 #
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9078 # -------------------------> read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9079 # <------------------------ read 2 read 2 contained within read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9080
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9081 # start and end of read 2 are fully contained within read 1, using the length of read 1 for the TLEN variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9082 $tlen_1 = $end_read_1 - $start_read_1 + 1; # Set to length of read 1 Leftmost read has a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9083 $tlen_2 = ($end_read_1 - $start_read_1 + 1) * -1; # Set to length of read 1 Rightmost read has a - sign. well this is debatable. Changed this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9084 ### as a request by frozenlyse on SeqAnswers on 24 July 2013
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9085 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9086
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9087 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9088
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9089 elsif ($start_read_2 < $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
9090
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9091 # Read 2 alignment is leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9092
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9093 if ($end_read_1 >= $end_read_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9094
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9095 # Read 2 alignment is leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9096 if ($flag_1 == 99 and $dovetail){ # R1 has 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
9097
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9098 # -----------------> read 1 reads are dovetailing, that is one mate alignment extends past the beginning of the other
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9099 # <------------------- read 2 such that the wrong mate begins upstream
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9101 # warn "FLAG 1: $flag_1\nFLAG 2: $flag_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9102 # warn "Reads are dovetailing\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9103 $tlen_1 = $end_read_1 - $start_read_2 + 1; # Read 1 still receives a + sign even though it is not leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9104 $tlen_2 = $start_read_2 - $end_read_1 - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9105 # warn "TLEN 1: $tlen_1\nTLEN 2: $tlen_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9106 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9107 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9108 # -------------> read 2 reads not overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9109 # <---------- read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9110 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9111 # -------------------------> read 2 reads overlapping
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9112 # <------------------------- read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9113 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9114 # -------------------------> read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9115 # <----------------------- read 1 read 1 contained within read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9116 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9117 # -------------------------> read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9118 # <----------------------- read 1 read 1 contained within read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9119 # warn "FLAG 1: $flag_1\nFLAG 2: $flag_2\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9120 # warn "Read 2 has a forward orientation\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9121 $tlen_2 = $end_read_1 - $start_read_2 + 1; # Leftmost read has a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9122 $tlen_1 = $start_read_2 - $end_read_1 - 1; # Rightmost read has a - sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9123 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9124 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9125 elsif ($end_read_1 < $end_read_2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9126
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9127 # -------------------------> read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9128 # <----------- read 1 read 1 contained within read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9129 #
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9130 # or
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9131 #
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9132 # -------------------------> read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9133 # <------------------------ read 1 read 1 contained within read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9134
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9135 # start and end of read 1 are fully contained within read 2, using the length of read 2 for the TLEN variable
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9136 $tlen_1 = ($end_read_2 - $start_read_2 + 1) * -1; # Set to length of read 2 Shorter read receives a - sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9137 $tlen_2 = $end_read_2 - $start_read_2 + 1; # Set to length of read 2 Longer read receives a +. Well this is debatable. Changed this
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9138 ### as a request by frozenlyse on SeqAnswers on 24 July 2013
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9139 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9140 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9141 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9142
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9143 else{ # Bowtie 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9144
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9145 if ($end_read_2 >= $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
9146 # Read 1 alignment is leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9147 # -------------------------> read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9148 # <------------------------- read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9149 # this is the most extreme case for Bowtie 1 alignments, reads do not contain each other, also no dovetailing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9150
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9151 $tlen_1 = $end_read_2 - $start_read_1 + 1; # Leftmost read has a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9152 $tlen_2 = $start_read_1 - $end_read_2 - 1; # Rightmost read has a - sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9153 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9154 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9155 # Read 2 alignment is leftmost
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9156 # -------------------------> read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9157 # <------------------------- read 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9158 # this is the most extreme case for Bowtie 1 alignments, reads do not contain each other, also no dovetailing
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9159
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9160 $tlen_2 = $end_read_1 - $start_read_2 + 1; # Leftmost read has a + sign,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9161 $tlen_1 = $start_read_2 - $end_read_1 - 1; # Rightmost read has a - sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9162 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9163 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9164
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9165 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9166
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9167 # adjusting the strand of the sequence before we use them to generate mismatch strings
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9168 if ($strand_1 eq '-'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9169 $actual_seq_1 = revcomp($actual_seq_1); # Sequence represented on the forward genomic strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9170 $ref_seq_1 = revcomp($ref_seq_1); # Required for comparison with actual sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9171 if ($cigar_1 =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9172 $methylation_call_params->{$id}->{genomic_seq_for_MD_tag_1} = revcomp( $methylation_call_params->{$id}->{genomic_seq_for_MD_tag_1} );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9173 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9174 $qual_1 = reverse $qual_1; # we need to reverse the quality string as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9175 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9176 if ($strand_2 eq '-'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9177 $actual_seq_2 = revcomp($actual_seq_2); # Mate sequence represented on the forward genomic strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9178 $ref_seq_2 = revcomp($ref_seq_2); # Required for comparison with actual sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9179 if ($cigar_2 =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9180 $methylation_call_params->{$id}->{genomic_seq_for_MD_tag_2} = revcomp( $methylation_call_params->{$id}->{genomic_seq_for_MD_tag_2} );
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9181 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9182 $qual_2 = reverse $qual_2; # If the sequence gets reverse complemented we reverse the quality string as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9183 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9184
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9185 # print "$actual_seq_1\n$ref_seq_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
9186 # print "$actual_seq_2\n$ref_seq_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
9187
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9188 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9189
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9190 my $hemming_dist_1 = hemming_dist($actual_seq_1,$ref_seq_1); # Minimal number of one-nucleotide edits needed to transform the read string into the reference sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9191 my $hemming_dist_2 = hemming_dist($actual_seq_2,$ref_seq_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9192 if ($bowtie2){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9193 $hemming_dist_1 += $methylation_call_params->{$id}->{indels_1}; # Adding the number of inserted/deleted bases which we parsed while getting the genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9194 $hemming_dist_2 += $methylation_call_params->{$id}->{indels_2}; # Adding the number of inserted/deleted bases which we parsed while getting the genomic sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9195 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9196 my $NM_tag_1 = "NM:i:$hemming_dist_1"; # Optional tag NM: edit distance based on nucleotide differences
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9197 my $NM_tag_2 = "NM:i:$hemming_dist_2"; # Optional tag NM: edit distance based on nucleotide differences
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9198
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9199 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9200
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9201 my $MD_tag_1 = make_mismatch_string($actual_seq_1,$ref_seq_1,$cigar_1,$methylation_call_params->{$id}->{genomic_seq_for_MD_tag_1}); # Optional tag MD: String providing mismatched reference bases in the alignment (including indel information)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9202 my $MD_tag_2 = make_mismatch_string($actual_seq_2,$ref_seq_2,$cigar_2,$methylation_call_params->{$id}->{genomic_seq_for_MD_tag_2});
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9203
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9204 # my $XX_tag_1 = make_mismatch_string($actual_seq_1,$ref_seq_1); # Optional tag XX: String providing mismatched reference bases in the alignment (NO indel information!)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9205 # my $XX_tag_2 = make_mismatch_string($actual_seq_2,$ref_seq_2);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9206
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9207 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9208
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9209 my $XM_tag_1; # Optional tag XM: 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
9210 my $XM_tag_2;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9211
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9212 if ($strand_1 eq '-'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9213 $XM_tag_1 = 'XM:Z:'.reverse $methcall_1; # Needs to be reversed if the sequence 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
9214 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9215 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9216 $XM_tag_1 = "XM:Z:$methcall_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9217 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9218
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9219 if ($strand_2 eq '-'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9220 $XM_tag_2 = 'XM:Z:'.reverse $methcall_2; # Needs to be reversed if the sequence 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
9221 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9222 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9223 $XM_tag_2 = "XM:Z:$methcall_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9224 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9225
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9226 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9227
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9228 my $XR_tag_1 = "XR:Z:$read_conversion_1"; # Optional tag XR: Read 1 conversion state
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9229 my $XR_tag_2 = "XR:Z:$read_conversion_2"; # Optional tag XR: Read 2 conversion state
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9230
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9231 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9232
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9233 my $XG_tag = "XG:Z:$genome_conversion"; # Optional tag XG: Genome Conversion state; valid for both reads
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9234
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9235 #####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9236
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9237 # Optionally calculating number of mismatches for Bowtie 2 alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9238
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9239 if ($non_bs_mm) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9240 if ($bowtie2) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9241
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9242 $number_of_mismatches_1 =~ s/-//; # removing the minus sign
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9243 $number_of_mismatches_2 =~ s/-//;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9244
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9245 ### if Bowtie 2 was used we need to analyse the CIGAR strings whether the reads contained any indels to determine the number of mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9246
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9247 ### CIGAR 1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9248 if ($cigar_1 =~ /(D|I)/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9249 # warn "$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
9250
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9251 # 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
9252 my @len = 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
9253 my @ops = 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
9254 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
9255 die "CIGAR string '$cigar_1' 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
9256
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9257 foreach (0..$#len) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9258 if ($ops[$_] eq 'M') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9259 # warn "skipping\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9260 next; # irrelevant
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9261 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9262 elsif ($ops[$_] 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
9263 $number_of_mismatches_1 -= $insertion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9264 $number_of_mismatches_1 -= $len[$_] * $insertion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9265 # warn "Insertion: Subtracting $ops[$_], length $len[$_], open: $insertion_open, extend: $insertion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9266 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9267 elsif ($ops[$_] 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
9268 $number_of_mismatches_1 -= $deletion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9269 $number_of_mismatches_1 -= $len[$_] * $deletion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9270 # warn "Deletion: Subtracting $ops[$_], length $len[$_], open: $deletion_open, extend: $deletion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9271 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9272 elsif ($cigar_1 =~ tr/[NSHPX=]//) { # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9273 die "The CIGAR string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $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
9274 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9275 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9276 die "The CIGAR string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $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
9277 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9278 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9279
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9280 # warn "Alignment score $number_of_mismatches_1\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9281 # print "Mismatches $number_of_mismatches_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
9282 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9283
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9284 ### CIGAR 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9285 if ($cigar_2 =~ /(D|I)/) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9286 # warn "$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
9287
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9288 # 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
9289 my @len = 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
9290 my @ops = 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
9291 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
9292 die "CIGAR string '$cigar_2' 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
9293
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9294 foreach (0..$#len) {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9295 if ($ops[$_] eq 'M') {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9296 # warn "skipping\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9297 next; #irrelevant
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9298 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9299 elsif ($ops[$_] 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
9300 $number_of_mismatches_2 -= $insertion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9301 $number_of_mismatches_2 -= $len[$_] * $insertion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9302 # warn "Insertion: Subtracting $ops[$_], length $len[$_], open: $insertion_open, extend: $insertion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9303 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9304 elsif ($ops[$_] 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
9305 $number_of_mismatches_2 -= $deletion_open;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9306 $number_of_mismatches_2 -= $len[$_] * $deletion_extend;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9307 # warn "Deletion: Subtracting $ops[$_], length $len[$_], open: $deletion_open, extend: $deletion_extend\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9308 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9309 elsif ($cigar_2 =~ tr/[NSHPX=]//) { # if these (for standard mapping) illegal characters exist we die
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9310 die "The CIGAR string contained illegal CIGAR operations in addition to 'M', 'I' and 'D': $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
9311 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9312 else {
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9313 die "The CIGAR string contained undefined CIGAR operations in addition to 'M', 'I' and 'D': $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
9314 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9315 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9316 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9317
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9318 ### Now we have InDel corrected Alignment scores
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9319
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9320 ### if the actual sequence contained Ns we need to adjust the number of mismatches. Ns receive a penalty of -1, but normal mismatches receive -6. This might still break if the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9321 ### sequence contained more than 5 Ns, but this should occur close to never
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9322
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9323 my $seq_1_N_count = $number_of_mismatches_1 % 6; # modulo 6 will return the integer rest after the division
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9324 my $seq_2_N_count = $number_of_mismatches_2 % 6;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9325 # warn "N count 1: $seq_1_N_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9326 # warn "N count 2: $seq_2_N_count\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9327
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9328 $number_of_mismatches_1 = int ($number_of_mismatches_1 / 6) + $seq_1_N_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9329 $number_of_mismatches_2 = int ($number_of_mismatches_2 / 6) + $seq_2_N_count;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9330
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9331 # warn "MM1 $number_of_mismatches_1 \n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9332 # warn "MM2 $number_of_mismatches_2 \n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9333 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9334 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9335
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9336 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9337
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9338 my $XA_tag = "XA:Z:$number_of_mismatches_1";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9339 my $XB_tag = "XB:Z:$number_of_mismatches_2";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9340
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9341 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9342
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9343 my $read_group; # optional
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9344 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9345 $read_group = "RG:Z:$rg_id";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9346 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9347
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9348 ####
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9349
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9350 # SAM format: QNAME, FLAG, RNAME, 1-based POS, MAPQ, CIGAR, RNEXT, PNEXT, TLEN, SEQ, QUAL, optional fields
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9351 ### optionally print number of non-bisulfite mismatches
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9352 if ($non_bs_mm){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9353 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9354 print OUT join("\t", ($id_1, $flag_1, $chr, $start_read_1, $mapq, $cigar_1, $rnext, $pnext_1, $tlen_1, $actual_seq_1, $qual_1, $NM_tag_1, $MD_tag_1, $XM_tag_1,$XR_tag_1,$XG_tag,$XA_tag,$read_group)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9355 print OUT join("\t", ($id_2, $flag_2, $chr, $start_read_2, $mapq, $cigar_2, $rnext, $pnext_2, $tlen_2, $actual_seq_2, $qual_2, $NM_tag_2, $MD_tag_2, $XM_tag_2,$XR_tag_2,$XG_tag,$XB_tag,$read_group)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9356 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9357 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9358 print OUT join("\t", ($id_1, $flag_1, $chr, $start_read_1, $mapq, $cigar_1, $rnext, $pnext_1, $tlen_1, $actual_seq_1, $qual_1, $NM_tag_1, $MD_tag_1, $XM_tag_1,$XR_tag_1,$XG_tag,$XA_tag)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9359 print OUT join("\t", ($id_2, $flag_2, $chr, $start_read_2, $mapq, $cigar_2, $rnext, $pnext_2, $tlen_2, $actual_seq_2, $qual_2, $NM_tag_2, $MD_tag_2, $XM_tag_2,$XR_tag_2,$XG_tag,$XB_tag)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9360 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9361 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9362 else{ # default
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9363 if ($rg_tag){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9364 print OUT join("\t", ($id_1, $flag_1, $chr, $start_read_1, $mapq, $cigar_1, $rnext, $pnext_1, $tlen_1, $actual_seq_1, $qual_1, $NM_tag_1, $MD_tag_1, $XM_tag_1,$XR_tag_1,$XG_tag,$read_group)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9365 print OUT join("\t", ($id_2, $flag_2, $chr, $start_read_2, $mapq, $cigar_2, $rnext, $pnext_2, $tlen_2, $actual_seq_2, $qual_2, $NM_tag_2, $MD_tag_2, $XM_tag_2,$XR_tag_2,$XG_tag,$read_group)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9366 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9367 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9368 print OUT join("\t", ($id_1, $flag_1, $chr, $start_read_1, $mapq, $cigar_1, $rnext, $pnext_1, $tlen_1, $actual_seq_1, $qual_1, $NM_tag_1, $MD_tag_1, $XM_tag_1,$XR_tag_1,$XG_tag)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9369 print OUT join("\t", ($id_2, $flag_2, $chr, $start_read_2, $mapq, $cigar_2, $rnext, $pnext_2, $tlen_2, $actual_seq_2, $qual_2, $NM_tag_2, $MD_tag_2, $XM_tag_2,$XR_tag_2,$XG_tag)), "\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9370 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9371 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9372 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9373
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9374
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9375 sub revcomp{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9376 my $seq = shift or die "Missing seq to reverse complement\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9377 $seq = reverse $seq;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9378 $seq =~ tr/ACTGactg/TGACTGAC/;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9379 return $seq;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9380 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9381
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9382 sub hemming_dist{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9383 my $matches = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9384 my @actual_seq = split //,(shift @_);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9385 my @ref_seq = split //,(shift @_);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9386
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9387 foreach (0..$#actual_seq){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9388 ++$matches if ($actual_seq[$_] eq $ref_seq[$_]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9389 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9390 return my $hd = scalar @actual_seq - $matches;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9391 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9392
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9393
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9394 ### Getting rid of the bitwise comparison because even though the initial comparison is nice and quick, the regex loop looking for non-null bytes characters isn't. We might
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9395 ### as well do a substring loop to start with, which enables us to generate proper MD:Z: flags that also take proper care of InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9396 ### 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
9397
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9398
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9399 sub make_mismatch_string{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9400 my ($actual_seq,$ref_seq,$cigar,$md_sequence) = @_;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9401
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9402 my $MD_tag = "MD:Z:";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9403 my $prev_matching = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9404 my $last_char;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9405
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9406 my $ref_base;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9407 my $actual_base;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9408
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9409 foreach my $pos ( 0..(length$actual_seq) - 1 ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9410
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9411 $actual_base = substr($actual_seq,$pos,1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9412 $ref_base = substr($ref_seq,$pos,1);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9413 # if ($verbose){ warn "reference: $ref_base\tseen base: $actual_base\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9414
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9415 if ( $actual_base eq $ref_base ){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9416 ++$prev_matching;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9417 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9418 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9419 # If the mismatch is due to an insertion we simply move on, else we print the previously matching bases as well as the mismatching genomic base
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9420 if ($ref_base eq 'X'){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9421 # if ($verbose){ warn "The genome base was an artificually padded '$ref_base' due to an insertion in the read at this position. Just ignoring it for the MD tag\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
9422 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9423 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9424 # if ($verbose){ warn "previous matching bases: $prev_matching\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9425
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9426 ### There is a mismatch between the sequence and the genome. First we need to write out how may bases matched until now
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9427 if ($prev_matching == 0){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9428 # if ($verbose){ warn "Got a mismatch either at the very start or next to another mismatch. Need to add a padding 0 as well as the mismatch\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9429 # if ($verbose){ warn "${prev_matching}$ref_base\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9430 $MD_tag .= $prev_matching;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9431 $MD_tag .= $ref_base;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9432 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9433 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9434 # if ($verbose){ warn "${prev_matching}$ref_base\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9435 $MD_tag .= $prev_matching;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9436 $MD_tag .= $ref_base;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9437 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9438
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9439 $prev_matching = 0; # resetting $prev_matching
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9440 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9441
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9442 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9443
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9444 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9445 ### appending the number of matches one last time
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9446 $MD_tag .= $prev_matching;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9447
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9448
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9449 ### If the read contains deletion(s) we need to take care of these in the MD-tag as well
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9450 if ($cigar =~ /D/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9451 my $deletions_total = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9452 while ($cigar =~ /D/g){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9453 ++$deletions_total;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9454 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9455 if ($verbose){ warn "Read contains $deletions_total deletions in total\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9456
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9457 if ($verbose){ warn "There was a deletion in the read!\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9458 if ($verbose){ warn "actual:\t$actual_seq\nref:\t$ref_seq\nMD-seq:\t$md_sequence\nMD-tag: $MD_tag\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9459
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9460 # 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
9461 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
9462 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
9463 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
9464 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
9465
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9466 my $MD_pos_so_far = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9467 my $deletions_processed = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9468 my $del_pos = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9469 my $deleted_bases = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9470 my $new_MD = $1 if ($MD_tag =~ /MD:Z:(.*)/);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9471 my $md_index_already_processed;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9472
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9473 my @md = split //,$new_MD;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9474
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9475 if ($verbose){ warn "New MD-tag: $new_MD\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9476 $MD_tag = "MD:Z:"; ### reconstituting a new MD-tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9477 $new_MD = ''; # using this to build up a new string that will replace the old \@md
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9478
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9479 if ($verbose){ warn "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
9480 ### determining end position of a read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9481 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
9482
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9483 if ($ops[$index] eq 'M'){ # matching bases
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9484 $del_pos += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9485 if ($verbose){ warn "Operation is 'M', adding $len[$index] bp\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9486 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9487 elsif($ops[$index] eq 'I'){ # insertion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9488 $del_pos += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9489 ### need to add insertions in the read to MD pos so far!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9490 $MD_pos_so_far += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9491 if ($verbose){ warn "Operation is 'I', adding $len[$index] bp\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9492 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9493 elsif($ops[$index] eq 'D'){ # deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9494 if ($verbose){ warn "Operation is 'D', extracting $len[$index] bp\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9495 $deleted_bases = substr($md_sequence,$del_pos,$len[$index]);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9496 if ($verbose){ warn "Deleted bases: $deleted_bases\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9497
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9498 ### Now we need to process the MD-tag so far and write out everything up until this point, inlcuding the deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9499 if ($verbose){ warn "Now processing the MD-tag\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9500 my $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9501
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9502 my $this_deletion_processed;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9503 my $md_processed_so_far;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9504 my $current_md_index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9505
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9506 foreach my $el (@md){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9507
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9508 unless (defined $current_md_index){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9509 $current_md_index = 0; # first element = index 0
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9510 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9511 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9512 ++$current_md_index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9513 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9514
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9515 if ($md_index_already_processed and ($current_md_index <= $md_index_already_processed)){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9516 if ($verbose){ warn "This has to be another deletion within the same read. Currently processing index $current_md_index, but have already processed $md_index_already_processed indexes previously\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9517 $new_MD .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9518 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9519 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9520
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9521 if ($verbose){ warn "Current element: $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9522 unless (defined $op){ # initialize
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9523 $op = $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9524 if ($verbose){ warn "Initializing \$op as $op\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9525 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9526 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9527
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9528 if ($deletions_processed == $deletions_total){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9529 if ($verbose){ warn "Processed $deletions_processed in the read so far, out of $deletions_total total. Just appending elements until the end of the string: here $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9530 $MD_tag .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9531 $new_MD .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9532 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9533 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9534 # this only occurs when there are more deletions in the read but we want to regenerate a new MD tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9535 if ($this_deletion_processed){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9536 $new_MD .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9537 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9538 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9539
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9540 if ($op =~ /^\d+$/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9541 if ($verbose){ warn "Operation so far was a digit: $op\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9542 if ($el =~ /\d/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9543 $op .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9544 if ($verbose){ warn "Appending current operation $el. New operation is: $op\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9545 next;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9546 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9547 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9548 if ($verbose){ warn "current element is a word character: $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9549
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9550 ### Need to determine if the matching operation length includes the deletion position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9551 if ($verbose){ warn "Processing operation $op and adding it to MD pos which is so far: $MD_pos_so_far; deletion pos is $del_pos.\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9552 $MD_pos_so_far += $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9553 if ($verbose){ warn "MD pos so far: $MD_pos_so_far\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9554 if ($MD_pos_so_far < $del_pos){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9555 if ($verbose){ warn "Doesn't cover the deletion yet. Writing back out.\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9556 $MD_tag .= $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9557 $new_MD .= $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9558 if ($verbose){ warn "Setting new operation to: $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9559 $op = $el; # setting new $op
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9560 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9561 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9562 if ($verbose){ warn "Here we go, this operation covers the deletion position!!\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9563 ### splitting up the number of matching bases in number before and after the deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9564
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9565 my $pos_after_deletion = $MD_pos_so_far - $del_pos;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9566 my $pos_before_deletion = $op - $pos_after_deletion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9567 if ($verbose){ warn "Splitting up previous operation '$op' into pos before deletion: ${pos_before_deletion} and pos_after_deletion: $pos_after_deletion\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9568 $MD_tag .= "${pos_before_deletion}^${deleted_bases}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9569 $new_MD .= "${pos_before_deletion}^${deleted_bases}${pos_after_deletion}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9570 if ($verbose){ warn "\$newMD after adjusting for the current deletion: $new_MD\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9571
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9572 #adjusting the MD_position by the number of bases after the deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9573 $MD_pos_so_far -= $pos_after_deletion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9574 if ($verbose){ warn "MD after adjusting for deletion: $MD_pos_so_far\n"; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9575 ### also appending the current element because we are writing out the rest of the MD-string unchanged to $new_MD
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9576 $new_MD .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9577
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9578 $deletions_processed += 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9579 $this_deletion_processed = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9580
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9581 if ($deletions_processed == $deletions_total){ # this was the last deletion of the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9582 if ($verbose){ warn "This was the last deletion in the read ($deletions_processed out of $deletions_total total). Continuing to append \$pos_after_deletion (${pos_after_deletion})..\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9583 $MD_tag .= "${pos_after_deletion}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9584
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9585 ### also appending the current element because we are writing out the rest of the MD-string unchanged
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9586 if ($verbose){ warn "also appending the current element $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9587 $MD_tag .= $el;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9588 ### Finally also adding the length of the deletion to $del_pos
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9589 $del_pos += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9590 if ($verbose){ warn "Adding length of the deletion itself (",$len[$index],") to \$del_pos: currently at $del_pos\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9591 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9592 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9593 if ($verbose){ warn "This wasn't the last deletion in the read. Substituting the last operation with the current deletion and reconstituting \@md\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9594 if ($verbose){ warn "Adding length of deletion string '${pos_before_deletion}^${deleted_bases}' (",length("${pos_before_deletion}^${deleted_bases}")," - length of current operation (",length$op,") to current_md_index\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9595
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9596
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9597 ### This migh need looking at!!
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9598
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9599 $current_md_index = $current_md_index + length("${pos_before_deletion}^${deleted_bases}") - length$op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9600 if ($verbose){ warn "Current index = $current_md_index\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9601
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9602 if ($verbose){ warn "Setting \$md_index_already_processed to ",$current_md_index-1,"\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9603 $md_index_already_processed = $current_md_index - 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9604
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9605 if ($verbose){ warn "Exiting now and waiting for the next deletion\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9606
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9607 ### Finally also adding the length of the deletion to $del_pos
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9608 $del_pos += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9609 $MD_pos_so_far += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9610 if ($verbose){ warn "Adding length of the deletion itself (",$len[$index],") to \$del_pos: currently at $del_pos\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9611 if ($verbose){ warn "MD-tag so far: $MD_tag ~~\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9612 #setting $op to en empty string so it is not being processed as the last element
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9613 $op = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9614 # last; # exiting the loop and processing the CIGAR string further until we hit the next deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9615 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9616 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9617 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9618 if ($verbose){ warn "MD-tag so far: $MD_tag ~~\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9619 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9620 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9621 if ($verbose){ warn "Operation so far was a word character: $op\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9622 if ($el =~ /\d+/){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9623 # processing the previous mismatch position
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9624 $MD_tag .= $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9625 $new_MD .= $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9626 $MD_pos_so_far += length($op);
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9627 if ($verbose){ warn "Writing out mismatching base $op and adding length ",length($op),"\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9628 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9629 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9630 # this should never occur since mismatches are followed by a 0 or another digit
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9631 die "current element is a another word character: $el. This should never happen!\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9632 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9633 if ($verbose){ warn "Setting new operation to: $el\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9634 $op = $el; # setting new $op
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9635 if ($verbose){ warn "MD-tag so far: $MD_tag ~~\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9636 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9637 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9638
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9639 ### need to consider last element if it was a digit or number and we are expecting the deletion in the last element of the MD-tag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9640 if ($op =~ /\d+/ and $deletions_processed < $deletions_total){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9641 if ($verbose){ warn "\n\nlast operation was $op\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9642 if ($verbose){ warn "Processing operation $op; deletion pos is $del_pos. MD so far was: $MD_pos_so_far\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9643
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9644 $MD_pos_so_far += $op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9645 if ($verbose){ warn "Adding $op to MD pos so far: $MD_pos_so_far\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9646 if ($verbose){ warn "Deletions already processed: $deletions_processed, del total: $deletions_total\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9647 if ($MD_pos_so_far >= $del_pos){
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9648 if ($verbose){ warn "Here we go, this operation covers the deletion position!!\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9649 ### splitting up the number of matching bases in number before and after the deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9650
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9651 my $pos_after_deletion = $MD_pos_so_far - $del_pos;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9652 my $pos_before_deletion = $op - $pos_after_deletion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9653 if ($verbose){ warn "Splitting up previous operation '$op' into pos before deletion: ${pos_before_deletion} and pos_after_deletion: $pos_after_deletion\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9654
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9655 $MD_tag .= "${pos_before_deletion}^${deleted_bases}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9656 $new_MD .= "${pos_before_deletion}^${deleted_bases}${pos_after_deletion}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9657
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9658 #adjusting the MD_position by the number of bases after the deletion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9659 $MD_pos_so_far -= $pos_after_deletion;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9660 if ($verbose){ warn "MD after adjusting for deletion: $MD_pos_so_far\n"; }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9661
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9662 $deletions_processed += 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9663 $this_deletion_processed = 1;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9664
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9665 if ($deletions_processed == $deletions_total){ # this was the last deletion of the read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9666 if ($verbose){ warn "This was the last deletion in the read ($deletions_processed out of $deletions_total total). Continuing to append \$pos_after_deletion (${pos_after_deletion})..\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9667 $MD_tag .= "${pos_after_deletion}";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9668
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9669 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9670 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9671 if ($verbose){ warn "This wasn't the last deletion in the read. Substituting the last operation with the current deletion and reconstituting \@md\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9672 if ($verbose){ warn "Adding length of deletion string '${pos_before_deletion}^${deleted_bases}' (",length("${pos_before_deletion}^${deleted_bases}")," - length of current operation (",length$op,") to current_md_index\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9673
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9674 $current_md_index = $current_md_index + length("${pos_before_deletion}^${deleted_bases}") - length$op;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9675 if ($verbose){ warn "Current index = $current_md_index\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9676
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9677 if ($verbose){ warn "Setting \$md_index_already_processed to ",$current_md_index-1,"\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9678 # since we are no longer in the loop we don't have to subtract 1 from $current_md_index (tit hasn't been incremented in the first place...)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9679 $md_index_already_processed = $current_md_index;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9680
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9681 if ($verbose){ warn "Exiting now and waiting for the next deletion\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9682
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9683 $MD_pos_so_far += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9684 if ($verbose){ warn "MD-tag so far: $MD_tag ~~\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9685 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9686 ### Finally also adding the length of the deletion to $del_pos
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9687 $del_pos += $len[$index];
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9688 if ($verbose){ warn "Adding length of the deletion itself (",$len[$index],") to \$del_pos: currently at $del_pos\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9689 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9690 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9691 die "Something went wrong, we haven't seen a deletion so far even though we should have...\n\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9692 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9693 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9694
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9695 # forming a new @md
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9696 @md = split //,$new_MD;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9697 $new_MD = '';
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9698 if ($verbose){ warn "New \@md array: @md\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9699 if ($verbose){ warn "MD-tag so far: $MD_tag ~~\nnew_MD so far: $new_MD\n\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9700
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9701 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9702 else{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9703 die "Found CIGAR operations other than M, I, D or N: '$ops[$index]'. Not allowed at the moment\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9704 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9705 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9706
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9707 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9708 if ($verbose){ warn "Returning MD-tag: $MD_tag\n";}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9709 return $MD_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9710
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9711 }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9712
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9713 ### Getting rid of the bitwise comparison because even though the initial comparison is nice and quick, the regex loop looking for non-null bytes characters isn't. We might
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9714 ### as well do a substring loop to start with, which enables us to generate proper MD:Z: flags that also take proper care of InDels
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9715 # sub make_mismatch_string{
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9716 # my $actual_seq = shift or die "Missing actual sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9717 # my $ref_seq = shift or die "Missing reference sequence\n";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9718 # my $XX_tag = "XX:Z:";
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9719
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9720 # my $tmp = ($actual_seq ^ $ref_seq); # Bitwise comparison
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9721
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9722 # warn "'$tmp'\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
9723 # my $prev_mm_pos = 0;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9724
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9725 # while($tmp =~ /[^\0]/g){ # Where bitwise comparison showed a difference
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9726 # my $nuc_match = pos($tmp) - $prev_mm_pos - 1; # Generate number of nucleotide that matches since last mismatch
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9727 # my $nuc_mm = substr($ref_seq, pos($tmp) - 1, 1) if pos($tmp) <= length($ref_seq); # Obtain reference nucleotide that was different from the actual read
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9728 # $XX_tag .= "$nuc_match" if $nuc_match > 0; # Ignore if mismatches are adjacent to each other
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9729 # $XX_tag .= "$nuc_mm" if defined $nuc_mm; # Ignore if there is no mismatch (prevents uninitialized string concatenation)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9730 # $prev_mm_pos = pos($tmp); # Position of last mismatch
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9731 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9732 # my $end_matches = length($ref_seq) - $prev_mm_pos; # Provides number of matches from last mismatch till end of sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9733 # $XX_tag .= "$end_matches" if $end_matches > 0; # Ignore if mismatch is at the end of sequence
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9734 # return $XX_tag;
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9735 # }
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9736
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9737
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9738
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9739 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
9740 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
9741
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9742
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9743 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
9744 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
9745 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
9746 (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
9747
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9748 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
9749 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
9750 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
9751 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
9752 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
9753 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
9754
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9755
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9756
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9757 DESCRIPTION
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9758
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9759
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9760 The following is a brief description of command line options and arguments 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
9761 bisulfite mapper and methylation caller. Bismark takes in FastA or FastQ files and aligns the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9762 reads to a specified bisulfite genome. Sequence reads are transformed into a bisulfite converted forward strand
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9763 version (C->T conversion) or into a bisulfite treated reverse strand (G->A conversion of 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
9764 Each of these reads are then aligned to bisulfite treated forward strand index of a reference genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9765 (C->T converted) and a bisulfite treated reverse strand index of the genome (G->A conversion of the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9766 forward strand, by doing this alignments will produce the same positions). These 4 instances of Bowtie (1 or 2)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9767 are run in parallel. The sequence file(s) are then read in again sequence by sequence to pull out the original
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9768 sequence from the genome and determine if there were any protected C's present or not.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9769
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9770 As of version 0.7.0 Bismark will only run 2 alignment threads for OT and OB in parallel, the 4 strand mode can be
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9771 re-enabled by using --non_directional.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9772
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9773 The final output of Bismark is in SAM format by default. For Bowtie 1 one can alos choose to report the old
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9774 'vanilla' output format, which is a single tab delimited file with all sequences that have a unique best
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9775 alignment to any of the 4 possible strands of a bisulfite PCR product. Both formats are described in more detail below.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9776
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9777
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9778 USAGE: bismark [options] <genome_folder> {-1 <mates1> -2 <mates2> | <singles>}
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9779
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9780
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9781 ARGUMENTS:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9782
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9783 <genome_folder> The path to the folder containing the unmodified reference genome
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9784 as well as the subfolders created by the Bismark_Genome_Preparation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9785 script (/Bisulfite_Genome/CT_conversion/ and /Bisulfite_Genome/GA_conversion/).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9786 Bismark expects one or more fastA files in this folder (file extension: .fa
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9787 or .fasta). The path can be relative or absolute. The path may also be set as
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9788 '--genome_folder /path/to/genome/folder/'.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9789
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9790 -1 <mates1> Comma-separated list of files containing the #1 mates (filename usually includes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9791 "_1"), e.g. flyA_1.fq,flyB_1.fq). Sequences specified with this option must
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9792 correspond file-for-file and read-for-read with those specified in <mates2>.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9793 Reads may be a mix of different lengths. Bismark will produce one mapping result
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9794 and one report file per paired-end input file pair.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9795
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9796 -2 <mates2> Comma-separated list of files containing the #2 mates (filename usually includes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9797 "_2"), e.g. flyA_1.fq,flyB_1.fq). Sequences specified with this option must
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9798 correspond file-for-file and read-for-read with those specified in <mates1>.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9799 Reads may be a mix of different lengths.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9800
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9801 <singles> A comma- or space-separated list of files containing the reads to be aligned (e.g.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9802 lane1.fq,lane2.fq lane3.fq). Reads may be a mix of different lengths. Bismark will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9803 produce one mapping result and one report file per input file.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9804
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9805
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9806 OPTIONS:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9807
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9808
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9809 Input:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9810
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9811 --se/--single_end <list> Sets single-end mapping mode explicitly giving a list of file names as <list>.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9812 The filenames may be provided as a comma [,] or colon [:] separated list.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9813
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9814 -q/--fastq The query input files (specified as <mate1>,<mate2> or <singles> are FASTQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9815 files (usually having extension .fg or .fastq). This is the default. See also
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9816 --solexa-quals.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9817
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9818 -f/--fasta The query input files (specified as <mate1>,<mate2> or <singles> are FASTA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9819 files (usually having extensions .fa, .mfa, .fna or similar). All quality values
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9820 are assumed to be 40 on the Phred scale. FASTA files are expected to contain both
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9821 the read name and the sequence on a single line (and not spread over several lines).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9822
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9823 -s/--skip <int> Skip (i.e. do not align) the first <int> reads or read pairs from the input.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9824
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9825 -u/--upto <int> Only aligns the first <int> reads or read pairs from the input. Default: no limit.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9826
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9827 --phred33-quals FASTQ qualities are ASCII chars equal to the Phred quality plus 33. Default: on.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9828
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9829 --phred64-quals FASTQ qualities are ASCII chars equal to the Phred quality plus 64. Default: off.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9830
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9831 --solexa-quals Convert FASTQ qualities from solexa-scaled (which can be negative) to phred-scaled
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9832 (which can't). The formula for conversion is:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9833 phred-qual = 10 * log(1 + 10 ** (solexa-qual/10.0)) / log(10). Used with -q. This
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9834 is usually the right option for use with (unconverted) reads emitted by the GA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9835 Pipeline versions prior to 1.3. Works only for Bowtie 1. Default: off.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9836
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9837 --solexa1.3-quals Same as --phred64-quals. This is usually the right option for use with (unconverted)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9838 reads emitted by GA Pipeline version 1.3 or later. Default: off.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9839
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9840 --path_to_bowtie The full path </../../> to the Bowtie (1 or 2) installation on your system. If not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9841 specified it is assumed that Bowtie (1 or 2) 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
9842
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9843
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9844 Alignment:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9845
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9846 -n/--seedmms <int> The maximum number of mismatches permitted in the "seed", i.e. the first L base pairs
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9847 of the read (where L is set with -l/--seedlen). This may be 0, 1, 2 or 3 and the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9848 default is 1. This option is only available for Bowtie 1 (for Bowtie 2 see -N).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9849
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9850 -l/--seedlen The "seed length"; i.e., the number of bases of the high quality end of the read to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9851 which the -n ceiling applies. The default is 28. Bowtie (and thus Bismark) is faster for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9852 larger values of -l. This option is only available for Bowtie 1 (for Bowtie 2 see -L).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9853
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9854 -e/--maqerr <int> Maximum permitted total of quality values at all mismatched read positions throughout
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9855 the entire alignment, not just in the "seed". The default is 70. Like Maq, bowtie rounds
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9856 quality values to the nearest 10 and saturates at 30. This value is not relevant for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9857 Bowtie 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9858
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9859 --chunkmbs <int> The number of megabytes of memory a given thread is given to store path descriptors in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9860 --best mode. Best-first search must keep track of many paths at once to ensure it is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9861 always extending the path with the lowest cumulative cost. Bowtie tries to minimize the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9862 memory impact of the descriptors, but they can still grow very large in some cases. If
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9863 you receive an error message saying that chunk memory has been exhausted in --best mode,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9864 try adjusting this parameter up to dedicate more memory to the descriptors. This value
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9865 is not relevant for Bowtie 2. Default: 512.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9866
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9867 -I/--minins <int> The minimum insert size for valid paired-end alignments. E.g. if -I 60 is specified and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9868 a paired-end alignment consists of two 20-bp alignments in the appropriate orientation
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9869 with a 20-bp gap between them, that alignment is considered valid (as long as -X is also
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9870 satisfied). A 19-bp gap would not be valid in that case. Default: 0.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9871
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9872 -X/--maxins <int> The maximum insert size for valid paired-end alignments. E.g. if -X 100 is specified and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9873 a paired-end alignment consists of two 20-bp alignments in the proper orientation with a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9874 60-bp gap between them, that alignment is considered valid (as long as -I is also satisfied).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9875 A 61-bp gap would not be valid in that case. Default: 500.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9876
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9877 --multicore <int> Sets the number of parallel instances of Bismark to be run concurrently. This forks the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9878 Bismark alignment step very early on so that each individual Spawn of Bismark processes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9879 only every n-th sequence (n being set by --multicore). Once all processes have completed,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9880 the individual BAM files, mapping reports, unmapped or ambiguous FastQ files are merged
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9881 into single files in very much the same way as they would have been generated running Bismark
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9882 conventionally with only a single instance.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9883
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9884 If system resources are plentiful this is a viable option to speed up the alignment process
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9885 (we observed a near linear speed increase for up to --multicore 8 tested). However, please note
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9886 that a typical Bismark run will use several cores already (Bismark itself, 2 or 4 threads of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9887 Bowtie/Bowtie2, Samtools, gzip etc...) and ~10-16GB of memory depending on the choice of aligner
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9888 and genome. WARNING: Bismark Parallel (BP?) is resource hungry! Each value of --multicore specified
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9889 will effectively lead to a linear increase in compute and memory requirements, so --multicore 4 for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9890 e.g. the GRCm38 mouse genome will probably use ~20 cores and eat ~40GB or RAM, but at the same time
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9891 reduce the alignment time to ~25-30%. You have been warned.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9892
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9893
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9894
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9895 Bowtie 1 Reporting:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9896
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9897 -k <2> Due to the way Bismark works Bowtie will report up to 2 valid alignments. This option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9898 will be used by default.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9899
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9900 --best Make Bowtie guarantee that reported singleton alignments are "best" in terms of stratum
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9901 (i.e. number of mismatches, or mismatches in the seed in the case if -n mode) and in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9902 terms of the quality; e.g. a 1-mismatch alignment where the mismatch position has Phred
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9903 quality 40 is preferred over a 2-mismatch alignment where the mismatched positions both
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9904 have Phred quality 10. When --best is not specified, Bowtie may report alignments that
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9905 are sub-optimal in terms of stratum and/or quality (though an effort is made to report
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9906 the best alignment). --best mode also removes all strand bias. Note that --best does not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9907 affect which alignments are considered "valid" by Bowtie, only which valid alignments
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9908 are reported by Bowtie. Bowtie is about 1-2.5 times slower when --best is specified.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9909 Default: on.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9910
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9911 --no_best Disables the --best option which is on by default. This can speed up the alignment process,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9912 e.g. for testing purposes, but for credible results it is not recommended to disable --best.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9913
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9914
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9915 Output:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9916
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9917 --non_directional The sequencing library was constructed in a non strand-specific manner, alignments to all four
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9918 bisulfite strands will be reported. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9919
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9920 (The current Illumina protocol for BS-Seq is directional, in which case the strands complementary
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9921 to the original strands are merely theoretical and should not exist in reality. Specifying directional
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9922 alignments (which is the default) will only run 2 alignment threads to the original top (OT)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9923 or bottom (OB) strands in parallel and report these alignments. This is the recommended option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9924 for sprand-specific libraries).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9925
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9926 --pbat This options may be used for PBAT-Seq libraries (Post-Bisulfite Adapter Tagging; Kobayashi et al.,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9927 PLoS Genetics, 2012). This is essentially the exact opposite of alignments in 'directional' mode,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9928 as it will only launch two alignment threads to the CTOT and CTOB strands instead of the normal OT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9929 and OB ones. Use this option only if you are certain that your libraries were constructed following
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9930 a PBAT protocol (if you don't know what PBAT-Seq is you should not specify this option). The option
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9931 --pbat works only for FastQ files (in both Bowtie and Bowtie 2 mode) and using uncompressed
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9932 temporary files only).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9933
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9934 --sam-no-hd Suppress SAM header lines (starting with @). This might be useful when very large 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
9935 split up into several smaller files to run concurrently and the output files are to be merged.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9936
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9937 --rg_tag Write out a Read Group tag to the resulting SAM/BAM file. This will write the following line to the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9938 SAM header: \@RG PL: ILLUMINA ID:SAMPLE SM:SAMPLE ; to set ID and SM see --rg_id and --rg_sample.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9939 In addition each read receives an RG:Z:RG-ID tag. Default: OFF.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9940
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9941 --rg_id <string> Sets the ID field in the \@RG header line. The default is 'SAMPLE'.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9942
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9943 --rg_sample <string> Sets the SM field in the \@RG header line; can't be set without setting --rg_id as well. The default is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9944 'SAMPLE'.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9945
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9946 --quiet Print nothing besides alignments.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9947
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9948 --vanilla Performs bisulfite mapping with Bowtie 1 and prints the 'old' output (as in Bismark 0.5.X) instead
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9949 of SAM format output.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9950
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9951 -un/--unmapped Write all reads that could not be aligned to a file in the output directory. Written reads will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9952 appear as they did in the input, without any translation of quality values that may have
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9953 taken place within Bowtie or Bismark. Paired-end reads will be written to two parallel files with _1
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9954 and _2 inserted in their filenames, i.e. _unmapped_reads_1.txt and unmapped_reads_2.txt. Reads
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9955 with more than one valid alignment with the same number of lowest mismatches (ambiguous mapping)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9956 are also written to _unmapped_reads.txt unless the option --ambiguous is specified as well.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9957
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9958 --ambiguous Write all reads which produce more than one valid alignment with the same number of lowest
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9959 mismatches or other reads that fail to align uniquely to a file in the output directory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9960 Written reads will appear as. they did in the input, without any of the translation of quality
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9961 values that may have taken place within Bowtie or Bismark. Paired-end reads will be written to two
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9962 parallel files with _1 and _2 inserted in theit filenames, i.e. _ambiguous_reads_1.txt and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9963 _ambiguous_reads_2.txt. These reads are not written to the file specified with --un.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9964
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9965 -o/--output_dir <dir> Write all output files into this directory. By default the output files will be written into
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9966 the same folder as the input file(s). If the specified folder does not exist, Bismark will attempt
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9967 to create it first. The path to the output folder can be either relative or absolute.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9968
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9969 --temp_dir <dir> Write temporary files to this directory instead of into the same directory as the input files. If
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9970 the specified folder does not exist, Bismark will attempt to create it first. The path to the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9971 temporary folder can be either relative or absolute.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9972
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9973 --non_bs_mm Optionally outputs an extra column specifying the number of non-bisulfite mismatches a read during the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9974 alignment step. This option is only available for SAM format. In Bowtie 2 context, this value is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9975 just the number of actual non-bisulfite mismatches and ignores potential 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
9976 The format for single-end reads and read 1 of paired-end reads is 'XA:Z:number of mismatches'
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9977 and 'XB:Z:number of mismatches' for read 2 of paired-end reads.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9978
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9979 --gzip Temporary bisulfite conversion files will be written out in a GZIP compressed form to save disk
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9980 space. This option is available for most alignment modes but is not available for paired-end FastA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9981 files. This option might be somewhat slower than writing out uncompressed files, but this awaits
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9982 further testing.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9983
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9984 --sam The output will be written out in SAM format instead of the default BAM format. Bismark will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9985 attempt to use the path to Samtools that was specified with '--samtools_path', or, if it hasn't
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9986 been specified, attempt to find Samtools in the PATH. If no installation of Samtools can be found,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9987 the SAM output will be compressed with GZIP instead (yielding a .sam.gz output file).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9988
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9989 --cram Writes the output to a CRAM file instead of BAM. This requires the use of Samtools 1.2 or higher.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9990
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9991 --cram_ref <ref_file> CRAM output requires you to specify a reference genome as a single FastA file. If this single-FastA
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9992 reference file is not supplied explicitly it will be regenerated from the genome .fa sequence(s)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9993 used for the Bismark run and written to a file called 'Bismark_genome_CRAM_reference.mfa' into the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9994 oputput directory.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9995
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9996 --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
9997 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
9998
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
9999 --prefix <prefix> Prefixes <prefix> to the output filenames. Trailing dots will be replaced by a single one. For
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10000 example, '--prefix test' with 'file.fq' would result in the output file 'test.file.fq_bismark.sam' etc.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10001
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10002 -B/--basename <basename> Write all output to files starting with this base file name. For example, '--basename foo'
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10003 would result in the files 'foo.bam' and 'foo_SE_report.txt' (or its paired-end equivalent). Takes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10004 precedence over --prefix.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10005
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10006 --old_flag Only in paired-end SAM mode, uses the FLAG values used by Bismark v0.8.2 and before. In addition,
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10007 this options appends /1 and /2 to the read IDs for reads 1 and 2 relative to the input file. Since
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10008 both the appended read IDs and custom FLAG values may cause problems with some downstream tools
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10009 such as Picard, new defaults were implemented as of version 0.8.3.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10010
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10011
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10012 default old_flag
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10013 =================== ===================
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10014 Read 1 Read 2 Read 1 Read 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10015
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10016 OT: 99 147 67 131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10017
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10018 OB: 83 163 115 179
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10019
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10020 CTOT: 147 99 67 131
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10021
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10022 CTOB: 163 83 115 179
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10023
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10024 --ambig_bam For reads that have multiple alignments a random alignment is written out to a special file ending in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10025 '.ambiguous.bam'. The alignments are in Bowtie2 format and do not any contain Bismark specific
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10026 entries such as the methylation call etc. These ambiguous BAM files are intended to be used as
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10027 coverage estimators for variant callers.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10028
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10029 --nucleotide_coverage Calculates the mono- and di-nucleotide sequence composition of covered positions in the analysed BAM
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10030 file and compares it to the genomic average composition once alignments are complete by calling 'bam2nuc'.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10031 Since this calculation may take a while, bam2nuc attempts to write the genomic sequence composition
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10032 into a file called 'genomic_nucleotide_frequencies.txt' indside the reference genome folder so it can
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10033 be re-used the next time round instead of calculating it once again. If a file 'nucleotide_stats.txt' is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10034 found with the Bismark reports it will be automatically detected and used for the Bismark HTML report.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10035 This option works only for BAM or CRAM files.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10036
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10037
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10038 Other:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10039
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10040 -h/--help Displays this help file.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10041
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10042 -v/--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
10043
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10044
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10045 BOWTIE 2 SPECIFIC OPTIONS
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10046
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10047 --bowtie1 Uses Bowtie 1 instead of Bowtie 2, which might be a good choice for faster and very short
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10048 alignments. Bismark assumes that raw sequence data is adapter and/or quality trimmed where
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10049 appropriate. Default: off.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10050
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10051 --bowtie2 Default: ON. Uses Bowtie 2 instead of Bowtie 1. Bismark limits Bowtie 2 to only perform end-to-end
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10052 alignments, i.e. searches for alignments involving all read characters (also called
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10053 untrimmed or unclipped alignments). Bismark assumes that raw sequence data is adapter
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10054 and/or quality trimmed where appropriate. Both small (.bt2) and large (.bt2l) Bowtie 2
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10055 indexes are supported.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10056
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10057 Bowtie 2 alignment options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10058
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10059 -N <int> Sets the number of mismatches to allowed in a seed alignment during multiseed alignment.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10060 Can be set to 0 or 1. Setting this higher makes alignment slower (often much slower)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10061 but increases sensitivity. Default: 0. This option is only available for Bowtie 2 (for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10062 Bowtie 1 see -n).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10063
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10064 -L <int> Sets the length of the seed substrings to align during multiseed alignment. Smaller values
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10065 make alignment slower but more senstive. Default: the --sensitive preset of Bowtie 2 is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10066 used by default, which sets -L to 20. This option is only available for Bowtie 2 (for
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10067 Bowtie 1 see -l).
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10068
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10069 --ignore-quals When calculating a mismatch penalty, always consider the quality value at the mismatched
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10070 position to be the highest possible, regardless of the actual value. I.e. input is treated
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10071 as though all quality values are high. This is also the default behavior when the input
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10072 doesn't specify quality values (e.g. in -f mode). This option is invariable and on by default.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10073
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10074
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10075 Bowtie 2 paired-end options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10076
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10077 --no-mixed This option disables Bowtie 2's behavior to try to find alignments for the individual mates if
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10078 it cannot find a concordant or discordant alignment for a pair. This option is invariable and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10079 and on by default.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10080
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10081 --no-discordant Normally, Bowtie 2 looks for discordant alignments if it cannot find any concordant alignments.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10082 A discordant alignment is an alignment where both mates align uniquely, but that does not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10083 satisfy the paired-end constraints (--fr/--rf/--ff, -I, -X). This option disables that behavior
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10084 and it is on by default.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10085
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10086 --dovetail It is possible, though unusual, for the mates to "dovetail", with the mates seemingly extending
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10087 "past" each other as in this example:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10088
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10089 Mate 1: GTCAGCTACGATATTGTTTGGGGTGACACATTACGC
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10090 Mate 2: TATGAGTCAGCTACGATATTGTTTGGGGTGACACAT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10091 Reference: GCAGATTATATGAGTCAGCTACGATATTGTTTGGGGTGACACATTACGCGTCTTTGAC
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10092
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10093 By default, dovetailing is considered inconsistent with concordant alignment, but setting --dovetail
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10094 causes Bowtie 2 to consider dovetailing alignments as concordant. This becomes relevant whenever
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10095 Reads are clipped from their 5' end prior to mapping, e.g. because of quality or bias issues.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10096 --dovetail is set automatically for PBAT libraries.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10097
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10098
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10099 Bowtie 2 effort options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10100
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10101 -D <int> Up to <int> consecutive seed extension attempts can "fail" before Bowtie 2 moves on, using
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10102 the alignments found so far. A seed extension "fails" if it does not yield a new best or a
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10103 new second-best alignment. Default: 15.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10104
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10105 -R <int> <int> is the maximum number of times Bowtie 2 will "re-seed" reads with repetitive seeds.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10106 When "re-seeding," Bowtie 2 simply chooses a new set of reads (same length, same number of
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10107 mismatches allowed) at different offsets and searches for more alignments. A read is considered
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10108 to have repetitive seeds if the total number of seed hits divided by the number of seeds
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10109 that aligned at least once is greater than 300. Default: 2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10110
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10111 Bowtie 2 parallelization options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10112
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10113
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10114 -p NTHREADS Launch NTHREADS parallel search threads (default: 1). Threads will run on separate processors/cores
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10115 and synchronize when parsing reads and outputting alignments. Searching for alignments is highly
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10116 parallel, and speedup is close to linear. Increasing -p increases Bowtie 2's memory footprint.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10117 E.g. when aligning to a human genome index, increasing -p from 1 to 8 increases the memory footprint
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10118 by a few hundred megabytes. This option is only available if bowtie is linked with the pthreads
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10119 library (i.e. if BOWTIE_PTHREADS=0 is not specified at build time). In addition, this option will
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10120 automatically use the option '--reorder', which guarantees that output SAM records are printed in
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10121 an order corresponding to the order of the reads in the original input file, even when -p is set
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10122 greater than 1 (Bismark requires the Bowtie 2 output to be this way). Specifying --reorder and
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10123 setting -p greater than 1 causes Bowtie 2 to run somewhat slower and use somewhat more memory then
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10124 if --reorder were not specified. Has no effect if -p is set to 1, since output order will naturally
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10125 correspond to input order in that case.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10126
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10127 Bowtie 2 Scoring options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10128
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10129 --score_min <func> Sets a function governing the minimum alignment score needed for an alignment to be considered
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10130 "valid" (i.e. good enough to report). This is a function of read length. For instance, specifying
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10131 L,0,-0.2 sets the minimum-score function f to f(x) = 0 + -0.2 * x, where x is the read length.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10132 See also: setting function options at http://bowtie-bio.sourceforge.net/bowtie2. The default is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10133 L,0,-0.2.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10134
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10135 --rdg <int1>,<int2> Sets the read gap open (<int1>) and extend (<int2>) penalties. A read gap of length N gets a penalty
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10136 of <int1> + N * <int2>. Default: 5, 3.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10137
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10138 --rfg <int1>,<int2> Sets the reference gap open (<int1>) and extend (<int2>) penalties. A reference gap of length N gets
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10139 a penalty of <int1> + N * <int2>. Default: 5, 3.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10140
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10141
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10142 Bowtie 2 Reporting options:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10143
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10144 -most_valid_alignments <int> This used to be the Bowtie 2 parameter -M. As of Bowtie 2 version 2.0.0 beta7 the option -M is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10145 deprecated. It will be removed in subsequent versions. What used to be called -M mode is still the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10146 default mode, but adjusting the -M setting is deprecated. Use the -D and -R options to adjust the
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10147 effort expended to find valid alignments.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10148
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10149 For reference, this used to be the old (now deprecated) description of -M:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10150 Bowtie 2 searches for at most <int>+1 distinct, valid alignments for each read. The search terminates when it
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10151 can't find more distinct valid alignments, or when it finds <int>+1 distinct alignments, whichever
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10152 happens first. Only the best alignment is reported. Information from the other alignments is used to
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10153 estimate mapping quality and to set SAM optional fields, such as AS:i and XS:i. Increasing -M makes
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10154 Bowtie 2 slower, but increases the likelihood that it will pick the correct alignment for a read that
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10155 aligns many places. For reads that have more than <int>+1 distinct, valid alignments, Bowtie 2 does not
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10156 guarantee that the alignment reported is the best possible in terms of alignment score. -M is
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10157 always used and its default value is set to 10.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10158
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10159
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10160 'VANILLA' Bismark OUTPUT:
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10161
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10162 Single-end output format (tab-separated):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10163
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10164 (1) <seq-ID>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10165 (2) <read alignment strand>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10166 (3) <chromosome>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10167 (4) <start position>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10168 (5) <end position>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10169 (6) <observed bisulfite sequence>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10170 (7) <equivalent genomic sequence>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10171 (8) <methylation call>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10172 (9) <read conversion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10173 (10) <genome conversion>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10174 (11) <read quality score (Phred33)>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10175
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10176
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10177 Paired-end output format (tab-separated):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10178 (1) <seq-ID>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10179 (2) <read 1 alignment strand>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10180 (3) <chromosome>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10181 (4) <start position>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10182 (5) <end position>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10183 (6) <observed bisulfite sequence 1>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10184 (7) <equivalent genomic sequence 1>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10185 (8) <methylation call 1>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10186 (9) <observed bisulfite sequence 2>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10187 (10) <equivalent genomic sequence 2>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10188 (11) <methylation call 2>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10189 (12) <read 1 conversion
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10190 (13) <genome conversion>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10191 (14) <read 1 quality score (Phred33)>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10192 (15) <read 2 quality score (Phred33)>
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10193
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10194
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10195 Bismark SAM OUTPUT (default):
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10196
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10197 (1) QNAME (seq-ID)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10198 (2) FLAG (this flag tries to take the strand a bisulfite read originated from into account (this is different from ordinary DNA alignment flags!))
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10199 (3) RNAME (chromosome)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10200 (4) POS (start position)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10201 (5) MAPQ (always 255 for use with Bowtie)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10202 (6) CIGAR
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10203 (7) RNEXT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10204 (8) PNEXT
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10205 (9) TLEN
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10206 (10) SEQ
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10207 (11) QUAL (Phred33 scale)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10208 (12) NM-tag (edit distance to the reference)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10209 (13) MD-tag (base-by-base mismatches to the reference (handles indels)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10210 (14) XM-tag (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
10211 (15) XR-tag (read conversion state for the alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10212 (16) XG-tag (genome conversion state for the alignment)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10213 (17) XA/XB-tag (non-bisulfite mismatches) (optional!)
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10214
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10215 Each read of paired-end alignments is written out in a separate line in the above format.
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10216
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10217
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10218 Last edited on 25 July 2016
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10219 HOW_TO
fcadce4d9a06 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/bismark commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
bgruening
parents:
diff changeset
10220 }