| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
undef $VERSION; |
|
2
|
|
|
|
|
|
|
package Bio::Roary::CommandLine::RoaryCoreAlignment; |
|
3
|
|
|
|
|
|
|
$Bio::Roary::CommandLine::RoaryCoreAlignment::VERSION = '3.10.1'; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Take in the group statistics spreadsheet and the location of the gene multifasta files and create a core alignment. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
513082
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
8
|
1
|
|
|
1
|
|
6703
|
use Getopt::Long qw(GetOptionsFromArray); |
|
|
1
|
|
|
|
|
8092
|
|
|
|
1
|
|
|
|
|
5
|
|
|
9
|
1
|
|
|
1
|
|
171
|
use Cwd 'abs_path'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use File::Path qw(remove_tree); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
52
|
|
|
11
|
1
|
|
|
1
|
|
352
|
use Bio::Roary::ExtractCoreGenesFromSpreadsheet; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
12
|
1
|
|
|
1
|
|
505
|
use Bio::Roary::LookupGeneFiles; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
53
|
|
|
13
|
1
|
|
|
1
|
|
549
|
use Bio::Roary::MergeMultifastaAlignments; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
502
|
|
|
14
|
|
|
|
|
|
|
extends 'Bio::Roary::CommandLine::Common'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); |
|
17
|
|
|
|
|
|
|
has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); |
|
18
|
|
|
|
|
|
|
has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'multifasta_base_directory' => ( is => 'rw', isa => 'Str', default => 'pan_genome_sequences' ); |
|
21
|
|
|
|
|
|
|
has 'spreadsheet_filename' => ( is => 'rw', isa => 'Str', default => 'gene_presence_absence.csv' ); |
|
22
|
|
|
|
|
|
|
has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'core_gene_alignment.aln' ); |
|
23
|
|
|
|
|
|
|
has 'core_definition' => ( is => 'rw', isa => 'Num', default => 0.99 ); |
|
24
|
|
|
|
|
|
|
has 'dont_delete_files' => ( is => 'rw', isa => 'Bool', default => 0 ); |
|
25
|
|
|
|
|
|
|
has 'allow_paralogs' => ( is => 'rw', isa => 'Bool', default => 0 ); |
|
26
|
|
|
|
|
|
|
has '_error_message' => ( is => 'rw', isa => 'Str' ); |
|
27
|
|
|
|
|
|
|
has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub BUILD { |
|
30
|
3
|
|
|
3
|
0
|
7
|
my ($self) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
11
|
my ( $multifasta_base_directory, $spreadsheet_filename, $output_filename, $core_definition,$verbose, $help, $mafft, $allow_paralogs, $dont_delete_files ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
107
|
GetOptionsFromArray( |
|
35
|
|
|
|
|
|
|
$self->args, |
|
36
|
|
|
|
|
|
|
'm|multifasta_base_directory=s' => \$multifasta_base_directory, |
|
37
|
|
|
|
|
|
|
's|spreadsheet_filename=s' => \$spreadsheet_filename, |
|
38
|
|
|
|
|
|
|
'o|output_filename=s' => \$output_filename, |
|
39
|
|
|
|
|
|
|
'cd|core_definition=f' => \$core_definition, |
|
40
|
|
|
|
|
|
|
'z|dont_delete_files' => \$dont_delete_files, |
|
41
|
|
|
|
|
|
|
'p|allow_paralogs' => \$allow_paralogs, |
|
42
|
|
|
|
|
|
|
'v|verbose' => \$verbose, |
|
43
|
|
|
|
|
|
|
'h|help' => \$help, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
50
|
|
|
|
2640
|
if ( defined($verbose) ) { |
|
47
|
0
|
|
|
|
|
0
|
$self->verbose($verbose); |
|
48
|
0
|
|
|
|
|
0
|
$self->logger->level(10000); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
3
|
100
|
|
|
|
71
|
$self->help($help) if(defined($help)); |
|
51
|
3
|
50
|
|
|
|
10
|
$self->allow_paralogs($allow_paralogs) if(defined($allow_paralogs)); |
|
52
|
|
|
|
|
|
|
|
|
53
|
3
|
100
|
66
|
|
|
45
|
if ( defined($multifasta_base_directory) && ( -d $multifasta_base_directory ) ) { |
|
54
|
2
|
|
|
|
|
100
|
$self->multifasta_base_directory( abs_path($multifasta_base_directory)); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
3
|
100
|
|
|
|
96
|
if(! -d $self->multifasta_base_directory ) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
1
|
|
|
|
|
45
|
$self->_error_message("Error: Cant access the multifasta base directory: ".$self->multifasta_base_directory); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
100
|
66
|
|
|
27
|
if ( defined($spreadsheet_filename) && ( -e $spreadsheet_filename ) ) { |
|
62
|
2
|
|
|
|
|
81
|
$self->spreadsheet_filename( abs_path($spreadsheet_filename)); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
3
|
100
|
|
|
|
93
|
if(! -e $self->spreadsheet_filename ) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
1
|
|
|
|
|
44
|
$self->_error_message("Error: Cant access the spreadsheet: ".$self->spreadsheet_filename); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
3
|
50
|
|
|
|
9
|
$self->output_filename( $output_filename ) if ( defined($output_filename) ); |
|
69
|
3
|
100
|
|
|
|
8
|
if ( defined($core_definition) ) |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
1
|
50
|
|
|
|
7
|
if($core_definition > 1) |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
0
|
|
|
|
|
0
|
$self->core_definition( $core_definition/100 ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
1
|
|
|
|
|
26
|
$self->core_definition( $core_definition ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
3
|
50
|
|
|
|
74
|
$self->dont_delete_files($dont_delete_files) if ( defined($dont_delete_files) ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub run { |
|
85
|
3
|
|
|
3
|
0
|
7
|
my ($self) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
3
|
100
|
|
|
|
68
|
( !$self->help ) or die $self->usage_text; |
|
88
|
2
|
50
|
|
|
|
48
|
if ( defined( $self->_error_message ) ) { |
|
89
|
0
|
|
|
|
|
0
|
print $self->_error_message . "\n"; |
|
90
|
0
|
|
|
|
|
0
|
die $self->usage_text; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
2
|
|
|
|
|
54
|
$self->logger->info("Extract core genes from spreadsheet"); |
|
94
|
2
|
|
|
|
|
64
|
my $core_genes_obj = Bio::Roary::ExtractCoreGenesFromSpreadsheet->new( |
|
95
|
|
|
|
|
|
|
spreadsheet => $self->spreadsheet_filename, |
|
96
|
|
|
|
|
|
|
core_definition => $self->core_definition, |
|
97
|
|
|
|
|
|
|
allow_paralogs => $self->allow_paralogs |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
44
|
$self->logger->info("Looking up genes in files"); |
|
101
|
2
|
|
|
|
|
60
|
my $gene_files = Bio::Roary::LookupGeneFiles->new( |
|
102
|
|
|
|
|
|
|
multifasta_directory => $self->multifasta_base_directory, |
|
103
|
|
|
|
|
|
|
ordered_genes => $core_genes_obj->ordered_core_genes, |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
49
|
$self->logger->info("Merge multifasta alignments"); |
|
107
|
2
|
|
|
|
|
60
|
my $merge_alignments_obj = Bio::Roary::MergeMultifastaAlignments->new( |
|
108
|
|
|
|
|
|
|
sample_names => $core_genes_obj->sample_names, |
|
109
|
|
|
|
|
|
|
multifasta_files => $gene_files->ordered_gene_files(), |
|
110
|
|
|
|
|
|
|
output_filename => $self->output_filename, |
|
111
|
|
|
|
|
|
|
sample_names_to_genes => $core_genes_obj->sample_names_to_genes |
|
112
|
|
|
|
|
|
|
); |
|
113
|
2
|
|
|
|
|
9
|
$merge_alignments_obj->merge_files; |
|
114
|
|
|
|
|
|
|
|
|
115
|
2
|
50
|
|
|
|
57
|
if($self->dont_delete_files == 0) |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
2
|
|
|
|
|
297
|
remove_tree('pan_genome_sequences'); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub usage_text { |
|
122
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
19
|
return <<USAGE; |
|
125
|
|
|
|
|
|
|
Usage: pan_genome_core_alignment [options] |
|
126
|
|
|
|
|
|
|
Create an alignment of core genes from the spreadsheet and the directory of gene multi-FASTAs. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Options: -o STR output filename [core_gene_alignment.aln] |
|
129
|
|
|
|
|
|
|
-cd FLOAT percentage of isolates a gene must be in to be core [99] |
|
130
|
|
|
|
|
|
|
-m STR directory containing gene multi-FASTAs [pan_genome_sequences] |
|
131
|
|
|
|
|
|
|
-s STR gene presence and absence spreadsheet [gene_presence_absence.csv] |
|
132
|
|
|
|
|
|
|
-p allow paralogs |
|
133
|
|
|
|
|
|
|
-z dont delete intermediate files |
|
134
|
|
|
|
|
|
|
-v verbose output to STDOUT |
|
135
|
|
|
|
|
|
|
-h this help message |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
For further info see: http://sanger-pathogens.github.io/Roary/ |
|
138
|
|
|
|
|
|
|
USAGE |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
142
|
1
|
|
|
1
|
|
8
|
no Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
143
|
|
|
|
|
|
|
1; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=pod |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=encoding UTF-8 |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 NAME |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Bio::Roary::CommandLine::RoaryCoreAlignment - Take in the group statistics spreadsheet and the location of the gene multifasta files and create a core alignment. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 VERSION |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
version 3.10.1 |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Take in the group statistics spreadsheet and the location of the gene multifasta files and create a core alignment. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is free software, licensed under: |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |