UnityMol  0.9.6-875
UnityMol viewer / In developement
SnapshotManager.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using Molecule.Model;
4 using System;
5 using System.IO;
6 using System.Linq;
7 using UI;
8 
9 public class SnapshotManager {
13  public static string generateSnapshot()
14  {
16  Vector3[] a = new Vector3[size];
18  int c = a.Count();
19 
20  string snapshot = "";
21 
22  // snapshot += "MODEL\n";
23 
24  int j = 0;
25  for (int i = 0; i < c; i++)
26  {
27  j = i + 1;
28  snapshot += "ATOM "
29  + string.Format("{0,5}", j)
30  + string.Format("{0,4:###}", MoleculeModel.atomsNamelist[i]) + " "
31  + string.Format("{0,4:###.0}", MoleculeModel.atomsResnamelist[i]) + " "
32  + string.Format("{0,4:###}", MoleculeModel.residueIds[i])
33  + string.Format("{0,11:###.000}", a[i].x) + " "
34  + string.Format("{0,8:###.000}", a[i].y) + " "
35  + string.Format("{0,8:###.000}", a[i].z) + "\n";
36  }
37  // snapshot += "ENDMDL";
38 
39  return snapshot;
40  }
41 
43  public static string getPath()
44  {
45  return Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/.unitymol/snapshots/";
46  }
47 
51  public static string saveSnapshot()
52  {
53  string molName = GUIDisplay.id;
54  string filename = Environment.UserName + "-" + molName + "-" + DateTime.Now.ToString ("yyyy-MM-dd-H-mm-ss") +".pdb";
55  string path = getPath();
56  System.IO.Directory.CreateDirectory(path);
57  StreamWriter sw = new StreamWriter(path + filename);
58  sw.Write (generateSnapshot());
59  sw.Close();
60 
61  return filename;
62  }
63 }
static string id
Definition: GUIDisplay.cs:123
static string generateSnapshot()
Produces a snapshot of the molecule in PDB format.
static List< string > atomsNamelist
The name of each atom.
static string getPath()
Get the path of the directory to which snapshots are saved.
static List< Vector3 > atomsIMDSimulationLocationlist
The coordinates of each atom, simulated through an IMD simulation.
static List< int > residueIds
The residue identifiers.
!WiP manage GUI, and provide static strings for the GUI.
Definition: GUIDisplay.cs:94
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
Definition: GUIDisplay.cs:66
static string saveSnapshot()
Save a snapshot of the molecule in a PDB file on disk.