71 using System.Collections.Generic;
80 using System.Text.RegularExpressions;
93 public float progress=0.0f;
94 public static bool isDone=
false;
95 public bool Loading =
true;
103 bool wantjson =
false;
124 public IEnumerator
LoadJsonWWW(
string file_name, Vector3 Offset) {
125 WWW www =
new WWW(file_name);
131 progress = www.progress;
132 yield
return new WaitForEndOfFrame();
146 WWW www =
new WWW(file_name);
152 progress = www.progress;
153 yield
return new WaitForEndOfFrame();
156 OBJ obj =
new OBJ(
new StringReader(www.text));
163 XmlReader reader=
new XmlTextReader(file_name);
166 while(reader.Read()) {
167 if(reader.ReadToFollowing(
"PDBx:atom_site")) {
168 Vector3 v=
new Vector3();
170 reader.ReadToDescendant(
"PDBx:Cartn_x");
171 v.x=reader.ReadElementContentAsFloat();
172 reader.ReadToFollowing(
"PDBx:Cartn_y");
173 v.y=reader.ReadElementContentAsFloat();
174 reader.ReadToFollowing(
"PDBx:Cartn_z");
175 v.z=reader.ReadElementContentAsFloat();
191 sr=
new StreamReader(resource_name+
".txt");
193 ReadPDBReaction(sr, resource_name);
201 sr=
new StreamReader(resource_name+
".top");
203 ReadAnimTop(sr, resource_name);
211 sr=
new StreamReader(resource_name+
".mdcrd");
213 ReadAnimCrd(sr, resource_name);
221 List<String> nbChainStr =
new List<string> ();
222 List<int> resInOrderByChain =
new List<int>();
223 Dictionary<string, int> IDofString =
new Dictionary<string, int> ();
227 for (
int i=0; i<resChainList.Count; i++) {
228 if (!nbChainStr.Contains (resChainList [i])) {
229 nbChainStr.Add(resChainList[i]);
230 IDofString.Add (resChainList[i], stringID);
235 int nbChain = nbChainStr.Count ();
237 List<int>[] preSortedList =
new List<int>[nbChain];
239 for (
int i=0; i<preSortedList.Length; i++) {
240 preSortedList[i] =
new List<int>();
245 for (
int i=0; i<resChainList.Count; i++){
246 preSortedList[IDofString[resChainList[i]]].Add (i);
250 for (
int i=0 ; i<preSortedList.Length; i++){
251 resInOrderByChain.AddRange(preSortedList[i]);
254 return resInOrderByChain;
267 srdr =
new StreamReader(resource_name+
".txt");
268 while((s=srdr.ReadLine()).StartsWith(
"[GEOMETRIES]")==
false){}
270 while((s = srdr.ReadLine())!=null){
271 if(s.StartsWith(
"END")){
275 tmp =
new ArrayList();
278 if(s.StartsWith(
"Coords")){
281 float[] xyz =
new float[3];
282 xyz[0] = -
float.Parse(s.Substring(7,9));
283 xyz[1] =
float.Parse(s.Substring(20,9));
284 xyz[2] =
float.Parse(s.Substring(32,9));
312 List<float> BFactorList =
new List<float>();
313 List<int> calist =
new List<int>();
314 List<string> resnamelist =
new List<string>();
315 List<string> atomsNameList =
new List<string>();
316 List<string> caChainlist =
new List<string>();
317 List<Color> colorList =
new List<Color> ();
319 List<AtomModel> typelist =
new List<AtomModel>();
320 string[] dnaBackboneAtoms =
new string[] {
"C5'"};
324 while(!s.StartsWith(
"%FORMAT(10I8)"))
329 string count =
string.Empty;
331 while(!
char.IsDigit(s[c]))
335 while(
char.IsDigit(s[c])){
341 while(!s.StartsWith(
"%FLAG AMBER_ATOM_TYPE "))
347 while(!s.StartsWith(
"%"))
350 String[] sa = s.Split(sep, 20, StringSplitOptions.RemoveEmptyEntries);
351 for(
int i = 0; i < sa.Count() ; i++)
353 string typestring = sa[i];
354 atomsNameList.Add(typestring);
356 bool b =
int.TryParse(typestring[0].ToString(), out bout);
360 type=typestring[1].ToString();
364 type=typestring[0].ToString();
367 string resname =
"MOL";
370 if(typestring[0].ToString()==
"C" && typestring.Length>1)
372 if(typestring[1].ToString()==
"A")
374 string chaintype =
"chain" +
"A";
376 caChainlist.Add(chaintype);
379 if(dnaBackboneAtoms.Contains(typestring))
381 string chaintype =
"chain" +
"A";
383 caChainlist.Add(chaintype);
385 float bfactor = 10.00f;
386 BFactorList.Add(bfactor);
389 typelist.Add(aModel);
400 resnamelist.Add(resname);
411 for(
int i=0;i<calist.Count;i++)
431 List<float[]> alist =
new List<float[]>();
432 List<float[]> calist =
new List<float[]>();
433 int currentcoord = 0;
434 int currentatome = 0;
440 float[] xyz =
new float[3];
441 ArrayList step =
new ArrayList();
444 tmp = s.Split(sep, 10, StringSplitOptions.RemoveEmptyEntries);
445 if(tmp.Count () == 0)
449 for(
int i = 0 ; i < tmp.Count() ; i++)
451 xyz[currentcoord] =
float.Parse(tmp[i]);
453 if(currentcoord == 3)
464 step =
new ArrayList();
471 float[] xyzi =
new float[4];
474 xyzi[0] = ((
Reaction.
coord[0] as ArrayList)[i] as
float[])[0];
475 xyzi[1] = ((
Reaction.
coord[0] as ArrayList)[i] as
float[])[1];
476 xyzi[2] = ((
Reaction.
coord[0] as ArrayList)[i] as
float[])[2];
518 WWW www =
new WWW(file_name);
523 progress = www.progress;
537 List<float[]> alist =
new List<float[]>();
538 List<float[]> CSRadiusList =
new List<float[]>();
540 List<AtomModel> typelist =
new List<AtomModel>();
542 List<int[]> edgelist =
new List<int[]>();
543 List<string> resnamelist =
new List<string>();
544 List<string[]> CSSGDList =
new List<string[]>();
545 List<string[]> CSColorList=
new List<string[]>();
546 List<string[]> CSLabelList=
new List<string[]>();
548 List<int[]> CSidList =
new List<int[]>();
551 XmlReader reader=
new XmlTextReader(
new StringReader(xml_content));
554 if(reader.ReadToFollowing(
"node"))
556 float[] vect=
new float[3];
558 float [] intarrayw=
new float[1];
559 while (reader.MoveToNextAttribute())
561 if(reader.Name==
"label")
563 string [] intarray=
new string[1];
564 intarray[0]=reader.Value;
565 CSLabelList.Add(intarray);
568 else if(reader.Name==
"id")
570 int [] intarray=
new int[1];
571 intarray[0]=
int.Parse(reader.Value);
572 CSidList.Add(intarray);
584 reader.ReadToFollowing(
"graphics");
585 while (reader.MoveToNextAttribute())
587 if(reader.Name==
"type")
591 else if(reader.Name==
"h")
595 else if(reader.Name==
"w")
598 intarrayw[0]=
float.Parse(reader.Value)/60;
600 CSRadiusList.Add(intarrayw);
602 else if(reader.Name==
"x")
606 vect[0]=
float.Parse(reader.Value)/60;
609 else if(reader.Name==
"y")
613 vect[1]=-
float.Parse(reader.Value)/60;
615 else if(reader.Name==
"fill")
617 string [] intarray=
new string[1];
618 intarray[0]=reader.Value;
619 CSColorList.Add(intarray);
623 else if(reader.Name==
"width")
627 else if(reader.Name==
"outline")
644 XmlReader reader2=
new XmlTextReader(
new StringReader(xml_content));
645 while(reader2.Read())
647 if(reader2.ReadToFollowing(
"edge"))
649 int[] vectint=
new int[2];
650 while (reader2.MoveToNextAttribute())
652 if(reader2.Name==
"label")
656 else if(reader2.Name==
"source")
659 vectint[0]=
int.Parse(reader2.Value);
661 else if(reader2.Name==
"target")
664 vectint[1]=
int.Parse(reader2.Value);
669 edgelist.Add(vectint);
676 XmlReader reader3=
new XmlTextReader(
new StringReader(xml_content));
677 while(reader3.Read())
679 if(reader3.NodeType==XmlNodeType.Element)
681 while (reader3.MoveToNextAttribute())
683 if(reader3.Name==
"name"&& reader3.Value==
"SGD symbol")
685 if(reader3.MoveToNextAttribute())
688 string [] intarray=
new string[1];
689 intarray[0]=reader3.Value;
690 CSSGDList.Add(intarray);
713 Vector3 minPoint=
new Vector3(
float.MaxValue,
float.MaxValue,
float.MaxValue);
714 Vector3 maxPoint=
new Vector3(
float.MinValue,
float.MinValue,
float.MinValue);
716 for(
int i=0; i<alist.Count; i++)
718 float[] position= alist[i] as
float[];
720 minPoint = Vector3.Min(minPoint,
new Vector3(position[0],position[1],position[2]));
721 maxPoint = Vector3.Max(maxPoint,
new Vector3(position[0],position[1],position[2]));
723 Vector3 centerPoint = minPoint + ((maxPoint - minPoint) / 2);
726 Camera.main.transform.position=
new Vector3(0,0,0);
735 for(
int i=0; i<alist.Count; i++)
737 float[] position= alist[i] as
float[];
738 float[] vectarray=
new float[3];
770 if(fieldlinefile.Exists)
771 wantjson = GUILayout.Toggle (wantjson,
new GUIContent (
"JSON" ,
"Open the Json file"));
776 if(Surfacefile.Exists || Surfacefile0.Exists)
777 wantobj = GUILayout.Toggle (wantobj,
new GUIContent (
"OBJ" ,
"Open the Obj file"));
781 wantdx = GUILayout.Toggle (wantdx,
new GUIContent (
"DX" ,
"Open the Dx file"));
782 if (GUILayout.Button(
"Confirm")){
static List< string[]> CSColorList
static bool networkLoaded
List< List< Vector3 > > ReadFile(string fieldlines_file_content, Vector3 Offset)
static List< int[]> CreateBondsCSList(List< int[]> atomsLocationlist)
void ReadXGMML(String xml_content)
void LoadAnimCrd(string resource_name)
IEnumerator LoadJsonWWW(string file_name, Vector3 Offset)
Loads the json WW.
static AtomModel GetModel(string type)
static Vector3 Offset
The offset for the molecule.
static string file_base_name
static int[] CatomsIndList
static List< string > atomsNamelist
The name of each atom.
static List< AtomModel > atomsTypelist
The type of each atom.
static List< float[]> CatomsLocationlist
The coordinates of each Carbon alpha.
static List< float[]> CSRadiusList
static List< float > BFactorList
Bfactor of each atom.
void ReadAnimTop(TextReader sr, string resource_name)
void ReadPDBReaction(TextReader sr, string resource_name)
static Color GetAtomColor(string atomType)
static List< int[]> CSidList
void LoadPDBReaction(string resource_name)
static Vector3 cameraLocation
void LoadXGMML(string file_name)
!WiP Includes FLAGS of GUI.
static bool isParticlesInitialized
static Vector3 MaxValue
The "biggest" corner of the bounding box that encloses the molecule.
static List< string > CaSplineChainList
The chain of each carbon alpha in the CA-Spline.
!WiP manage GUI, and provide static strings for the GUI.
static List< Color > atomsColorList
The color of each atom.
static void CreateSplines()
Creates the carbon alpha splines.
static List< int[]> bondEPList
The bonds between atoms.
static List< List< Vector3 > > FieldLineList
void ReadAnimCrd(TextReader sr, string resource_name)
void LoadXMLRequest(string file_name)
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule.
void LoadAnimTop(string resource_name)
IEnumerator LoadOBJWWW(string file_name)
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
static void BuildMoleculeComponents()
Builds the molecule's components.
static List< string[]> CSLabelList
static List< string[]> CSSGDList
static List< int > sortResIndex(List< string > resChainList)
static List< float[]> atomsLocationlist
The coordinates of each atom.