Bio-MLST-Check
view release on metacpan or search on metacpan
lib/Bio/MLST/Check.pm view on Meta::CPAN
$pm->wait_all_children;
1;
}
sub _build__input_fasta_files
{
my($self) = @_;
return $self->raw_input_fasta_files;
}
sub create_result_files
{
my($self) = @_;
exit 1 unless $self->input_fasta_files_exist;
$self->_generate_spreadsheet_rows;
my $spreadsheet = Bio::MLST::Spreadsheet::File->new(
header => pop(@{$self->_spreadsheet_header}),
spreadsheet_allele_numbers_rows => $self->_spreadsheet_allele_numbers_rows,
spreadsheet_genomic_rows => $self->_spreadsheet_genomic_rows,
output_directory => $self->output_directory,
spreadsheet_basename => $self->spreadsheet_basename
);
$spreadsheet->create();
if($self->output_fasta_files)
{
$self->_create_alignment('Fasta','fa');
}
if($self->output_phylip_files)
{
$self->_create_alignment('phylip','phylip');
}
1;
}
sub _create_alignment
{
my($self, $format, $extension) = @_;
my $output_filename = join('/',($self->output_directory,'concatenated_alleles.'.$extension));
my $out = Bio::AlignIO->new(-file => "+>$output_filename" , '-format' => $format);
my $aln = Bio::SimpleAlign->new();
for(my $i = 0; $i < @{$self->_concat_names}; $i++)
{
next unless(defined( $self->_concat_sequences->[$i]));
$aln->add_seq(Bio::LocatableSeq->new(
-seq => $self->_concat_sequences->[$i],
-id => $self->_concat_names->[$i],
-start => 1,
-end => length($self->_concat_sequences->[$i])
));
}
$out->write_aln($aln);
}
sub input_fasta_files_exist
{
my($self) = @_;
my $file_not_found = 0;
for my $fastafile (@{$self->_input_fasta_files})
{
unless( -e $fastafile )
{
print qq[Input fasta file not found: $fastafile\n];
$file_not_found++;
}
}
return $file_not_found ? 0:1;
}
no Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Bio::MLST::Check - Multilocus sequence type checking using blast
=head1 VERSION
version 2.1.1706216
=head1 SYNOPSIS
High throughput multilocus sequence typing (MLST) checking.
=head1 DESCRIPTION
This application is for taking Multilocus sequence typing (MLST) sources from multiple locations and consolidating them in one place so that they can be easily used (and kept up to date).
Then you can provide FASTA files and get out sequence types for a given MLST database.
Two spreadsheets are outputted, one contains the allele number for each locus, and the ST (or nearest ST), the other contains the genomic sequence for each allele.
If more than 1 allele gives 100% identity for a locus, the contaminated flag is set.
Optionally you can output a concatenated sequence in FASTA format, which you can then use with tree building programs.
New, unseen alleles are saved in FASTA format, with 1 per file, for submission to back to MLST databases.
It requires NCBI Blast+ to be installed and for blastn and makeblastdb to be in your PATH.
# Add this environment variable to your ~/.bashrc file - do this once
export MLST_DATABASES=/path/to/where_you_want_to_store_the_databases
# Download the latest copy of the databases (run it once per month)
download_mlst_databases
# Find the sequence types for all fasta files in your current directory
get_sequence_type -s "Clostridium difficile" *.fa
use Bio::MLST::Check;
Bio::MLST::Check->new(
'species' => 'E.coli',
'base_directory' => '/path/to/dir',
'raw_input_fasta_files' => ['myfasta.fa'],
'makeblastdb_exec' => 'makeblastdb',
'blastn_exec' => 'blastn',
'output_directory' => '/path/to/output',
'output_fasta_files'=> 1,
);
=head1 METHODS
=head2 create_result_files
Creates a spreadsheet of results, FASTA files with novel sequences and optionally a concatentated sequence (FASTA) for tree building.
( run in 0.817 second using v1.01-cache-2.11-cpan-e1769b4cff6 )