UnityMol  0.9.6-875
UnityMol viewer / In developement
VARNABillboard.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using Molecule.Model;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System;
7 using System.Diagnostics;
8 using System.Threading;
9 
10 public class VARNABillboard : MonoBehaviour {
11  private bool done = true;
12 
13  private Process varnaProcess;
14  private Thread oThread;
15 
16  private string outputDirectory = Application.dataPath + "/Resources";
17 
18  // Use this for initialization
19  void Start () {
20  gameObject.transform.localPosition = new Vector3(2.0f,-1.0f,3.0f);
21  gameObject.transform.localRotation = Quaternion.identity;
22  }
23 
24  private void varnaProcess_Exited(object sender, System.EventArgs e)
25  {
26  done = true;
27  }
28 
29  // Update is called once per frame
30  void Update () {
31  if (done)
32  {
33  done = false;
34 
35  StartCoroutine("loadFile");
36 
37  oThread = new Thread(new ThreadStart(generateFileInThread));
38  oThread.Start();
39  }
40  }
41 
43  List<int[]> hbonds = RNAView.findHbonds();
44  PlotManager.Instance.PlotAdd("NHBonds", hbonds.Count);
45  int sequenceLength = MoleculeModel.sequence.Count();
46  string structure = VARNA.generateStructureString(sequenceLength, hbonds);
47 
48  varnaProcess = VARNA.generateImage(MoleculeModel.sequence, structure, outputDirectory, "test.png");
49  varnaProcess.Exited += new EventHandler(varnaProcess_Exited);
50  varnaProcess.Start();
51  }
52 
53  IEnumerator loadFile() {
54  ResourceRequest request = Resources.LoadAsync("test");
55  yield return request;
56  gameObject.GetComponent<Renderer>().material.mainTexture = request.asset as Texture2D;
57  UnityEngine.Debug.Log ("::::: Loaded");
58  }
59 }
static string generateStructureString(int sequenceLength, List< int[]> pairs)
Definition: VARNA.cs:8
string outputDirectory
void PlotAdd(String plotName, float value)
Add a value to plot graph
Definition: PlotManager.cs:53
static List< int[]> findHbonds()
Definition: RNAView.cs:228
Process varnaProcess
static PlotManager Instance
Instance of object
Definition: PlotManager.cs:18
IEnumerator loadFile()
void varnaProcess_Exited(object sender, System.EventArgs e)
Definition: VARNA.cs:7
void generateFileInThread()
static Process generateImage(string sequence, string structure, string outputDirectory, string filename)
Definition: VARNA.cs:29