annotate breakMAF.pl @ 3:d49b9759e294 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit 3abc213e109bb564de7dee75d71d90eb1bf78c7e
author rnateam
date Thu, 15 Nov 2018 01:24:06 -0500
parents 434332033e82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
1 #!/usr/bin/perl -w
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
2
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
3 use strict;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
4 use Getopt::Long;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
5 use POSIX qw(ceil floor);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
6
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
7 my $maxLength = 400;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
8 my $desiredLength = 200;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
9 my $help = 0;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
10
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
11 GetOptions(
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
12 "maxLength:i" => \$maxLength,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
13 "desiredLength:i" => \$desiredLength,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
14 "help" => \$help,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
15 "h" => \$help
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
16 );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
17
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
18 if ($help) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
19 print STDERR "\nbreakMAF [options] < input.maf > output.maf\n\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
20 print STDERR "Options:\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
21 print STDERR " maxLength: Break all blocks longer than that (default: 400 columns)\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
22 print STDERR " desiredLength: Try to create blocks of this size (default: 200 columns)\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
23 exit(1);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
24 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
25
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
26 $/ = 'a score=';
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
27
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
28 while ( my $block = <> ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
29
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
30 $block = 'a score=' . $block;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
31
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
32 my $currAln = readMAF($block)->[0];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
33
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
34 next if not defined($currAln);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
35
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
36 my $length = length( $currAln->[0]->{seq} );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
37
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
38 if ( $length > $maxLength ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
39
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
40 my $breakN = int( $length / $desiredLength );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
41 my $chunkLength = ceil( $length / $breakN );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
42
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
43 my $from = 0;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
44
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
45 while (1) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
46 my $to = $from + $chunkLength;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
47
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
48 if ( $to > $length ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
49 $to = $length;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
50 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
51
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
52 my $slice = sliceAlnByColumn( $currAln, $from, $to );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
53
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
54 print formatAln( $slice, 'maf' ), "\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
55
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
56 $from = $to;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
57
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
58 last if $from == $length;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
59 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
60
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
61 } else {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
62 print formatAln( $currAln, 'maf' ), "\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
63 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
64 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
65
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
66 ######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
67 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
68 # readMAF($string)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
69 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
70 # Converts the MAF in string to internal alignment format. Returns
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
71 # list of usual array references.
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
72 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
73 ######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
74
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
75 sub readMAF {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
76
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
77 my $string = shift;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
78
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
79 return [] if $string eq '';
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
80
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
81 my @input = split( "\n", $string );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
82
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
83 #open(FILE,"<$file") || die("Could not read $file ($!)");
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
84
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
85 my @outAlns = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
86 my @aln = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
87
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
88 foreach my $i ( 0 .. $#input ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
89
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
90 $_ = $input[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
91
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
92 next if (/^\s?\#/);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
93 next if (/^\s?a/);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
94
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
95 if (/^\s?s/) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
96 ( my $dummy, my $name, my $start, my $length, my $strand, my $fullLength, my $seq ) = split;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
97
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
98 my $end = $start + $length;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
99
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
100 ( my $org, my $chrom ) = split( /\./, $name );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
101
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
102 push @aln, {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
103 name => $name,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
104 org => $org,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
105 chrom => $chrom,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
106 start => $start,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
107 end => $end,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
108 seq => $seq,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
109 strand => $strand
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
110 };
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
111 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
112
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
113 if ( /^\s?$/ and @aln ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
114 push @outAlns, [@aln];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
115 @aln = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
116 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
117 if ( ( not defined $input[ $i + 1 ] ) and (@aln) ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
118 push @outAlns, [@aln];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
119 @aln = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
120 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
121 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
122 return \@outAlns;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
123 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
124
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
125 sub formatAln {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
126
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
127 my @aln = @{ $_[0] };
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
128
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
129 my $format = $_[1];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
130
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
131 $format = lc($format);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
132
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
133 my @alnSeqs = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
134 my @alnNames = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
135
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
136 my $counter = 1;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
137
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
138 foreach my $row (@aln) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
139
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
140 my $name = "seq$counter";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
141 $counter++;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
142 if ( $row->{name} ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
143 $name = ( $row->{name} );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
144 } elsif ( $row->{org} and $row->{chrom} ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
145 $name = "$row->{org}.$row->{chrom}";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
146 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
147
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
148 my $start = $row->{start};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
149 my $end = $row->{end};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
150 my $strand = $row->{strand};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
151
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
152 my $pos = '';
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
153
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
154 if ( defined $start
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
155 and defined $end
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
156 and defined $strand
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
157 and ( $format ne 'phylip' ) ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
158 ( $start, $end ) = ( $end, $start ) if ( $strand eq '-' );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
159 $pos = "/$start-$end";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
160 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
161
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
162 push @alnNames, "$name$pos";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
163 push @alnSeqs, $row->{seq};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
164
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
165 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
166
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
167 my $output = '';
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
168
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
169 if ( $format eq 'clustal' ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
170
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
171 $output = "CLUSTAL W(1.81) multiple sequence alignment\n\n\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
172 my $maxName = 0;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
173
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
174 foreach my $name (@alnNames) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
175 $maxName = ( $maxName < length($name) ) ? length($name) : $maxName;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
176 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
177
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
178 for my $i ( 0 .. $#alnNames ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
179 my $buffer = " " x ( ( $maxName + 6 ) - length( $alnNames[$i] ) );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
180 $alnNames[$i] .= $buffer;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
181 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
182 my $columnWidth = 60;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
183 my $currPos = 0;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
184 my $length = length( $alnSeqs[0] );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
185
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
186 while ( $currPos < $length ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
187 for my $i ( 0 .. $#alnNames ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
188 $output .= $alnNames[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
189 $output .= substr( $alnSeqs[$i], $currPos, $columnWidth );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
190 $output .= "\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
191 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
192 $output .= "\n\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
193 $currPos += $columnWidth;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
194 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
195 } elsif ( $format eq 'fasta' ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
196 foreach my $i ( 0 .. $#alnNames ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
197 my $name = $alnNames[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
198 my $seq = $alnSeqs[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
199 $seq =~ s/(.{60})/$1\n/g;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
200 $output .= ">$name\n$seq\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
201 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
202 } elsif ( $format eq 'phylip' ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
203 my $length = length( $alnSeqs[0] );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
204 my $N = @alnSeqs;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
205 $output .= " $N $length\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
206 foreach my $i ( 0 .. $#alnNames ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
207 my $name = $alnNames[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
208 my $seq = $alnSeqs[$i];
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
209 $seq =~ s/(.{60})/$1\n/g;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
210 $output .= "$name\n$seq\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
211 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
212 } elsif ( $format eq 'maf' ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
213 $output .= "a score=0\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
214 foreach my $row (@aln) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
215 my $length = $row->{end} - $row->{start};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
216 $output .= "s $row->{org}.$row->{chrom} $row->{start} $length $row->{strand} 0 $row->{seq}\n";
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
217 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
218 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
219 return $output;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
220
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
221 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
222
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
223 ######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
224 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
225 # sliceAlnByColumn(\@aln ref-to-alignment, $start int, $end int)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
226 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
227 # Returns slice of alignment specified by alignment column.
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
228 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
229 # \@aln ... alignment in list of hash format
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
230 # $start, $end ... slice to cut
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
231 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
232 # Returns reference to alignment in list of hash format. This is a new
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
233 # alignment, i.e. the input is not sliced in place
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
234 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
235 ######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
236
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
237 sub sliceAlnByColumn {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
238
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
239 my @aln = @{ $_[0] };
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
240 shift;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
241 ( my $start, my $end ) = @_;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
242
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
243 # correct ends without warning if outside of valid range
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
244 $start = 0 if ( $start < 0 );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
245 $end = length( $aln[0]->{seq} ) if ( $end > length( $aln[0]->{seq} ) );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
246
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
247 #my @newAln=@aln;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
248
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
249 # make deep copy of list of hash
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
250 my @newAln = ();
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
251 foreach (@aln) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
252 push @newAln, { %{$_} };
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
253 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
254
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
255 foreach my $i ( 0 .. $#newAln ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
256
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
257 my $oldStart = $newAln[$i]->{start};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
258 my $oldEnd = $newAln[$i]->{end};
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
259
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
260 $newAln[$i]->{start} = alnCol2genomePos( $newAln[$i]->{seq}, $oldStart, $start );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
261 $newAln[$i]->{end} = alnCol2genomePos( $newAln[$i]->{seq}, $oldStart, $end - 1 ) + 1;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
262 $newAln[$i]->{seq} = substr( $newAln[$i]->{seq}, $start, $end - $start );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
263
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
264 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
265
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
266 return ( [@newAln] );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
267
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
268 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
269
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
270 ######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
271 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
272 # alnCol2genomePos($seq string, $start int, $col int)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
273 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
274 # Calculates the genomic position corresponding to a column in an
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
275 # alignment.
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
276 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
277 # $seq ... sequence from alignment (i.e. letters with gaps)
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
278 # $start ... Genomic position of first letter in $seq
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
279 # $col ... column in the alignment that is to be mapped
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
280 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
281 # Returns genomic position. No error handling, so $col must be a valid
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
282 # column of the string $seq.
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
283 #
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
284 #######################################################################
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
285
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
286 sub alnCol2genomePos {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
287
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
288 ( my $seq, my $start, my $col ) = @_;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
289
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
290 $seq =~ s/\./-/g; #Convert all gaps to "-"
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
291
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
292 my $newPos = $start;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
293
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
294 # if gap only...
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
295 return $start if ( $seq =~ /^-+$/ );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
296
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
297 ( my $tmp ) = $seq =~ /(-*)[^-]/;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
298
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
299 my $leadingGaps = length($tmp);
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
300
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
301 # if column is in gap before first letter,
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
302 # return position of the first letter
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
303 return $start if ( $col < $leadingGaps );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
304
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
305 $newPos = $start - 1;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
306
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
307 for my $i ( $leadingGaps .. $col ) {
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
308 $newPos++ if ( ( my $t = substr( $seq, $i, 1 ) ) ne '-' );
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
309 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
310 return $newPos;
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
311 }
434332033e82 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/rnacode commit b6d3800e260cdfcbe99e5f056344c3df101dad00
rnateam
parents:
diff changeset
312