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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
"""Classes for linking back to a sequence or structure database."""
import warnings
import ihm.reference
from ihm.reference import Alignment, SeqDif # noqa: F401
class TargetReference(ihm.reference.Sequence):
"""Point to the sequence of a target :class:`modelcif.Entity` in a sequence
database. Typically a subclass such as :class:`UniProt` is used,
although to use a custom database, make a new subclass and provide
a docstring to describe the database, e.g.::
class CustomRef(TargetReference):
"my custom database"
Compare with :class:`modelcif.ReferenceDatabase`, which describes
multiple sequences used in template searches or alignment
construction; this class relates to just the modeled sequence itself.
See also :attr:`alignments` to describe the correspondence between
the database and entity sequences.
:param str code: The name of the sequence in the database.
:param str accession: The database accession.
:param int align_begin: Beginning index of the sequence in the database.
Deprecated; use :attr:`alignments` instead.
:param int align_end: Ending index of the sequence in the database.
Deprecated; use :attr:`alignments` instead.
:param str isoform: Sequence isoform, if applicable.
:param str ncbi_taxonomy_id: Taxonomy identifier provided by NCBI.
:param str organism_scientific: Scientific name of the organism.
:param sequence_version_date: Versioning date, e.g. for UniProtKB
sequences this is usually the date of last
modification from the DT line of an entry.
:type sequence_version_date: :class:`datetime.date` or
:class:`datetime.datetime`
:param str sequence_crc64: The CRC64 sum of the original database
sequence.
:param str sequence: The complete database sequence, as a string of
one-letter codes. If omitted, will default to the canonical
sequence of the associated :class:`~modelcif.Entity`.
:param str details: Longer text describing the sequence.
:param bool is_primary: True iff this is the main input used in the
modeling.
"""
name = 'Other'
def __init__(self, code, accession, align_begin=None, align_end=None,
isoform=None, ncbi_taxonomy_id=None,
organism_scientific=None, sequence_version_date=None,
sequence_crc64=None, sequence=None, details=None,
is_primary=None):
super(TargetReference, self).__init__(
db_name=self.name, db_code=code, accession=accession,
sequence=sequence, details=details)
self.align_begin, self.align_end = align_begin, align_end
self.isoform = isoform
self.ncbi_taxonomy_id = ncbi_taxonomy_id
self.organism_scientific = organism_scientific
self.sequence_version_date = sequence_version_date
self.sequence_crc64 = sequence_crc64
if align_begin or align_end:
warnings.warn(
"align_begin and align_end are deprecated, and will be "
"removed in a future python-modelcif release. Specify the "
"database sequence and provide one or more "
"modelcif.reference.Alignment objects instead.", stacklevel=2)
if sequence is None:
warnings.warn(
"No sequence provided. The canonical sequence of the Entity "
"will be used instead.", stacklevel=2)
#: All alignments between the reference and entity sequences, as
#: :class:`Alignment` objects. If none are provided, a simple 1:1
#: alignment is assumed.
self.alignments = []
self.is_primary = is_primary
code = property(lambda self: self.db_code)
def _get_other_details(self):
if (type(self) is not TargetReference
and self.name == TargetReference.name):
return self.__doc__.split('\n')[0]
other_details = property(
_get_other_details,
doc="More information about a custom reference type. "
"By default it is the first line of the docstring.")
class UniProt(TargetReference):
"""Point to the sequence of an :class:`modelcif.Entity` in UniProt.
These objects are typically passed to the :class:`modelcif.Entity`
constructor for target sequences (for templates, see
:class:`TemplateReference`).
See :class:`TargetReference` for a description of the parameters.
"""
name = 'UNP'
other_details = None
class TemplateReference:
"""Point to the structure of a :class:`modelcif.Template` in a structure
database.
These objects are typically passed to the :class:`modelcif.Template`
constructor for template sequences (for target sequences, see
:class:`TargetReference`).
Typically a subclass such as :class:`PDB` is used,
although to use a custom database, make a new subclass and provide
a docstring to describe the database, e.g.::
class CustomRef(TemplateReference):
"my custom database"
:param str accession: The database accession.
:param db_version_date: Versioning date, e.g. for PDB entries this is
usually the value of
``_pdbx_audit_revision_history.revision_date``.
:type db_version_date: :class:`datetime.date` or
:class:`datetime.datetime`
"""
name = 'Other'
def __init__(self, accession, db_version_date=None):
self.accession = accession
self.db_version_date = db_version_date
def _get_other_details(self):
if (type(self) is not TemplateReference
and self.name == TemplateReference.name):
return self.__doc__.split('\n')[0]
other_details = property(
_get_other_details,
doc="More information about a custom reference type. "
"By default it is the first line of the docstring.")
class PDB(TemplateReference):
"""Point to the structure of a :class:`modelcif.Template` in PDB.
These objects are typically passed to the :class:`modelcif.Template`
constructor.
See :class:`TemplateReference` for a description of the parameters.
"""
name = 'PDB'
other_details = None
class AlphaFoldDB(TemplateReference):
"""Point to the structure of a :class:`modelcif.Template` in AlphaFold DB.
These objects are typically passed to the :class:`modelcif.Template`
constructor.
See :class:`TemplateReference` for a description of the parameters.
"""
name = 'AlphaFoldDB'
other_details = None
class PubChem(TemplateReference):
"""Point to the structure of a :class:`modelcif.Template` in PubChem.
These objects are typically passed to the :class:`modelcif.Template`
constructor.
See :class:`TemplateReference` for a description of the parameters. Use
the PubChem CID as the accession code.
"""
name = 'PubChem'
other_details = None
|