annotate Roary/lib/Bio/Roary.pm @ 1:997f4f276c1c draft

Uploaded
author dereeper
date Fri, 14 May 2021 20:42:33 +0000
parents c47a5f61bc9f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
1 package Bio::Roary;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
2
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
3 # ABSTRACT: Create a pan genome
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
4
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
5 =head1 SYNOPSIS
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
6
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
7 Create a pan genome
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
8
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
9 =cut
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
10
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
11 use Moose;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
12 use File::Copy;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
13 use Bio::Perl;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
14 use Bio::Roary::ParallelAllAgainstAllBlast;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
15 use Bio::Roary::CombinedProteome;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
16 use Bio::Roary::External::Cdhit;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
17 use Bio::Roary::External::Mcl;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
18 use Bio::Roary::InflateClusters;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
19 use Bio::Roary::AnalyseGroups;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
20 use Bio::Roary::GroupLabels;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
21 use Bio::Roary::AnnotateGroups;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
22 use Bio::Roary::GroupStatistics;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
23 use Bio::Roary::Output::GroupsMultifastasNucleotide;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
24 use Bio::Roary::External::PostAnalysis;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
25 use Bio::Roary::FilterFullClusters;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
26 use Bio::Roary::External::IterativeCdhit;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
27 use Bio::Roary::Output::BlastIdentityFrequency;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
28
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
29 has 'fasta_files' => ( is => 'rw', isa => 'ArrayRef', required => 1 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
30 has 'input_files' => ( is => 'rw', isa => 'ArrayRef', required => 1 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
31 has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'clustered_proteins' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
32 has 'output_pan_geneome_filename' => ( is => 'rw', isa => 'Str', default => 'pan_genome.fa' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
33 has 'output_statistics_filename' => ( is => 'rw', isa => 'Str', default => 'gene_presence_absence.csv' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
34 has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
35 has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
36 has 'makeblastdb_exec' => ( is => 'rw', isa => 'Str', default => 'makeblastdb' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
37 has 'blastp_exec' => ( is => 'rw', isa => 'Str', default => 'blastp' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
38 has 'mcxdeblast_exec' => ( is => 'ro', isa => 'Str', default => 'mcxdeblast' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
39 has 'mcl_exec' => ( is => 'ro', isa => 'Str', default => 'mcl' );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
40 has 'perc_identity' => ( is => 'ro', isa => 'Num', default => 98 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
41 has 'dont_delete_files' => ( is => 'ro', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
42 has 'dont_create_rplots' => ( is => 'rw', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
43 has 'dont_split_groups' => ( is => 'ro', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
44 has 'verbose_stats' => ( is => 'rw', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
45 has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
46 has 'group_limit' => ( is => 'rw', isa => 'Num', default => 50000 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
47 has 'core_definition' => ( is => 'rw', isa => 'Num', default => 1.0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
48 has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
49 has 'mafft' => ( is => 'ro', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
50 has 'inflation_value' => ( is => 'rw', isa => 'Num', default => 1.5 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
51 has 'allow_paralogs' => ( is => 'rw', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
52
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
53 has 'output_multifasta_files' => ( is => 'ro', isa => 'Bool', default => 0 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
54
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
55 sub run {
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
56 my ($self) = @_;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
57
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
58 my $output_combined_filename = '_combined_files';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
59 my $output_cd_hit_filename = '_clustered';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
60 my $output_blast_results_filename = '_blast_results';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
61 my $output_mcl_filename = '_uninflated_mcl_groups';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
62 my $output_filtered_clustered_fasta = '_clustered_filtered.fa';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
63 my $cdhit_groups = $output_combined_filename.'.groups';
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
64
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
65
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
66 unlink($cdhit_groups) unless($self->dont_delete_files == 1);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
67
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
68 print "Combine proteins into a single file\n" if($self->verbose);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
69 my $combine_fasta_files = Bio::Roary::CombinedProteome->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
70 proteome_files => $self->fasta_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
71 output_filename => $output_combined_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
72 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
73 $combine_fasta_files->create_combined_proteome_file;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
74
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
75 my $number_of_input_files = @{$self->input_files};
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
76
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
77 print "Iteratively run cd-hit\n" if($self->verbose);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
78 my $iterative_cdhit= Bio::Roary::External::IterativeCdhit->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
79 output_cd_hit_filename => $output_cd_hit_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
80 output_combined_filename => $output_combined_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
81 number_of_input_files => $number_of_input_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
82 output_filtered_clustered_fasta => $output_filtered_clustered_fasta,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
83 job_runner => $self->job_runner,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
84 cpus => $self->cpus
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
85 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
86
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
87 $iterative_cdhit->run();
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
88
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
89 print "Parallel all against all blast\n" if($self->verbose);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
90 my $blast_obj = Bio::Roary::ParallelAllAgainstAllBlast->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
91 fasta_file => $output_cd_hit_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
92 blast_results_file_name => $output_blast_results_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
93 job_runner => $self->job_runner,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
94 cpus => $self->cpus,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
95 makeblastdb_exec => $self->makeblastdb_exec,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
96 blastp_exec => $self->blastp_exec,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
97 perc_identity => $self->perc_identity
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
98 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
99 $blast_obj->run();
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
100
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
101 my $blast_identity_frequency_obj = Bio::Roary::Output::BlastIdentityFrequency->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
102 input_filename => $output_blast_results_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
103 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
104 $blast_identity_frequency_obj->create_file();
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
105
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
106 print "Cluster with MCL\n" if($self->verbose);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
107 my $mcl = Bio::Roary::External::Mcl->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
108 blast_results => $output_blast_results_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
109 mcxdeblast_exec => $self->mcxdeblast_exec,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
110 mcl_exec => $self->mcl_exec,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
111 job_runner => $self->job_runner,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
112 cpus => $self->cpus,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
113 inflation_value => $self->inflation_value,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
114 output_file => $output_mcl_filename
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
115 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
116 $mcl->run();
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
117
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
118 unlink($output_blast_results_filename) unless($self->dont_delete_files == 1);
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
119
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
120 my $post_analysis = Bio::Roary::External::PostAnalysis->new(
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
121 job_runner => 'Local',
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
122 cpus => $self->cpus,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
123 fasta_files => $self->fasta_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
124 input_files => $self->input_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
125 output_filename => $self->output_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
126 output_pan_geneome_filename => $self->output_pan_geneome_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
127 output_statistics_filename => $self->output_statistics_filename,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
128 clusters_filename => $output_cd_hit_filename.'.clstr',
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
129 dont_wait => 1,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
130 output_multifasta_files => $self->output_multifasta_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
131 dont_delete_files => $self->dont_delete_files,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
132 dont_create_rplots => $self->dont_create_rplots,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
133 dont_split_groups => $self->dont_split_groups,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
134 verbose_stats => $self->verbose_stats,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
135 translation_table => $self->translation_table,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
136 group_limit => $self->group_limit,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
137 core_definition => $self->core_definition,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
138 verbose => $self->verbose,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
139 mafft => $self->mafft,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
140 allow_paralogs => $self->allow_paralogs,
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
141 );
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
142 $post_analysis->run();
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
143
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
144 }
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
145
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
146
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
147 no Moose;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
148 __PACKAGE__->meta->make_immutable;
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
149
c47a5f61bc9f Uploaded
dereeper
parents:
diff changeset
150 1;