コード例 #1
0
        public void LoadPDBResource(string resource_name)
        {
            TextAsset    text_data = Resources.Load(resource_name) as TextAsset;
            StringReader sr        = new StringReader(text_data.text);

            //ReadPDB(sr);
            ControlMolecule.CreateMolecule(sr);
        }
コード例 #2
0
        public void LoadPDBRequest(string file_base_name, bool withData = true)
        {
            StreamReader sr;

//			FileInfo file=new FileInfo(file_base_name+".pdb");
            sr = new StreamReader(file_base_name + ".pdb");

            //ReadPDB(sr);
            ControlMolecule.CreateMolecule(sr);

            if (withData)
            {
                FileInfo fieldlinefile = new FileInfo(file_base_name + ".json");
                FileInfo apffile       = new FileInfo(file_base_name + ".apf");
                if (fieldlinefile.Exists)
                {
                    LoadJsonRequest("file://" + file_base_name + ".json", MoleculeModel.Offset);
                    MoleculeModel.fieldLineFileExists = true;
                }
                else if (apffile.Exists)
                {
                    LoadJsonRequest("file://" + file_base_name + ".apf", MoleculeModel.Offset);
                    MoleculeModel.fieldLineFileExists = true;
                }
                else
                {
                    MoleculeModel.fieldLineFileExists = false;
                    MoleculeModel.FieldLineList       = null;
                }

                FileInfo Surfacefile  = new FileInfo(file_base_name + ".obj");
                FileInfo Surfacefile0 = new FileInfo(file_base_name + "0.obj");

                if (Surfacefile.Exists || Surfacefile0.Exists)
                {
                    LoadOBJRequest(file_base_name);
                    MoleculeModel.surfaceFileExists = true;
                    GUIMoleculeController.modif     = true;
                }
                else
                {
                    MoleculeModel.surfaceFileExists = false;
                }

                FileInfo dxfile = new FileInfo(file_base_name + ".dx");
                MoleculeModel.dxFileExists = false;                  // otherwise a molecule might load dx data from a previous molecule
                if (dxfile.Exists)
                {
                    MoleculeModel.dxFileExists = true;
                    LoadDxRequest(file_base_name + ".dx", MoleculeModel.Offset);
                }
            }
        }
コード例 #3
0
        public IEnumerator LoadPDBWWW(string file_name)
        {
            WWW www = new WWW(file_name);

            progress = 0;
            isDone   = false;
            while (!www.isDone)
            {
//				Debug.Log("*** PDB: "+www.progress);
                progress = www.progress;
                yield return(new WaitForEndOfFrame());
            }
            Debug.Log("read");
            //ReadPDB(new StringReader(www.text));
            ControlMolecule.CreateMolecule(new StringReader(www.text));
            isDone = true;
        }
コード例 #4
0
        public void FetchPDB(string url, string id, string proxyserver = "", int proxyport = 0)
        {
            StreamReader    sr;
            Stream          dataStream = null;
            HttpWebResponse response   = null;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + id + ".pdb");

            // If required by the server, set the credentials.
            request.Credentials = CredentialCache.DefaultCredentials;

            //Set proxy information if needed
            Debug.Log("LoadPDB: " + proxyserver + " " + proxyport);
            if (proxyserver != "")
            {
                request.Proxy = new WebProxy(proxyserver, proxyport);
            }

            // Get the response.
            response = (HttpWebResponse)request.GetResponse();
            // Display the status.
            Debug.Log("LoadPDB Status :: " + response.StatusDescription);

            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            sr = new StreamReader(dataStream);

            ControlMolecule.CreateMolecule(sr);
            //ReadPDB(sr);

            if (dataStream != null && response != null)
            {
                dataStream.Close();
                response.Close();
            }
        }
コード例 #5
0
        public static void LoadSymmetry(float Xorigin, float Yorigin, float Zorigin, float Xdirection, float Ydirection, float Zdirection)
        {
            Debug.Log(MoleculeModel.atomsLocationlist[0][0] + " " + MoleculeModel.atomsLocationlist[0][1] + " " + MoleculeModel.atomsLocationlist[0][2]);
            Debug.Log("REORIENTATION");
            //Vector3 origin = new Vector3 (Xorigin, Yorigin, Zorigin);
            Vector3 direction = new Vector3(Xdirection, Ydirection, Zdirection);

            direction.Normalize();
            //float[] position= MoleculeModel.atomsLocationlist[0] as float[];
            // Re-orientation of pdb coordinates to be oriented according to the symmetry axis
            //Vector3 orientation = direction;
            //axis = self.symmetry_axes[0].direction
            float   angle    = Vector3.Angle(direction, -Vector3.up);
            Vector3 rot_axis = Vector3.Cross(direction, -Vector3.up);

            Debug.Log("Axis: " + rot_axis);
            Debug.Log("Angle: " + angle);
            Quaternion rotate = Quaternion.AngleAxis(angle, rot_axis);

//				Vector3 test = new Vector3 (2.0f, 2.0f, 2.0f);
//				Vector3 result = rotate * test;
//				Debug.Log ("Result: "+result);
            for (int i = 0; i < MoleculeModel.atomsLocationlist.Count; i++)
            {
                float[] position = MoleculeModel.atomsLocationlist[i] as float[];
                Vector3 vec_pos  = new Vector3(position[0], position[1], position[2]);
                Vector3 new_vec  = rotate * vec_pos;
                position[0] = new_vec.x;
                position[1] = new_vec.y;
                position[2] = new_vec.z;
                MoleculeModel.atomsLocationlist[i] = position;
            }
            Debug.Log(MoleculeModel.MinValue);
            ControlMolecule.BuildMoleculeComponents();
            Debug.Log(MoleculeModel.MinValue);
            // Switch on the guided navigation mode
            UIData.guided           = true;
            UIData.resetDisplay     = true;
            UIData.resetBondDisplay = true;
            UIData.isCubeToSphere   = true;
            UIData.isSphereToCube   = false;
            UIData.atomtype         = UIData.AtomType.sphere;
            BallUpdate.resetColors  = true;

//				BallUpdate.resetRadii = true;
            MoleculeModel.newtooltip = GUI.tooltip;

            Debug.Log("resname length: " + MoleculeModel.atomsResnamelist.Count);
            Debug.Log("atomtype length: " + MoleculeModel.atomsTypelist.Count);
            Debug.Log("resname length: " + MoleculeModel.atomsChainList.Count);
            Debug.Log("resname length: " + MoleculeModel.atoms.Count);

            float x_tot = 0.0f;
            float y_tot = 0.0f;
            float z_tot = 0.0f;
            int   count = 0;

            for (int i = 0; i < MoleculeModel.atomsLocationlist.Count; i++)
            {
                if (MoleculeModel.atomsChainList[i] == "B" && MoleculeModel.residueIds[i] == 194)
                {
                    float[] position = MoleculeModel.atomsLocationlist[i] as float[];
                    x_tot += position[0];
                    y_tot += position[1];
                    z_tot += position[2];
                    count++;
                }
            }
            float[] target = new float[3];
            target[0] = x_tot / count;
            target[1] = y_tot / count;
            target[2] = z_tot / count;

            Debug.Log("Target coordinates: " + x_tot / count + " " + y_tot / count + " " + z_tot / count);
//				float[] target= MoleculeModel.atomsLocationlist[0] as float[];
            //OptimalView.OptimalView.GetOptimalPosition(target, (float) 15.0);

            //Refilling CA list for CA trace and BF representation

            List <float[]> calist = new List <float[]>();

            for (int i = 0; i < MoleculeModel.atomsNamelist.Count; i++)
            {
                if (MoleculeModel.atomsNamelist[i] == "CA")
                {
                    float[] vect = new float[3];
                    vect[0] = MoleculeModel.atomsLocationlist[i][0];
                    vect[1] = MoleculeModel.atomsLocationlist[i][1];
                    vect[2] = MoleculeModel.atomsLocationlist[i][2];
                    calist.Add(vect);
                }
            }

            MoleculeModel.CatomsLocationlist       = calist;
            MoleculeModel.backupCatomsLocationlist = calist;

            // Refilling residuedictionaries for Ribbons

            List <Dictionary <string, Vector3> > residueDictList = new List <Dictionary <string, Vector3> >();
            Dictionary <string, Vector3>         residueDict     = new Dictionary <string, Vector3>();
            List <int> residueIds = MoleculeModel.residueIds;
            Vector3    testVector = Vector3.zero;

            int currResId = int.MinValue + 1;
            int prevResId = int.MinValue + 1;

            for (int i = 0; i < MoleculeModel.atomsNamelist.Count; i++)
            {
                currResId = residueIds[i];
                Vector3 currAtom = new Vector3(MoleculeModel.atomsLocationlist[i][0], MoleculeModel.atomsLocationlist[i][1], MoleculeModel.atomsLocationlist[i][2]);

                if (currResId != prevResId)
                {
                    if (residueDict != null && residueDict.Count > 0)
                    {
                        residueDictList.Add(residueDict);
                    }
                    residueDict = new Dictionary <string, Vector3>();
                }
                prevResId = currResId;
                if (!residueDict.TryGetValue(MoleculeModel.atomsNamelist[i], out testVector))
                {
                    residueDict.Add(MoleculeModel.atomsNamelist[i], currAtom);
                }
            }

            MoleculeModel.residueDictionaries = residueDictList;

            CreateAxeAndOrigin();
        }         // End of LoadSymmetry
コード例 #6
0
ファイル: SocketPDB.cs プロジェクト: twobob/UnityMol-Releases
        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);
        }
コード例 #7
0
    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();
    }
コード例 #8
0
        //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;
        }
コード例 #9
0
    /// <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;
    }