@@ -113,14 +113,21 @@ struct Atom <: AbstractAtom
113113 charge:: String
114114 residue:: StructuralElement
115115end
116- Atom (a:: Atom , r:: StructuralElement ) = Atom (a. serial, a. name, a. alt_loc_id, copy (a. coords), a. occupancy, a. temp_factor, a. element, a. charge, r)
116+
117+ function Atom (a:: Atom , r:: StructuralElement )
118+ return Atom (a. serial, a. name, a. alt_loc_id, copy (a. coords), a. occupancy,
119+ a. temp_factor, a. element, a. charge, r)
120+ end
117121
118122" A container to hold different locations of the same atom."
119123struct DisorderedAtom <: AbstractAtom
120124 alt_loc_ids:: Dict{Char, Atom}
121125 default:: Char
122126end
123- DisorderedAtom (da:: DisorderedAtom , r:: StructuralElement ) = DisorderedAtom (Dict (k => Atom (a, r) for (k, a) in da. alt_loc_ids), da. default)
127+
128+ function DisorderedAtom (da:: DisorderedAtom , r:: StructuralElement )
129+ return DisorderedAtom (Dict (k => Atom (a, r) for (k, a) in da. alt_loc_ids), da. default)
130+ end
124131
125132"""
126133A residue (amino acid) or other molecule - either a `Residue` or a
@@ -139,11 +146,13 @@ mutable struct Residue <: AbstractResidue
139146 chain:: StructuralElement
140147 ss_code:: Char
141148end
142- function Residue (r:: Residue , chain:: StructuralElement )
143- atoms = Dict {String, AbstractAtom} ()
144- rnew = Residue (r. name, r. number, r. ins_code, r. het_res, [name for name in r. atom_list], atoms, chain, r. ss_code)
149+
150+ function Residue (r:: Residue , ch:: StructuralElement )
151+ atom_dict = Dict {String, AbstractAtom} ()
152+ rnew = Residue (r. name, r. number, r. ins_code, r. het_res, [name for name in r. atom_list],
153+ atom_dict, ch, r. ss_code)
145154 for (name, atom) in r. atoms
146- atoms [name] = isa (atom, Atom) ? Atom (atom, rnew) : DisorderedAtom (atom, rnew)
155+ atom_dict [name] = isa (atom, Atom) ? Atom (atom, rnew) : DisorderedAtom (atom, rnew)
147156 end
148157 return rnew
149158end
@@ -156,7 +165,10 @@ struct DisorderedResidue <: AbstractResidue
156165 names:: Dict{String, Residue}
157166 default:: String
158167end
159- DisorderedResidue (dr:: DisorderedResidue , chain:: StructuralElement ) = DisorderedResidue (Dict (k => Residue (r, chain) for (k, r) in dr. names), dr. default)
168+
169+ function DisorderedResidue (dr:: DisorderedResidue , ch:: StructuralElement )
170+ return DisorderedResidue (Dict (k => Residue (r, ch) for (k, r) in dr. names), dr. default)
171+ end
160172
161173" A chain (molecule) from a macromolecular structure."
162174mutable struct Chain <: StructuralElement
@@ -165,11 +177,12 @@ mutable struct Chain <: StructuralElement
165177 residues:: Dict{String, AbstractResidue}
166178 model:: StructuralElement
167179end
168- function Chain (c:: Chain , model:: StructuralElement )
169- residues = Dict {String, AbstractResidue} ()
170- cnew = Chain (c. id, [id for id in c. res_list], residues, model)
180+
181+ function Chain (c:: Chain , mo:: StructuralElement )
182+ res_dict = Dict {String, AbstractResidue} ()
183+ cnew = Chain (c. id, [id for id in c. res_list], res_dict, mo)
171184 for (id, res) in c. residues
172- residues [id] = isa (res, Residue) ? Residue (res, cnew) : DisorderedResidue (res, cnew)
185+ res_dict [id] = isa (res, Residue) ? Residue (res, cnew) : DisorderedResidue (res, cnew)
173186 end
174187 return cnew
175188end
@@ -180,11 +193,12 @@ struct Model <: StructuralElement
180193 chains:: Dict{String, Chain}
181194 structure:: StructuralElement
182195end
183- function Model (m:: Model , structure:: StructuralElement )
184- chains = Dict {String, Chain} ()
185- mnew = Model (m. number, chains, structure)
196+
197+ function Model (m:: Model , struc:: StructuralElement )
198+ chain_dict = Dict {String, Chain} ()
199+ mnew = Model (m. number, chain_dict, struc)
186200 for (id, ch) in m. chains
187- chains [id] = Chain (ch, mnew)
201+ chain_dict [id] = Chain (ch, mnew)
188202 end
189203 return mnew
190204end
@@ -197,11 +211,12 @@ struct MolecularStructure <: StructuralElement
197211 name:: String
198212 models:: Dict{Int, Model}
199213end
214+
200215function MolecularStructure (s:: MolecularStructure )
201- models = Dict {Int, Model} ()
202- snew = MolecularStructure (s. name, models )
216+ model_dict = Dict {Int, Model} ()
217+ snew = MolecularStructure (s. name, model_dict )
203218 for (number, mo) in s. models
204- models [number] = Model (mo, snew)
219+ model_dict [number] = Model (mo, snew)
205220 end
206221 return snew
207222end
373388Base. firstindex (struc:: MolecularStructure ) = first (modelnumbers (struc))
374389Base. lastindex (struc:: MolecularStructure ) = last (modelnumbers (struc))
375390
376- # recursive copy methods. If we copy a subelement (anything below MolecularStructure), it shares the parent element
391+ # Recursive copy methods
392+ # If we copy a sub-element (anything below MolecularStructure), it shares the parent element
377393Base. copy (a:: Atom ) = Atom (a, a. residue)
378394Base. copy (da:: DisorderedAtom ) = DisorderedAtom (da, only (unique (a -> a. residue, values (da. alt_loc_ids))). residue)
379395Base. copy (r:: Residue ) = Residue (r, r. chain)
0 commit comments