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(); }
/// <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; }