public void loadPDB(string id) { UnitySocket.Send(CommandID.GETPDB); UnitySocket.Send(0); UnitySocket.Send(id); int num0 = UnitySocket.ReceiveInt(); int num1 = UnitySocket.ReceiveInt(); //print(num); Debug.Log(num0 + "|" + num1); for (int k = 0; k < num0 + num1; k++) { UnitySocket.Send(CommandID.GETPDB); UnitySocket.Send(k + 1); if (k < num0) { string sonAtoms = UnitySocket.ReceiveString(60000); Atoms += sonAtoms.Trim(); // Debug.Log("sonAtoms is: "+sonAtoms); } else { string sonClubs = UnitySocket.ReceiveString(68000); Clubs += sonClubs.Trim(); } } string [] sArray = Atoms.Split('$'); Debug.Log("length:" + sArray.Length); for (int i = 0; i < sArray.Length - 1; i++) { if (sArray[i] == "") { continue; } string [] ssArray = sArray[i].Split('#'); // Debug.Log(i+"|"+sArray[i]+"////"); float[] vect = new float[3]; float.TryParse(ssArray[0], out vect[0]); float.TryParse(ssArray[1], out vect[1]); float.TryParse(ssArray[2], out vect[2]); // for(int kk=0;kk<vect.Length;kk++) // { // Debug.Log(i+"|"+vect[kk]+"////"); // } typelist.Add(AtomModel.GetModel(ssArray[3])); alist.Add(vect); } Debug.Log(Clubs); Vector3 minPoint = Vector3.zero; Vector3 maxPoint = Vector3.zero; MoleculeModel.atomsLocationlist = alist; MoleculeModel.atomsTypelist = typelist; //MoleculeModel.bondList=ControlMolecule.CreateBondsList(alist,typelist); //Debug.Log("======================= Bond List" + MoleculeModel.bondList.ToString()); MoleculeModel.bondEPList = ControlMolecule.CreateBondsEPList(alist, typelist); MoleculeModel.bondEPSugarList = ControlMolecule.CreateBondsEPList(MoleculeModel.atomsSugarLocationlist, MoleculeModel.atomsSugarTypelist); // float [] a0=alist[0] as float[]; // MoleculeModel.cameraLocation.x=MoleculeModel.target.x=a0[0]; // MoleculeModel.cameraLocation.y=MoleculeModel.target.y=a0[1]; // MoleculeModel.target.z=a0[2]; // MoleculeModel.cameraLocation.z=a0[2]-150; // for (int i = 0; i < alist.Count; i++) { float[] position = alist[i] as float[]; minPoint = Vector3.Min(minPoint, new Vector3(position[0], position[1], position[2])); maxPoint = Vector3.Max(maxPoint, new Vector3(position[0], position[1], position[2])); } Vector3 centerPoint = minPoint + ((maxPoint - minPoint) / 2); //MoleculeModel.target = centerPoint; MoleculeModel.Offset = -centerPoint; for (int i = 0; i < alist.Count; i++) { float[] position = alist[i] as float[]; float[] vect = new float[3]; vect[0] = position[0] + MoleculeModel.Offset.x; vect[1] = position[1] + MoleculeModel.Offset.y; vect[2] = position[2] + MoleculeModel.Offset.z; alist[i] = vect; } // Debug.Log("MoleculeModel.target "+MoleculeModel.target); MoleculeModel.cameraLocation.x = MoleculeModel.target.x; MoleculeModel.cameraLocation.y = MoleculeModel.target.y; // MoleculeModel.cameraLocation.z=MoleculeModel.target.z-((maxPoint - minPoint) ).z; MoleculeModel.cameraLocation.z = MoleculeModel.target.z - ((maxPoint - minPoint)).z; //MoleculeModel.bondList=ControlMolecule.CreateBondsList(alist,typelist); MoleculeModel.bondEPList = ControlMolecule.CreateBondsEPList(alist, typelist); MoleculeModel.bondEPSugarList = ControlMolecule.CreateBondsEPList(MoleculeModel.atomsSugarLocationlist, MoleculeModel.atomsSugarTypelist); MoleculeModel.atomsnumber = alist.Count; MoleculeModel.bondsnumber = MoleculeModel.bondEPList.Count; string [] sClubArray = Clubs.Split('$'); for (int i = 0; i < sClubArray.Length - 1; i++) { string [] ssClubArray = sClubArray[i].Split('#'); float[] vect = new float[3]; vect[0] = float.Parse(ssClubArray[0]); vect[1] = float.Parse(ssClubArray[1]); vect[2] = float.Parse(ssClubArray[2]); clubLocationalist.Add(vect); float[] vectRotation = new float[3]; vectRotation[0] = float.Parse(ssClubArray[3]); vectRotation[1] = float.Parse(ssClubArray[4]); vectRotation[2] = 0f; clubRotationList.Add(vectRotation); } Debug.Log(clubRotationList.Count); }
/* * private string GetClosest(Vector3 pos) { * float minDist = float.MaxValue; * float dist; * string type = ""; * for(int i=0; i<locations.Count; i++) { * dist = Vector3.SqrMagnitude(pos - locations[i]); * if (dist < minDist) { * minDist = dist; * type = types[i]; * } * } * return type; * } * * private void ColorVerticesWithLists(Mesh mesh) { * int nbVertices = mesh.vertices.Length; * Vector3[] vertices = mesh.vertices; * Color32[] meshColors = new Color32[nbVertices]; * string type; * * for(int i=0; i<nbVertices; i++) { * type = GetClosest(vertices[i]); * meshColors[i] = AtomModel.GetAtomColor(type); * } * mesh.colors32 = meshColors; * } */ private void ColorVertices(Mesh mesh) { int nbVertices = mesh.vertices.Length; float valtype; List <float> BFactorList = MoleculeModel.BFactorList; Vector3[] vertices = mesh.vertices; Color32[] meshColors = new Color32[nbVertices]; if (slowColoring) { List <float[]> atomLocs = MoleculeModel.atomsLocationlist; atomLocations = new List <Vector3>(); for (int i = 0; i < atomLocs.Count; i++) { atomLocations.Add(new Vector3(atomLocs[i][0], atomLocs[i][1], atomLocs[i][2])); } atomColors = MoleculeModel.atomsColorList; } string type; for (int i = 0; i < nbVertices; i++) { //if(UI.UIData.atomtype == UI.UIData.AtomType.particleball){ type = atomTree.GetClosestAtomType(vertices[i]); if (UI.UIData.surfColChain) { Ribbons.InitCol(); meshColors[i] = Ribbons.GetColorChain(type); } else if (UI.UIData.surfColHydroKD) { HydrophobicScales.InitKyteDoo(); meshColors[i] = HydrophobicScales.GetColorHydro(type); } else if (UI.UIData.surfColHydroEng) { HydrophobicScales.InitEngleman(); meshColors[i] = HydrophobicScales.GetColorHydro(type); } else if (UI.UIData.surfColHydroEis) { HydrophobicScales.InitEisenberg(); meshColors[i] = HydrophobicScales.GetColorHydro(type); } else if (UI.UIData.surfColPChim) { HydrophobicScales.InitPhysChim(); meshColors[i] = HydrophobicScales.GetColorHydro(type); } else if (UI.UIData.surfColHydroWO) { HydrophobicScales.InitWhiteOct(); meshColors[i] = HydrophobicScales.GetColorHydro(type); } else if (UI.UIData.surfColBF) { valtype = float.Parse(type); if (valmax == 0) { valmin = BFactorRep.GetMin(BFactorList); valmax = BFactorRep.GetMax(BFactorList); } valtype = (valtype - valmin) / (valmax - valmin); bftype = BFactorRep.GetBFStyle(valtype); meshColors[i] = AtomModel.GetModel(bftype).baseColor; } else { meshColors[i] = MoleculeModel.GetAtomColor(type); } //This part of the code wasn't working //Anyway i dunno why we want to use another way to color surfaces when not in particles mode //} /*else * if(slowColoring){ * meshColors[i] = GetClosestAtomColor(vertices[i]); * }else{ * type = atomTree.GetClosestAtomType(vertices[i]); * meshColors[i] = MoleculeModel.GetAtomColor(type); * //meshColors[i] = atomTree.GetClosestAtomColor(vertices[i]); * }*/ } mesh.colors32 = meshColors; }
public static void CreateBFRep() { List <float[]> alist = MoleculeModel.atomsLocationlist; List <float[]> calist = new List <float[]>(MoleculeModel.backupCatomsLocationlist); List <string> caChainlist = new List <string>(MoleculeModel.backupCaSplineChainList); List <string> atomsNameList = MoleculeModel.atomsNamelist; List <AtomModel> typelist = MoleculeModel.atomsTypelist; //C.R List <float> Bfactorlist = MoleculeModel.BFactorList; List <int> residlist = MoleculeModel.residueIds; List <float> BfactCAlist = new List <float> (); //List<string> resnamelist = MoleculeModel.atomsResnamelist; // Trace interpolation from C-alpha positions // Only if there are more than 2 C-alpha if (calist.Count > 2) { // Compute bfactor mean by residue int comp = 0; //counter number of residues float b = 0; float bfac = residlist[0]; int j = 0; //counter CA for (int i = 1; i < residlist.Count; i++) { if (i + 1 == residlist.Count) { bfac = b / comp; BfactCAlist.Add(bfac); } if ((atomsNameList[i - 1] == atomsNameList[i]) && (residlist[i - 1] == residlist[i])) { if (atomsNameList[i] == "CA") { calist.RemoveAt(j); caChainlist.RemoveAt(j); //Debug.Log ("Remove"); } } if (residlist[i - 1] == residlist[i]) { b += Bfactorlist[i]; comp++; } else { bfac = b / comp; BfactCAlist.Add(bfac); j++; b = Bfactorlist[i]; comp = 1; } } // Compute bfactor min if (UIData.isRescale) { minValue = float.Parse(minval); } else { minValue = GetMin(BfactCAlist); } for (int i = 0; i < BfactCAlist.Count; i++) { BfactCAlist[i] = BfactCAlist[i] - minValue; } // End of bfactor min // Compute Bfactor max if (UIData.isRescale) { maxValue = (float.Parse(maxval) - float.Parse(minval)); } else { maxValue = GetMax(BfactCAlist); } //bfactor value between 0 and 1 for (int i = 0; i < BfactCAlist.Count; i++) { BfactCAlist[i] = BfactCAlist[i] / maxValue; } GenInterpolationArray_BF geninterpolationarray = new GenInterpolationArray_BF(); geninterpolationarray.InputKeyNodes = calist; geninterpolationarray.InputTypeArray = caChainlist; geninterpolationarray.InputBfactArray = BfactCAlist; geninterpolationarray.CalculateSplineArray(); calist = null; caChainlist = null; Bfactorlist = null; calist = geninterpolationarray.OutputKeyNodes; caChainlist = geninterpolationarray.OutputTypeArray; Bfactorlist = geninterpolationarray.OutputBfactArray; } MoleculeModel.CaSplineList = calist; MoleculeModel.CaSplineTypeList = new List <AtomModel>(); string typebf; for (int k = 0; k < calist.Count; k++) { typebf = GetBFStyle(Bfactorlist[k]); MoleculeModel.CaSplineTypeList.Add(AtomModel.GetModel(typebf)); } MoleculeModel.CaSplineChainList = caChainlist; if (UIData.ffType == UIData.FFType.HiRERNA) { MoleculeModel.bondEPList = ControlMolecule.CreateBondsList_HiRERNA(atomsNameList); } else { //MoleculeModel.bondList=ControlMolecule.CreateBondsList(alist,typelist); MoleculeModel.bondEPList = ControlMolecule.CreateBondsEPList(alist, typelist); MoleculeModel.bondCAList = ControlMolecule.CreateBondsCAList(caChainlist); } MoleculeModel.atomsnumber = alist.Count; MoleculeModel.bondsnumber = MoleculeModel.bondEPList.Count; MoleculeModel.CaSplineChainList = caChainlist; minval = minValue.ToString(); maxval = (maxValue + minValue).ToString(); }
//TODO: avoid reading the file 3 times public void ReadXGMML(String xml_content) { List <float[]> alist = new List <float[]>(); List <float[]> CSRadiusList = new List <float[]>(); List <AtomModel> typelist = new List <AtomModel>(); // List<string> chainlist = new List<string>(); List <int[]> edgelist = new List <int[]>(); List <string> resnamelist = new List <string>(); List <string[]> CSSGDList = new List <string[]>(); List <string[]> CSColorList = new List <string[]>(); List <string[]> CSLabelList = new List <string[]>(); List <int[]> CSidList = new List <int[]>(); XmlReader reader = new XmlTextReader(new StringReader(xml_content)); while (reader.Read()) { if (reader.ReadToFollowing("node")) { float[] vect = new float[3]; // Vector3 v=new Vector3(); float [] intarrayw = new float[1]; while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "label") { string [] intarray = new string[1]; intarray[0] = reader.Value; CSLabelList.Add(intarray); } else if (reader.Name == "id") { int [] intarray = new int[1]; intarray[0] = int.Parse(reader.Value); CSidList.Add(intarray); } // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); } // if(reader.NodeType==XmlNodeType.Element) // { // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); // string [] intarray= new string[1]; // intarray[0]=reader.Value; // if(reader.LocalName=="SGD symbol")CSSGDList.Add(intarray); // // } reader.ReadToFollowing("graphics"); while (reader.MoveToNextAttribute()) // Read the attributes. { if (reader.Name == "type") { } else if (reader.Name == "h") { } else if (reader.Name == "w") { // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); intarrayw[0] = float.Parse(reader.Value) / 60; CSRadiusList.Add(intarrayw); } else if (reader.Name == "x") { // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); //Take the opposite of y beceause Unity is left-handed vect[0] = float.Parse(reader.Value) / 60; } else if (reader.Name == "y") { // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); //Take the opposite of y beceause screen is directed in -y vect[1] = -float.Parse(reader.Value) / 60; } else if (reader.Name == "fill") { string [] intarray = new string[1]; intarray[0] = reader.Value; CSColorList.Add(intarray); } else if (reader.Name == "width") { } else if (reader.Name == "outline") { } // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); } //Take the opposite for z to make the node pop out toward the user vect[2] = -GUIMoleculeController.depthfactor * intarrayw[0]; alist.Add(vect); typelist.Add(AtomModel.GetModel("S")); // modellist.Add(model); } } reader.Close(); XmlReader reader2 = new XmlTextReader(new StringReader(xml_content)); while (reader2.Read()) { if (reader2.ReadToFollowing("edge")) { int[] vectint = new int[2]; while (reader2.MoveToNextAttribute()) // Read the attributes. { if (reader2.Name == "label") { } else if (reader2.Name == "source") { // Debug.Log(" " + reader2.Name + "='" + reader2.Value + "'"); vectint[0] = int.Parse(reader2.Value); } else if (reader2.Name == "target") { // Debug.Log(" " + reader2.Name + "='" + reader2.Value + "'"); vectint[1] = int.Parse(reader2.Value); } // Debug.Log(" " + reader.Name + "='" + reader.Value + "'"); } // Debug.Log(" vectint[0]:" + vectint[0]+", vectint[1]:" + vectint[1]); edgelist.Add(vectint); } } reader2.Close(); XmlReader reader3 = new XmlTextReader(new StringReader(xml_content)); while (reader3.Read()) { if (reader3.NodeType == XmlNodeType.Element) { while (reader3.MoveToNextAttribute()) // Read the attributes. { if (reader3.Name == "name" && reader3.Value == "SGD symbol") { if (reader3.MoveToNextAttribute()) { // Debug.Log(" " + reader3.Name + "=" + reader3.Value + " "); string [] intarray = new string[1]; intarray[0] = reader3.Value; CSSGDList.Add(intarray); // Debug.Log(" " + reader3.Name + "='" + reader3.Value + "'"); } } } } } reader3.Close(); MoleculeModel.atomsLocationlist = alist; MoleculeModel.atomsTypelist = typelist; MoleculeModel.atomsResnamelist = resnamelist; MoleculeModel.CSidList = CSidList; MoleculeModel.CSLabelList = CSLabelList; MoleculeModel.CSRadiusList = CSRadiusList; MoleculeModel.CSColorList = CSColorList; MoleculeModel.CSSGDList = CSSGDList; //float [] a0=alist[0] as float[]; Vector3 minPoint = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); Vector3 maxPoint = new Vector3(float.MinValue, float.MinValue, float.MinValue); for (int i = 0; i < alist.Count; i++) { float[] position = alist[i] as float[]; // Debug.Log(position[0]+","+position[1]+","+position[2]); minPoint = Vector3.Min(minPoint, new Vector3(position[0], position[1], position[2])); maxPoint = Vector3.Max(maxPoint, new Vector3(position[0], position[1], position[2])); } Vector3 centerPoint = minPoint + ((maxPoint - minPoint) / 2); //MoleculeModel.target = centerPoint; Camera.main.transform.position = new Vector3(0, 0, 0); MoleculeModel.Offset = -centerPoint; MoleculeModel.MinValue = minPoint; MoleculeModel.MaxValue = maxPoint; Debug.Log("centerPoint=" + centerPoint); for (int i = 0; i < alist.Count; i++) { float[] position = alist[i] as float[]; float[] vectarray = new float[3]; vectarray[0] = position[0] + MoleculeModel.Offset.x; vectarray[1] = position[1] + MoleculeModel.Offset.y; vectarray[2] = position[2] + MoleculeModel.Offset.z; alist[i] = vectarray; } // Debug.Log("MoleculeModel.target "+MoleculeModel.target); MoleculeModel.cameraLocation.x = MoleculeModel.target.x; MoleculeModel.cameraLocation.y = MoleculeModel.target.y; // MoleculeModel.cameraLocation.z=MoleculeModel.target.z-((maxPoint - minPoint) ).z; MoleculeModel.cameraLocation.z = -80; // MoleculeModel.cameraLocation.z=MoleculeModel.target.z; // MoleculeModel.bondList=ControlMolecule.CreateBondsList(alist,typelist); // MoleculeModel.bondEPList=ControlMolecule.CreateBondsEPList(alist,typelist); MoleculeModel.bondEPList = ControlMolecule.CreateBondsCSList(edgelist); MoleculeModel.atomsnumber = alist.Count; MoleculeModel.bondsnumber = MoleculeModel.bondEPList.Count; MoleculeModel.networkLoaded = true; // there should be a network loaded, if all went well // return alist; }
// Regex RE = new Regex("\n", RegexOptions.Multiline); // MatchCollection theMatches = RE.Matches(text); // int matchescount=theMatches.Count; public static void ReadPDB(TextReader sr, List <float[]> alist, List <float[]> calist, List <float> BFactorList, List <string> resnamelist, List <string> atomsNameList, List <string> caChainlist, List <AtomModel> typelist, List <string> chainList, List <Color> colorList, List <float[]> sshelixlist, List <float[]> sssheetlist) { string[] dnaBackboneAtoms = new string[] { "C5'" }; List <int> residueIds = new List <int>(); List <int> splits = new List <int>(); List <int> atomsNumberList = new List <int>(); int resNb = 0; int prevRes = int.MinValue; int currentRes = int.MinValue + 1; int nowline = 0; int nbAtoms = 0; int nbTers = 0; string s; int prevresnb = 0; while ((s = sr.ReadLine()) != null) { if (s.StartsWith("ENDMDL")) { break; } if (s.Length > 4) { bool isAtomLine = s.StartsWith("ATOM"); bool isHetAtm = s.StartsWith("HETATM"); bool isHelixLine = s.StartsWith("HELIX"); bool isSheetLine = s.StartsWith("SHEET"); bool isConnectLine = s.StartsWith("CONECT"); if (s.StartsWith("TER")) { splits.Add(resNb); nbTers++; } if (isHelixLine) { string chainh = s.Substring(19, 2).Trim(); string initr = s.Substring(22, 4); string termr = s.Substring(34, 4); string classH = s.Substring(39, 2); string len = s.Substring(72, 5); float[] vect = new float[4]; float initres = float.Parse(initr); float termres = float.Parse(termr); float length = float.Parse(len); float classhelix = 1f; try{ classhelix = float.Parse(classH); }catch { classhelix = float.Parse(s.Substring(38, 2)); } vect[0] = initres; vect[1] = termres; vect[2] = length; vect[3] = classhelix; sshelixlist.Add(vect); MoleculeModel.helixChainList.Add(chainh); } if (isSheetLine) { string chainS = s.Substring(21, 2).Trim(); string initr = s.Substring(23, 4); string termr = s.Substring(34, 4); float[] vect = new float[2]; vect[0] = float.Parse(initr); vect[1] = float.Parse(termr); sssheetlist.Add(vect); MoleculeModel.strandChainList.Add(chainS); } if (UIData.readHetAtom) { isAtomLine = isAtomLine || s.StartsWith("HETATM"); } if (!UIData.readWater) { try{ if ((string)s.Substring(17, 3).Trim() == "HOH") { isAtomLine = false; } }catch { isAtomLine = false; } } if (isAtomLine) { float[] vect = new float[3]; MoleculeModel.atomHetTypeList.Add(s.Split(' ')[0]); string sx = s.Substring(30, 8); string sy = s.Substring(38, 8); string sz = s.Substring(46, 8); string sbfactor = null; bool parseBFactor = false; if (s.Length > 60) { sbfactor = s.Substring(60, 6); parseBFactor = true; } string atomsNumber = s.Substring(6, 5); string typestring = s.Substring(12, 4).Trim(); atomsNameList.Add(typestring); int bout; bool b = int.TryParse(typestring[0].ToString(), out bout); string type; if (b) { type = typestring[1].ToString(); } else { type = typestring[0].ToString(); } string resname = s.Substring(17, 3).Trim(); int resid = int.Parse(s.Substring(22, 4)); residueIds.Add(resid); currentRes = resid; atomsNumberList.Add(int.Parse(atomsNumber)); //Unity has a left-handed coordinates system while PDBs are right-handed //So we have to reverse the X coordinates float x = -float.Parse(sx); float y = float.Parse(sy); float z = float.Parse(sz); float bfactor = 0.0f; if (parseBFactor == true) { bfactor = float.Parse(sbfactor); } vect[0] = x; vect[1] = y; vect[2] = z; //CA case if (typestring[0].ToString() == "C" && typestring.Length > 1) { if (typestring[1].ToString() == "A") { string chaintype = s.Substring(21, 1); calist.Add(vect); caChainlist.Add(chaintype); } } //?? if (dnaBackboneAtoms.Contains(typestring)) { string chaintype = s.Substring(21, 1); calist.Add(vect); caChainlist.Add(chaintype); } if (s.Substring(21, 1) != " ") { string chain = s.Substring(21, 1); chainList.Add(chain); } if (parseBFactor == true) { BFactorList.Add(bfactor); } alist.Add(vect); AtomModel aModel; if (UIData.ffType == UIData.FFType.atomic) { aModel = AtomModel.GetModel(type); } else { aModel = AtomModel.GetModel(typestring); } if (aModel == null) { aModel = AtomModel.GetModel("X"); } typelist.Add(aModel); if (MoleculeModel.sugarResname.Contains(resname)) { MoleculeModel.atomsSugarTypelist.Add(aModel); } if (UIData.ffType == UIData.FFType.atomic) { colorList.Add(MoleculeModel.GetAtomColor(type)); } else { colorList.Add(aModel.baseColor); } resnamelist.Add(resname); if (MoleculeModel.residues.ContainsKey(resid) == false) { MoleculeModel.residues.Add(resid, new ArrayList()); //add the chain name for each residu MoleculeModel.resChainList.Add(s.Substring(21, 1)); //If we have a sugar, we add theses informations in some special list if (MoleculeModel.sugarResname.Contains(resname)) { MoleculeModel.resSugarChainList.Add(s.Substring(21, 1)); } } int curresnb = int.Parse(s.Substring(22, 4)); if (prevresnb == 0 && curresnb != 0) { MoleculeModel.firstresnb = curresnb; } if (curresnb != prevresnb) { MoleculeModel.resChainList2.Add(s.Substring(21, 1)); prevresnb = curresnb; } MoleculeModel.residues[resid].Add(nbAtoms); if (prevRes != currentRes) { resNb++; } prevRes = currentRes; nbAtoms++; //If we have a sugar, we add theses informations in some special list if (MoleculeModel.sugarResname.Contains(resname)) { MoleculeModel.atomsSugarLocationlist.Add(vect); MoleculeModel.atomsSugarResnamelist.Add(resname); MoleculeModel.atomsSugarNamelist.Add(typestring); } } if (isConnectLine) { if (UIData.connectivity_PDB) { string[] splitedStringTemp = s.Split(' '); //0 is Connect, 1 is the atom, 2,3..... is the bounded atoms List <string> splitedString = new List <string>(); for (int j = 0; j < splitedStringTemp.Length; j++) { if (splitedStringTemp[j] != "") { splitedString.Add(splitedStringTemp[j]); } } for (int j = 2; j < splitedString.Count; j++) { MoleculeModel.BondListFromPDB.Add(new int[2] { int.Parse(splitedString[1]) - 1, int.Parse(splitedString[j]) - 1 }); } } } nowline++; } } isDone = true; Ribbons.mustSplitDictList = (nbTers > 1); for (int i = 0; i < typelist.Count; i++) { MoleculeModel.atomsLocalScaleList.Add(100.0f); } foreach (string name in atomsNameList) { if (!MoleculeModel.existingName.Contains(name)) { MoleculeModel.existingName.Add(name); } } // existingRes is created in DisplayMolecule.CheckResidues after looking for protonated HIS foreach (string chain in chainList) { if (!MoleculeModel.existingChain.Contains(chain)) { MoleculeModel.existingChain.Add(chain); } } MoleculeModel.existingName.Sort(); MoleculeModel.existingChain.Sort(); sr.Close(); Debug.Log("typelist:" + typelist.Count); Debug.Log("resnameList:" + resnamelist.Count); Debug.Log("caChainlist:" + caChainlist.Count); Debug.Log("chainlist:" + chainList.Count); Debug.Log("colorList:" + colorList.Count); Debug.Log("atomsLocalScaleList:" + MoleculeModel.atomsLocalScaleList.Count); Debug.Log("BfactorList: " + BFactorList.Count); if (resnamelist.Count == typelist.Count) { UIData.hasResidues = true; } if (chainList.Count == typelist.Count) { UIData.hasChains = true; } MoleculeModel.atomsLocationlist = alist; MoleculeModel.CatomsLocationlist = calist; MoleculeModel.CaSplineChainList = caChainlist; MoleculeModel.atomsTypelist = typelist; MoleculeModel.atomsNamelist = atomsNameList; MoleculeModel.atomsNumberList = atomsNumberList; MoleculeModel.BFactorList = BFactorList; MoleculeModel.atomsResnamelist = resnamelist; MoleculeModel.residueIds = residueIds; MoleculeModel.splits = splits; MoleculeModel.atomsChainList = chainList; MoleculeModel.atomsColorList = colorList; MoleculeModel.ssHelixList = sshelixlist; MoleculeModel.ssStrandList = sssheetlist; //MoleculeModel.residueDictionaries = residueDictList; //Here we will fill the sortedIndex residue by the Chain ID MoleculeModel.sortedResIndexByList = sortResIndex(MoleculeModel.resChainList); MoleculeModel.sortedResIndexByListSugar = sortResIndex(MoleculeModel.resSugarChainList); }
/// <summary> /// Trace interpolation points from C-alpha positions. /// Recreate interpolation points for carbon alpha splines. /// </summary> public static void ReSpline() { List <float[]> alist = MoleculeModel.atomsLocationlist; List <AtomModel> typelist = MoleculeModel.atomsTypelist; List <string> atomsNameList = MoleculeModel.atomsNamelist; List <float[]> calist = new List <float[]>(MoleculeModel.CatomsLocationlist); List <string> caChainlist = new List <string>(MoleculeModel.backupCaSplineChainList); List <int> residlist = MoleculeModel.residueIds; //List<string> resnamelist = MoleculeModel.atomsResnamelist; // Trace interpolation from C-alpha positions // Only if there are more than 2 C-alpha if (calist.Count > 2) { int j = 0; for (int i = 1; i < residlist.Count; i++) { if (atomsNameList[i] == "CA") { if ((atomsNameList[i - 1] == atomsNameList[i]) && (residlist[i - 1] == residlist[i])) { calist.RemoveAt(j); caChainlist.RemoveAt(j); Debug.Log("Remove"); } j++; } } GenInterpolationArray geninterpolationarray = new GenInterpolationArray(); geninterpolationarray.InputKeyNodes = calist; geninterpolationarray.InputTypeArray = caChainlist; geninterpolationarray.CalculateSplineArray(); calist = null; caChainlist = null; calist = geninterpolationarray.OutputKeyNodes; caChainlist = geninterpolationarray.OutputTypeArray; } MoleculeModel.CaSplineList = calist; MoleculeModel.CaSplineTypeList = new List <AtomModel>(); for (int k = 0; k < calist.Count; k++) { MoleculeModel.CaSplineTypeList.Add(AtomModel.GetModel("chain" + caChainlist[k])); } MoleculeModel.CaSplineChainList = caChainlist; if (UIData.ffType == UIData.FFType.HiRERNA) { MoleculeModel.bondEPList = ControlMolecule.CreateBondsList_HiRERNA(atomsNameList); } else { //MoleculeModel.bondList=ControlMolecule.CreateBondsEPList(alist,typelist); MoleculeModel.bondEPList = ControlMolecule.CreateBondsEPList(alist, typelist); MoleculeModel.bondCAList = ControlMolecule.CreateBondsCAList(caChainlist); } MoleculeModel.atomsnumber = alist.Count; MoleculeModel.bondsnumber = MoleculeModel.bondEPList.Count; MoleculeModel.CaSplineChainList = caChainlist; }