pygfa.graph_element.parser package¶
Submodules¶
pygfa.graph_element.parser.containment module¶
-
class
pygfa.graph_element.parser.containment.
Containment
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
PREDEFINED_OPTFIELDS
= {'ID': 'Z', 'RC': 'i', 'NM': 'i'}¶
-
REQUIRED_FIELDS
= {'overlap': 'cig', 'from': 'lbl', 'from_orn': 'orn', 'to': 'lbl', 'to_orn': 'orn', 'pos': 'pos'}¶
-
pygfa.graph_element.parser.edge module¶
-
class
pygfa.graph_element.parser.edge.
Edge
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
REQUIRED_FIELDS
= {'eid': 'oid', 'beg2': 'pos2', 'sid2': 'ref', 'end2': 'pos2', 'sid1': 'ref', 'beg1': 'pos2', 'end1': 'pos2', 'alignment': 'aln'}¶
-
pygfa.graph_element.parser.field_validator module¶
Field validation module to check each field string against GFA1 and GFA2 specification.
-
exception
pygfa.graph_element.parser.field_validator.
FormatError
[source]¶ Bases:
Exception
Exception raised when a wrong type of object is given to the validator.
-
exception
pygfa.graph_element.parser.field_validator.
InvalidFieldError
[source]¶ Bases:
Exception
Exception raised when an invalid field is provided.
-
exception
pygfa.graph_element.parser.field_validator.
UnknownDataTypeError
[source]¶ Bases:
Exception
Exception raised when the datatype provided is not in the DATASTRING_VALIDATION_REGEXP dictionary.
-
pygfa.graph_element.parser.field_validator.
is_gfa1_cigar
(string)[source]¶ Check if the given string is a valid CIGAR string as defined in the GFA1 specification.
-
pygfa.graph_element.parser.field_validator.
is_gfa2_cigar
(string)[source]¶ Check if the given string is a valid CIGAR string as defined in the GFA2 specification.
-
pygfa.graph_element.parser.field_validator.
is_valid
(string, datatype)[source]¶ Check if the string respects the datatype.
Parameters: datatype – The type of data corresponding to the string.
Returns: True if the string respect the type defined by the datatype.
Raises: - UnknownDataTypeError – If the datatype is not presents in DATASTRING_VALIDATION_REGEXP.
- UnknownFormatError – If string is not python string.
TODO: Fix exception reference in the documentation.
pygfa.graph_element.parser.fragment module¶
-
class
pygfa.graph_element.parser.fragment.
Fragment
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
REQUIRED_FIELDS
= {'fbeg': 'pos2', 'fend': 'pos2', 'sid': 'id', 'sbeg': 'pos2', 'external': 'ref', 'send': 'pos2', 'alignment': 'aln'}¶
-
pygfa.graph_element.parser.gap module¶
-
class
pygfa.graph_element.parser.gap.
Gap
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
REQUIRED_FIELDS
= {'gid': 'oid', 'variance': 'oint', 'distance': 'int', 'sid2': 'ref', 'sid1': 'ref'}¶
-
pygfa.graph_element.parser.group module¶
-
class
pygfa.graph_element.parser.group.
OGroup
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
REQUIRED_FIELDS
= {'references': 'rfs', 'oid': 'oid'}¶
-
-
class
pygfa.graph_element.parser.group.
UGroup
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
REQUIRED_FIELDS
= {'ids': 'ids', 'uid': 'oid'}¶
-
pygfa.graph_element.parser.header module¶
-
class
pygfa.graph_element.parser.header.
Header
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
PREDEFINED_OPTFIELDS
= {'VN': 'Z', 'TS': 'i'}¶
-
pygfa.graph_element.parser.line module¶
-
class
pygfa.graph_element.parser.line.
Field
(name, value)[source]¶ Bases:
object
This class represent any required field.
The type of field is bound to the field name.
-
name
¶
-
value
¶
-
-
exception
pygfa.graph_element.parser.line.
InvalidLineError
[source]¶ Bases:
Exception
Exception raised when making a Line object from a string. The number of fields gained by splittin the string must be equal to or great than the number of required field ecluding the optional first field indicating the type of the line.
-
class
pygfa.graph_element.parser.line.
Line
(line_type=None)[source]¶ Bases:
object
A generic Line, it’s unlikely that it will be directly instantiated (but could be done so). Its subclasses should be used instead.
It’s possible to instatiate a Line to save a custom line in a gfa file.
-
PREDEFINED_OPTFIELDS
= {}¶
-
REQUIRED_FIELDS
= {}¶
-
add_field
(field)[source]¶ Add a field to the line.
It’s possible to add a Field if an only if its name is in the REQUIRED_FIELDS dictionary. Otherwise the field will be considered as an optional field and an InvalidFieldError will be raised.
Parameters: field – The field to add to the line Raises: InvalidFieldError – If a ‘name’ and a ‘value’ attributes are not found or the field has already been added. Note: If you want to add a Field for a custom Line object be sure to add its name to the REQUIRED_FIELDS dictionary for that particular Line subclass.
-
fields
¶
-
classmethod
is_valid
(line_)[source]¶ Check if the line is valid.
Defining the method here allows to have automatically validated all the line of the specifications.
-
remove_field
(field)[source]¶ If the field is contained in the line it gets removed. Otherwise it does nothing, without raising any exception.
-
type
¶
-
-
class
pygfa.graph_element.parser.line.
OptField
(name, value, field_type)[source]¶ Bases:
pygfa.graph_element.parser.line.Field
An Optional field of the form TAG:TYPE:VALUE, where: TAG match [A-Za-z0-9][A-Za-z0-9] TYPE match [AiZfJHB]
-
type
¶
-
pygfa.graph_element.parser.link module¶
-
class
pygfa.graph_element.parser.link.
Link
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
PREDEFINED_OPTFIELDS
= {'MQ': 'i', 'FC': 'i', 'RC': 'i', 'ID': 'Z', 'NM': 'i', 'KC': 'i'}¶
-
REQUIRED_FIELDS
= {'overlap': 'cig', 'from': 'lbl', 'from_orn': 'orn', 'to': 'lbl', 'to_orn': 'orn'}¶
-
pygfa.graph_element.parser.path module¶
-
class
pygfa.graph_element.parser.path.
Path
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
-
PREDEFINED_OPTFIELDS
= {}¶
-
REQUIRED_FIELDS
= {'overlaps': 'cgs', 'path_name': 'lbl', 'seqs_names': 'lbs'}¶
-
pygfa.graph_element.parser.segment module¶
-
class
pygfa.graph_element.parser.segment.
SegmentV1
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
A GFA1 Segment line.
-
PREDEFINED_OPTFIELDS
= {'LN': 'i', 'FC': 'i', 'RC': 'i', 'UR': 'Z', 'SH': 'H', 'KC': 'i'}¶
-
REQUIRED_FIELDS
= {'sequence': 'seq', 'name': 'lbl'}¶
-
-
class
pygfa.graph_element.parser.segment.
SegmentV2
[source]¶ Bases:
pygfa.graph_element.parser.line.Line
A GFA2 Segment line.
-
REQUIRED_FIELDS
= {'slen': 'int', 'sid': 'id', 'sequence': 'seq2'}¶
-