コード例 #1
0
        public static void ParseJsonInstanceSets()
        {
            string json   = File.ReadAllText(Database.Paths.Rotamer.JsonRotamerInstances);
            JArray jArray = JArray.Parse(json);

            RotamerInstanceSet[] sets = new RotamerInstanceSet[jArray.Count];

            for (int definitionIndex = 0; definitionIndex < jArray.Count; definitionIndex++)
            {
                RotamerInstanceSet set = JsonConvert.DeserializeObject <RotamerInstanceSet>((jArray.ElementAt(definitionIndex).ToString()));
                sets[definitionIndex] = set;
            }
            sets_ = sets;
        }
コード例 #2
0
        public static void CacheInstanceCoordinates()
        {
            coordinates_ = new Vector3[AaTable.AaCount][][];
            for (int residueTypeIndex = 0; residueTypeIndex < AaTable.AaCount; residueTypeIndex++)
            {
                IAa residue = new Aa(residueTypeIndex, true, true);
                RotamerInstanceSet rotamerSet = sets_.First(match => match.ResidueNames.Contains(residue.Name)); Debug.Assert(rotamerSet != null, "Residue type " + residue.Name + " was not found in rotamer_dynameomics.json");
                int rotamerCount = rotamerSet.Torsions.GetLength(0);
                coordinates_[residueTypeIndex] = new Vector3[rotamerCount][];
                if (rotamerCount == 0)
                {
                    continue;
                }

                // Record the OXT index. This is shitty [TODO - rethink], but all required atoms (N,CA,C and sidechain) come first in the ResidueQuick atom list,
                // and atoms that may not exist (OXT, H, H1,H2,H3) are last in the list. This allows for caching of coordinates for just the sidechain (as necessary when
                // dealing with rotamers) using a continuous list of indices in the range [0, index(OXT) - 1].
                int oxtIndex = 0;
                while (residue[oxtIndex].Name != "OXT")
                {
                    oxtIndex++;
                }

                // Iterate rotamers belonging to this residue type
                for (int rotamerIndex = 0; rotamerIndex < rotamerSet.Torsions.GetLength(0); rotamerIndex++)
                {
                    // Create a scratch residue to work with, to prevent floating point error buildup
                    IAa tmp = new Aa(residue);

                    // Apply torsions at each chi index
                    for (int chiIndex = 1; chiIndex <= rotamerSet.ChiCount; chiIndex++)
                    {
                        RotamerDefinition rotamerDefinition = definitions_[residueTypeIndex]; Debug.Assert(rotamerDefinition.ResidueName == residue.Name, "JSON for rotamer definitions and residue definitions is out of sync, rotamer definition=" + rotamerDefinition.ResidueName + ", residue definition=" + residue.Name);
                        float             torsion           = rotamerSet.GetTorsionDegrees(rotamerIndex, chiIndex);
                        SetChiAngleDegrees(tmp, chiIndex, torsion);
                        //SetChiAngleDegrees(tmp, torsion, rotamerDefinition.GetBackboneAtomNames(chiIndex), rotamerDefinition.GetDependentAtomNames(chiIndex));
                    }

                    // Cache the final coordinates
                    coordinates_[residueTypeIndex][rotamerIndex] = new Vector3[oxtIndex];
                    for (int atomIndex = 0; atomIndex < oxtIndex; atomIndex++)
                    {
                        coordinates_[residueTypeIndex][rotamerIndex][atomIndex] = tmp[atomIndex].Xyz;
                    }
                }
            }
        }