/
exception.py
142 lines (96 loc) · 3.23 KB
/
exception.py
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
"""
Exceptions (:mod:`skbio.core.exception`)
========================================
.. currentmodule:: skbio.core.exception
This module defines custom exception classes used throughout the core
scikit-bio codebase.
Exceptions
----------
.. autosummary::
:toctree: generated/
FileFormatError
RecordError
FieldError
BiologicalSequenceError
SequenceCollectionError
DissimilarityMatrixError
DistanceMatrixError
DissimilarityMatrixFormatError
MissingIDError
TreeError
NoLengthError
DuplicateNodeError
MissingNodeError
NoParentError
FastqParseError
GeneticCodeError
GeneticCodeInitError
InvalidCodonError
"""
from __future__ import absolute_import, division, print_function
# ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------------------------------------
class FileFormatError(Exception):
"""Exception raised when a file can not be parsed."""
pass
class RecordError(FileFormatError):
"""Exception raised when a record is bad."""
pass
class FieldError(RecordError):
"""Exception raised when a field within a record is bad."""
pass
class BiologicalSequenceError(Exception):
"""General error for biological sequence validation failures."""
pass
class SequenceCollectionError(Exception):
"""General error for sequence collection validation failures."""
pass
class DissimilarityMatrixError(Exception):
"""General error for dissimilarity matrix validation failures."""
pass
class DistanceMatrixError(DissimilarityMatrixError):
"""General error for distance matrix validation failures."""
pass
class MissingIDError(DissimilarityMatrixError):
"""Error for ID lookup that doesn't exist in the dissimilarity matrix."""
def __init__(self, missing_id):
super(MissingIDError, self).__init__()
self.args = ("The ID '%s' is not in the dissimilarity matrix." %
missing_id,)
class DissimilarityMatrixFormatError(DissimilarityMatrixError):
"""Error for reporting issues in dissimilarity matrix file format.
Typically used during parsing.
"""
pass
class TreeError(Exception):
"""General tree error"""
pass
class NoLengthError(TreeError):
"""Missing length when expected"""
pass
class DuplicateNodeError(TreeError):
"""Duplicate nodes with identical names"""
pass
class MissingNodeError(TreeError):
"""Expecting a node"""
pass
class NoParentError(MissingNodeError):
"""Missing a parent"""
pass
class FastqParseError(FileFormatError):
"""Exception raised when a FASTQ formatted file cannot be parsed"""
pass
class GeneticCodeError(Exception):
"""Base class exception used by the GeneticCode class"""
pass
class GeneticCodeInitError(ValueError, GeneticCodeError):
"""Exception raised by the GeneticCode class upon a bad initialization"""
pass
class InvalidCodonError(KeyError, GeneticCodeError):
"""Exception raised by the GeneticCode class if __getitem__ fails"""
pass