-
Notifications
You must be signed in to change notification settings - Fork 3
/
woland-mutageniclogo.pl
executable file
·150 lines (130 loc) · 4.87 KB
/
woland-mutageniclogo.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
########################################################################################################################################
## WOLAND Beta 1.01 (09-30-2017)
## woland-mutageniclogo.pl
##
## WOLAND is a multiplatform tool to analyze point mutation patterns using resequencing data from any organism or cell.
##
## For more details please read README file.
##
########################################################################################################################################
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::ArgParse;
our $REVISION = '$Revision: $';
our $DATE = '$Date: 2017-09-30 00:11:04 -0800 (Sat, 30 Sep 2017) $';
our $AUTHOR = '$Author: Tiago A. de Souza <[email protected]> $';
#global variables
our ($table, $sensechange);
our ($revcomp);
our (@sensesequence);
our (@targetsequence);
sub parse_inputtable_to_sensechanges{ #parsing input-table, extract context sequence and apply reverse-complement to non-sense changes
my $tableline;
open (TABLE, $table);
my @tablearray=<TABLE>;
close(TABLE);
my (@samplename,@group,@targetsequence,@sensesequence);
foreach $tableline (@tablearray){ # two arrays for each category (group & sample results folder)
my @i = split (/\t/, $tableline);
chomp (@i);
push (@group, "$i[0]"); # array for group definition
push (@samplename, "$i[1]"); # array for sample folder definition
}
for my $i (0..$#samplename){
open CONTEXTSEQANNO, "<results-batch-$table/samples-$table/results-$samplename[$i]/WOLAND-contextsequencesanno-$samplename[$i]";
my @fastacontext=<CONTEXTSEQANNO>;
close (CONTEXTSEQANNO);
my @fastacontextprocessed=();
for my $ii (0..$#fastacontext){
if ($fastacontext[$ii] =~ /^>/){
my @sequencesplitted = split (/\t/, "$fastacontext[$ii+1]");
my @idsplitted = split (/\n/, "$fastacontext[$ii]");
chomp(@sequencesplitted);
push (@fastacontextprocessed, "$idsplitted[0]\n$sequencesplitted[0]\n");
}
}
my $fastacontextprocessedline;
@targetsequence=();
foreach $fastacontextprocessedline (@fastacontextprocessed){
my @iii = split (/\n/, "$fastacontextprocessedline");
push (@targetsequence, $iii[1]);
}
for my $ii (0..$#targetsequence){ #C>T change
if ($sensechange=~"CT"){
if($targetsequence[$ii]=~"...C..."){
push (@sensesequence, "$targetsequence[$ii]");
}
if($targetsequence[$ii]=~"...G..."){
&to_reversecomplement($targetsequence[$ii]);
push (@sensesequence, "$revcomp");
}
}
if ($sensechange=~"GT"){ #G>T change
if($targetsequence[$ii]=~"...G..."){
push (@sensesequence, "$targetsequence[$ii]");
}
if($targetsequence[$ii]=~"...C..."){
&to_reversecomplement($targetsequence[$ii]);
push (@sensesequence, "$revcomp");
}
}
if ($sensechange=~"GC"){ #G>C change
if($targetsequence[$ii]=~"...G..."){
push (@sensesequence, "$targetsequence[$ii]");
}
if($targetsequence[$ii]=~"...C..."){
&to_reversecomplement($targetsequence[$ii]);
push (@sensesequence, "$revcomp");
}
}
}
open (LOGO, ">>results-batch-$table/samples-$table/results-$samplename[$i]/WOLAND-LOGO-$sensechange-$samplename[$i]");
for my $ii (0..$#sensesequence){
print LOGO "\>$i\n$sensesequence[$ii]\n";
}
close (LOGO);
@sensesequence=();
}
}
sub to_reversecomplement{ #reversecomplement based on sense-change
my $dna="$_[0]";
$dna = shift;
$revcomp = reverse($dna); # reverse the DNA sequence
$revcomp =~ tr/ACGTacgt/TGCAtgca/; # complement the reversed DNA sequence
return $revcomp;
}
my $ap = Getopt::ArgParse->new_parser(
prog => 'woland-mutageniclogo.pl',
description => 'WOLAND is a multiplatform tool to analyze point mutation patterns using resequencing SNV data.
Use woland-mutageniclogo to extract stranded context sequences FASTA files specific for C>T, G>T and G>C changes AFTER woland-report. For more details please read README',
epilog => 'If you used Woland in your research, we would appreciate your citation:
de Souza TA, Defelicibus A, Menck CF',
);
$ap->add_arg(
'--sense-change',
'-s',
required => 1,
choices => [ 'CT', 'GT', 'GC' ],
help => 'Type of sense-nucleotide change to filter in extracted sequences');
$ap->add_arg(
'--input-table',
'-i',
required => 1,
help => 'Tab-delimited file with samples in the 1st column and groups in the 2nd column');
my $args = $ap->parse_args();
## main warning
# unless ($#ARGV>=1){
# die "\nERROR : Incorrect number of arguments/files - Usage: $0 <sensechange> <input-table> \n\n";
# }
# unless ($ARGV[0] eq "GT" || $ARGV[0] eq "CT" || $ARGV[0] eq "GC"){
# die "\nERROR : Incorrect <typeofchange>. Please use CT,GT or GC\n\n";
# }
unless (-r -e -f $args->input_table){
die sprintf("\nERROR: %s not exists or is not readable or not properly formatted. Please check file.\n\n",
$args->input_table);
}
$sensechange = $args->sense_change;
$table = $args->input_table;
&parse_inputtable_to_sensechanges;
exit;