UnityMol  0.9.6-875
UnityMol viewer / In developement
Reorient.cs
Go to the documentation of this file.
1 // ------------------------------------------------------------------------------
2 // <autogenerated>
3 // This code was generated by a tool.
4 // Mono Runtime Version: 4.0.30319.1
5 //
6 // Changes to this file may cause incorrect behavior and will be lost if
7 // the code is regenerated.
8 // </autogenerated>
9 // ------------------------------------------------------------------------------
10 using System;
11 using UnityEngine;
12 using System.Collections;
13 using Molecule.Model;
14 using System.Collections.Generic;
15 using UI;
16 using Molecule.Control;
17 using OptimalView;
18 
19 namespace Reorient
20 {
21  public class Reorient
22  {
23  public static void LoadSymmetry(float Xorigin, float Yorigin, float Zorigin, float Xdirection, float Ydirection, float Zdirection)
24  {
26  Debug.Log("REORIENTATION");
27  //Vector3 origin = new Vector3 (Xorigin, Yorigin, Zorigin);
28  Vector3 direction = new Vector3 (Xdirection, Ydirection, Zdirection);
29  direction.Normalize ();
30  //float[] position= MoleculeModel.atomsLocationlist[0] as float[];
31 
32  // Re-orientation of pdb coordinates to be oriented according to the symmetry axis
33  //Vector3 orientation = direction;
34  //axis = self.symmetry_axes[0].direction
35  float angle = Vector3.Angle(direction, -Vector3.up);
36  Vector3 rot_axis = Vector3.Cross (direction, -Vector3.up);
37  Debug.Log ("Axis: "+rot_axis);
38  Debug.Log ("Angle: "+angle);
39  Quaternion rotate = Quaternion.AngleAxis (angle, rot_axis);
40 // Vector3 test = new Vector3 (2.0f, 2.0f, 2.0f);
41 // Vector3 result = rotate * test;
42 // Debug.Log ("Result: "+result);
43  for (int i=0; i<MoleculeModel.atomsLocationlist.Count; i++) {
44  float[] position= MoleculeModel.atomsLocationlist[i] as float[];
45  Vector3 vec_pos = new Vector3(position[0], position[1], position[2]);
46  Vector3 new_vec = rotate * vec_pos;
47  position[0] = new_vec.x;
48  position[1] = new_vec.y;
49  position[2] = new_vec.z;
50  MoleculeModel.atomsLocationlist[i] = position;
51  }
52  Debug.Log (MoleculeModel.MinValue);
54  Debug.Log (MoleculeModel.MinValue);
55 
56  // Switch on the guided navigation mode
57  UIData.guided = true;
58 
59  // Redraw spheres with new atoms positions
60 
62 
63  BallUpdate.resetColors = true;
64 
65 
66 // BallUpdate.resetRadii = true;
67  MoleculeModel.newtooltip = GUI.tooltip;
68 
69  Debug.Log("resname length: "+MoleculeModel.atomsResnamelist.Count);
70  Debug.Log("atomtype length: "+MoleculeModel.atomsTypelist.Count);
71  Debug.Log("resname length: "+MoleculeModel.atomsChainList.Count);
72  Debug.Log("resname length: "+MoleculeModel.atoms.Count);
73 
74  float x_tot = 0.0f;
75  float y_tot = 0.0f;
76  float z_tot = 0.0f;
77  int count = 0;
78 
79  for (int i=0; i<MoleculeModel.atomsLocationlist.Count; i++) {
80  if(MoleculeModel.atomsChainList[i] == "B" && MoleculeModel.residueIds[i] == 194){
81  float[] position= MoleculeModel.atomsLocationlist[i] as float[];
82  x_tot += position[0];
83  y_tot += position[1];
84  z_tot += position[2];
85  count++;
86  }
87  }
88  float[] target = new float[3];
89  target[0] = x_tot/count;
90  target[1] = y_tot/count;
91  target[2] = z_tot/count;
92 
93  Debug.Log ("Target coordinates: "+x_tot/count+" "+y_tot/count+" "+z_tot/count);
94 // float[] target= MoleculeModel.atomsLocationlist[0] as float[];
95  //OptimalView.OptimalView.GetOptimalPosition(target, (float) 15.0);
96 
97  //Refilling CA list for CA trace and BF representation
98 
99  List<float[]> calist = new List<float[]>();
100 
101  for (int i = 0; i<MoleculeModel.atomsNamelist.Count; i++){
102  if(MoleculeModel.atomsNamelist[i] == "CA"){
103  float[] vect = new float[3];
104  vect[0] = MoleculeModel.atomsLocationlist[i][0];
105  vect[1] = MoleculeModel.atomsLocationlist[i][1];
106  vect[2] = MoleculeModel.atomsLocationlist[i][2];
107  calist.Add (vect);
108  }
109  }
110 
113 
114  // Refilling residuedictionaries for Ribbons
115 
116  List<Dictionary<string, Vector3>> residueDictList = new List<Dictionary<string, Vector3>>();
117  Dictionary<string, Vector3> residueDict = new Dictionary<string, Vector3>();
118  List<int> residueIds = MoleculeModel.residueIds;
119  Vector3 testVector = Vector3.zero;
120 
121  int currResId = int.MinValue+1;
122  int prevResId = int.MinValue+1;
123 
124  for (int i = 0; i<MoleculeModel.atomsNamelist.Count; i++) {
125 
126  currResId = residueIds[i];
127  Vector3 currAtom = new Vector3(MoleculeModel.atomsLocationlist[i][0], MoleculeModel.atomsLocationlist[i][1], MoleculeModel.atomsLocationlist[i][2]);
128 
129  if(currResId != prevResId) {
130  if(residueDict != null && residueDict.Count > 0){
131  residueDictList.Add(residueDict);
132  }
133  residueDict = new Dictionary<string, Vector3>();
134  }
135  prevResId = currResId;
136  if(!residueDict.TryGetValue(MoleculeModel.atomsNamelist[i], out testVector)){
137  residueDict.Add(MoleculeModel.atomsNamelist[i], currAtom);}
138 
139  }
140 
141  MoleculeModel.residueDictionaries = residueDictList;
142 
144 
145  } // End of LoadSymmetry
146 
147  }
148 
149 }
150 
static List< Dictionary< string, Vector3 > > residueDictionaries
static GuidedNavigationManager getGuidedNavigationManager()
Definition: UnityMolMain.cs:38
void CreateAxeAndOrigin()
Instantiate the origin and symmetry axis game objects.
static bool guided
Definition: UIData.cs:201
static List< string > atomsNamelist
The name of each atom.
static List< string > atomsChainList
The chain of each atom.
static List< AtomModel > atomsTypelist
The type of each atom.
static bool resetColors
Definition: BallUpdate.cs:73
static List< int > residueIds
The residue identifiers.
static List< float[]> CatomsLocationlist
The coordinates of each Carbon alpha.
!WiP Includes FLAGS of GUI.
Definition: UIData.cs:78
static void ChangeRepresentation(UIData.AtomType newAtomType, UIData.BondType newBondType=UIData.BondType.nobond)
static List< float[]> backupCatomsLocationlist
Backup of the coordinates of each Carbon alpha.
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule.
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
static void BuildMoleculeComponents()
Builds the molecule&#39;s components.
static void LoadSymmetry(float Xorigin, float Yorigin, float Zorigin, float Xdirection, float Ydirection, float Zdirection)
Definition: Reorient.cs:23
Definition: GUIDisplay.cs:66
static List< float[]> atomsLocationlist
The coordinates of each atom.