def __init__(self, cleaned_data): # skip sequences with accession numbers and building GenBank Fasta file self.sequences_skipped = [] self.cleaned_data = cleaned_data self.translations = None self.degen_translations = None self.clean_translations() self.errors = [] self.seq_objs = [] self.minimum_number_of_genes = cleaned_data['number_genes'] self.aminoacids = cleaned_data['aminoacids'] try: self.codon_positions = clean_positions(cleaned_data['positions']) except exceptions.InadequateCodonPositions as e: self.codon_positions = None self.errors = [e] self.file_format = cleaned_data['file_format'] self.partition_by_positions = cleaned_data['partition_by_positions'] self.voucher_codes = get_voucher_codes(cleaned_data) self.gene_codes = get_gene_codes(cleaned_data) self.gene_codes_and_lengths = None self.taxon_names = cleaned_data['taxon_names'] self.voucher_codes_metadata = dict() self.gene_codes_metadata = self.get_gene_codes_metadata() self.warnings = [] self.outgroup = cleaned_data['outgroup'] self.dataset_file = None self.aa_dataset_file = None self.charset_block = None self.dataset_str = self.create_dataset()
def __init__(self, cleaned_data): self.cleaned_data = self.populate_cleaned_data_form(cleaned_data) self.voucher_codes = get_voucher_codes(cleaned_data) self.gene_codes = get_gene_codes(cleaned_data) self.fasta_datasets = self.get_fasta_datasets() self.genes_type = self.get_genes_type() self.stats = self.get_stats_from_datasets()
def __init__(self, cleaned_data): self.cleaned_data = cleaned_data self.translations = None self.degen_translations = None self.clean_translations() self.errors = [] self.seq_objs = [] self.minimum_number_of_genes = cleaned_data["number_genes"] self.aminoacids = cleaned_data["aminoacids"] try: self.codon_positions = clean_positions(cleaned_data["positions"]) except exceptions.InadequateCodonPositions as e: self.codon_positions = None self.errors = [e] self.file_format = cleaned_data["file_format"] self.partition_by_positions = cleaned_data["partition_by_positions"] self.voucher_codes = get_voucher_codes(cleaned_data) self.gene_codes = get_gene_codes(cleaned_data) self.gene_codes_and_lengths = None self.taxon_names = cleaned_data["taxon_names"] self.voucher_codes_metadata = dict() self.gene_codes_metadata = self.get_gene_codes_metadata() self.warnings = [] self.outgroup = cleaned_data["outgroup"] self.dataset_file = None self.aa_dataset_file = None self.charset_block = None self.dataset_str = self.create_dataset()
def __init__(self, cleaned_data): self.cleaned_data = cleaned_data self.gene_info_to_display = self.get_gene_info_to_display() self.voucher_codes = get_voucher_codes(cleaned_data) self.gene_codes = get_gene_codes(cleaned_data) self.voucher_info_values = self.get_voucher_info_values() self.voucher_info = self.get_voucher_info() self.sequences_info = self.get_sequence_info() self.warnings = []
def create_dataset(self): if not self.codon_positions: return "" if self.degen_translations is not None and self.codon_positions != ["ALL"]: msg = "Cannot degenerate codons if you have not selected all codon positions" self.errors.append(msg) return "" elif self.degen_translations is not None and self.partition_by_positions != "by gene": msg = "Cannot degenerate codons if they go to different partitions" self.errors.append(msg) return "" self.voucher_codes = get_voucher_codes(self.cleaned_data) self.gene_codes = get_gene_codes(self.cleaned_data) self.create_seq_objs() if self.file_format in ["NEXUS", "GenBankFASTA", "FASTA", "MEGA", "TNT", "PHYLIP"]: try: dataset = Dataset( self.seq_objs, format=self.file_format, partitioning=self.partition_by_positions, codon_positions=self.codon_positions[0], aminoacids=self.aminoacids, degenerate=self.degen_translations, outgroup=self.outgroup, ) except MissingParameterError as e: self.errors.append(e) return "" except ValueError as e: self.errors.append(e) return "" except TranslationErrorMixedGappedSeq as e: self.errors.append(e) return "" except NexusError as e: self.errors.append(e.__str__()) return "" self.warnings += dataset.warnings dataset_handler = DatasetHandler(dataset.dataset_str, self.file_format) self.dataset_file = dataset_handler.dataset_file if self.file_format == "PHYLIP": self.charset_block = dataset.extra_dataset_str return dataset.dataset_str
def create_dataset(self): if not self.codon_positions: return '' error_msg = None if self.degen_translations is not None and self.codon_positions != ['ALL']: error_msg = 'Cannot degenerate codons if you have not selected all codon positions' self.errors.append(error_msg) elif self.degen_translations is not None and self.partition_by_positions != 'by gene': error_msg = 'Cannot degenerate codons if they go to different partitions' self.errors.append(error_msg) if error_msg: return '' self.voucher_codes = get_voucher_codes(self.cleaned_data) self.gene_codes = get_gene_codes(self.cleaned_data) self.create_seq_objs() if self.file_format in ['NEXUS', 'GenBankFASTA', 'FASTA', 'MEGA', 'TNT', 'PHYLIP']: try: dataset = Dataset( self.seq_objs, format=self.file_format, partitioning=self.partition_by_positions, codon_positions=self.codon_positions[0], aminoacids=self.aminoacids, degenerate=self.degen_translations, outgroup=self.outgroup, ) except (MissingParameterError, ValueError, TranslationErrorMixedGappedSeq) as e: self.errors.append(e) dataset = None except NexusError as e: self.errors.append(e.__str__()) dataset = None if not dataset: return "" self.warnings += dataset.warnings dataset_handler = DatasetHandler(dataset.dataset_str, self.file_format) self.dataset_file = dataset_handler.dataset_file if self.file_format == 'PHYLIP': self.charset_block = dataset.extra_dataset_str return dataset.dataset_str
def create_dataset(self): self.voucher_codes = get_voucher_codes(self.cleaned_data) self.gene_codes = get_gene_codes(self.cleaned_data) self.create_seq_objs() return self.from_seq_objs_to_fasta()
def test_get_gene_codes(self): expected = 3 result = get_gene_codes(self.cleaned_data) self.assertEqual(expected, len(result))