70     using System.Collections.Generic;
    88             List<Dictionary<string, Vector3>>   residueDictList     =   
new List<Dictionary<string, Vector3>>();
    89             Dictionary<string, Vector3>         residueDict         =   
new Dictionary<string, Vector3>();
    93             Vector3 currAtom = Vector3.zero;
    95             int currResId = 
int.MinValue+1;
    96             int prevResId = 
int.MinValue+1;
    98             Vector3 testVector = Vector3.zero;
   101             for(
int i=0; i<alist.Count; i++) {
   103                 currResId = residueIds[i];
   113                 if(currResId != prevResId) {
   114                     if(residueDict != null && residueDict.Count > 0){
   115                         residueDictList.Add(residueDict);
   117                     residueDict = 
new Dictionary<string, Vector3>();
   121                 prevResId = currResId;
   124                 currAtom = 
new Vector3(-alist[i][0], alist[i][1], alist[i][2]);
   131                 if(!residueDict.TryGetValue(aNamesList[i], out testVector)){
   132                     residueDict.Add(aNamesList[i], currAtom);
   135                     Debug.Log(
"Bizarre");
   148             Debug.Log(residueDictList.Count+
" residues in the molecule");
   157             List<Dictionary<string, Vector3>>   residueDictList     =   
new List<Dictionary<string, Vector3>>();
   158             Dictionary<string, Vector3>         residueDict         =   
new Dictionary<string, Vector3>();
   163             for (
int i = 0 ; i<alist.Count; i++){
   165                 if((i==alist.Count-1) || (residueIds[i] != residueIds[i+1])){
   166                     if(residueDict != null && residueDict.Count > 0){
   167                         residueDictList.Add(residueDict);
   169                     residueDict = 
new Dictionary<string, Vector3>();
   172                 currAtom = 
new Vector3(-alist[i][0], alist[i][1], alist[i][2]);
   174                 if(!residueDict.TryGetValue(aNamesList[i], out testVector)){
   175                     residueDict.Add(aNamesList[i], currAtom);
   188             Debug.Log(
"CheckHiRERNAModel");
   201                 int nbOfAtoms = entry.Value.Count;
   203                 while (i != nbOfAtoms)
   205                     int atomIndex = (int)entry.Value[i];
   207                     if (atomName == 
"C1" || atomName == 
"G2" || atomName == 
"U1" || atomName == 
"A2")
   220             if (
File.Exists(filename)) {
   221                 StreamReader sr = 
new StreamReader(filename);
   227                 while((s=sr.ReadLine())!=null) {
   228                     substr = s.Substring (7, 10);
   230                     num = 
float.Parse(substr);
   247             UpdateMoleculeCenter();
   259             int cptH = 0,cptC = 0,cptO = 0,cptN = 0,cptS = 0,cptP = 0,cptX = 0;
   264                 else if(atomType == 
"C")
   266                 else if(atomType == 
"O")
   268                 else if(atomType == 
"N")
   270                 else if(atomType == 
"S")
   272                 else if(atomType == 
"P")
   299             Vector3 minPoint= 
new Vector3(
float.MaxValue,
float.MaxValue,
float.MaxValue);
   300             Vector3 maxPoint= 
new Vector3(
float.MinValue,
float.MinValue,
float.MinValue);
   301             Vector3 bary = Vector3.zero;
   303             for(
int i=0; i<alist.Count; i++) {
   304                 float[] position= alist[i];
   305                 minPoint = Vector3.Min(minPoint, 
new Vector3(position[0],position[1],position[2]));
   306                 maxPoint = Vector3.Max(maxPoint, 
new Vector3(position[0],position[1],position[2]));
   307                 bary = bary+(
new Vector3(position[0],position[1],position[2]));
   309             Vector3 centerPoint = bary/alist.Count;
   311             Debug.Log(
"centerPoint:"+centerPoint + 
" min/max " + minPoint + 
"/" + maxPoint);
   316             Debug.Log(
"alist.Count:"+alist.Count);
   317             for(
int i=0; i<alist.Count; i++) {
   318                 float[] position= alist[i];
   320                 float[] vect=
new float[4];
   325                 vect[3] = position[3];
   327                 bary = bary+(
new Vector3(vect[0],vect[1],vect[2]));
   330             for(
int i=0; i<alistSugar.Count; i++) {
   331                 float[] position= alistSugar[i];
   332                 float[] vect=
new float[3];
   342             bary = bary/alist.Count;
   343             Debug.Log(
"Bary center :" + bary);
   349             for(
int i=0; i<calist.Count; i++) {
   350                 float[] position= calist[i] as 
float[];
   351                 float[] vect=
new float[4];
   396             if(calist.Count > 2) {
   417                 geninterpolationarray.InputKeyNodes=calist;
   418                 geninterpolationarray.InputTypeArray=caChainlist;
   419                 geninterpolationarray.CalculateSplineArray();
   422                 calist=geninterpolationarray.OutputKeyNodes;
   423                 caChainlist=geninterpolationarray.OutputTypeArray;
   428             for(
int k=0; k<calist.Count; k++){
   447         public static List<int[]> 
CreateBondsList(List<
float[]> atomsLocationlist, List<AtomModel> atomsTypelist) {
   448             List<int[]> bond=
new List<int[]>();
   450             for(
int i=0;i<atomsLocationlist.Count;i++) {
   451                 float [] atom0 = atomsLocationlist[i];
   452                 string atomtype0 = (atomsTypelist[i]).type;
   457                 for(
int j=1;j<80;j++) {
   458                     if(i+j < atomsLocationlist.Count) {
   459                         float[] atom1 = atomsLocationlist[i+j];
   460                         string atomtype1 = (atomsTypelist[i+j]).type;
   463                         if ((atomtype0==
"H") && (atomtype1==
"H")) 
continue;
   464                         if ((atomtype0==
"S") || (atomtype1==
"S")) cutoff = 1.84f;
   465                         if ((atomtype0==
"O" && atomtype1==
"P") || (atomtype1==
"O" && atomtype0==
"P")) cutoff = 1.84f;
   466                         if ((atomtype0==
"O" && atomtype1==
"H") || (atomtype1==
"O" && atomtype0==
"H")) cutoff = 1.84f;
   472                         float sqDist = (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1) + (z0-z1)*(z0-z1);
   474                         if(sqDist <= cutoff*cutoff) {
   475                             int [] atomsIds = {i,i+j};
   486             List<int[]> bond=
new List<int[]>();
   502             int N = atomsLocationlist.Count;
   504             for(
int i=0;i<N;i++) {
   505                 float[] atom0 = atomsLocationlist[i];
   506                 string atomtype0 = (atomsTypelist[i]).type;
   512                 for (
int j=i+1; j<(i+w < N ? (i+w):N); j++){
   514                     string atomtype1 = (atomsTypelist[j]).type;
   516                     float[] atom1 = atomsLocationlist[j];
   520                     if ((atomtype0==
"H") && (atomtype1==
"H")) 
continue;
   521                     else if ((a1name == 
"CAL") && (atomtype0==
"O")) cutoff = 3.5f;
   522                     else if ((atomtype0==
"S") || (atomtype1==
"S")) cutoff = 1.91f;
   523                     else if ((atomtype0==
"P") || (atomtype1==
"P")) cutoff = 1.7f;
   524                     else if ((atomtype0==
"O" && atomtype1==
"H") || (atomtype1==
"O" && atomtype0==
"H")) cutoff = 1.84f;
   531                     float sqDist = (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1) + (z0-z1)*(z0-z1);
   533                     if(sqDist <= cutoff*cutoff) {
   534                         int [] atomsIds = {i,j};
   550         public static List<int[]> 
CreateBondsEPList(List<
float[]> atomsLocationlist, List<AtomModel> atomsTypelist) {
   551             List<int[]> bond=
new List<int[]>();
   552             List<int> h_already_in=
new List<int>(); 
   558             for(
int i=0;i<atomsLocationlist.Count;i++) {
   559                 float[] atom0 = atomsLocationlist[i];
   560                 string atomtype0 = (atomsTypelist[i]).type;
   582                 for(
int j=i+1; j<atomsLocationlist.Count; j++){
   583                     float[] atom1 = atomsLocationlist[j];
   584                     string atomtype1 = (atomsTypelist[j]).type;
   588                     if ((atomtype0==
"H") && (atomtype1==
"H")) 
continue;
   589                     else if ((a1name == 
"CAL") && (atomtype0==
"O")) cutoff = 3.5f;
   590                     else if ((atomtype0==
"S") || (atomtype1==
"S")) cutoff = 1.91f;
   591                     else if ((atomtype0==
"P") || (atomtype1==
"P")) cutoff = 1.7f;
   592                     else if ((atomtype0==
"O" && atomtype1==
"H") || (atomtype1==
"O" && atomtype0==
"H")) cutoff = 1.84f;
   598                     float sqDist = (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1) + (z0-z1)*(z0-z1);
   609                     if(sqDist <= cutoff*cutoff) {
   612                             if (!h_already_in.Contains(i)){
   613                                 int [] atomsIds = {i,j};
   622                         }
else if (atomtype1==
"H"){
   623                             if (!h_already_in.Contains(j)){
   624                                 int [] atomsIds = {i,j};
   635                             int [] atomsIds = {i,j};
   656                             bond.Add (
new int[2] {atom1, atom2});
   686             GameObject clubatom0 = null;
   687             GameObject clubatom1 = null;
   695                 atomtype0=(atoms[i] as GameObject).tag;
   701                 for(
int j=1;j<count-i;j++)
   706                     atomtype1 = (atoms[i+j] as GameObject).tag;
   709                     if((atomtype0==
"H")&&(atomtype1==
"H"))
continue;
   710                     if((atomtype0==
"S")||(atomtype1==
"S"))cutoff = 1.84f;
   711                     if((atomtype0==
"P")||(atomtype1==
"P"))cutoff = 1.7f;
   718                     diffx = ((atoms[i] as GameObject).transform.position.x-(atoms[i+j] as GameObject).transform.position.x);
   720                     diffy =((atoms[i] as GameObject).transform.position.y-(atoms[i+j] as GameObject).transform.position.y);
   722                     diffz = ((atoms[i] as GameObject).transform.position.z-(atoms[i+j] as GameObject).transform.position.z);
   724                     if((diffx + diffy + diffz) <= cutoff*cutoff)
   727                         Debug.Log (
"Cutoff");
   731                             StickUpdate comp = (club as GameObject).GetComponent<StickUpdate>();
   733                             if(clubatom0 == atoms[i])
   736                                 if(clubatom1 == atoms[i+j])
   747                             Stick = (GameObject)GameObject.Instantiate(Resources.Load(
"HStickPrefab"));
   766                             Stick.GetComponent<Renderer>().material.SetFloat(
"_Shrink", 0.01f);
   768                             Stick.GetComponent<Collider>().enabled = 
false;
   771                             Vector3 posAtom1 = 
new Vector3(fposAtom1[0],fposAtom1[1],fposAtom1[2]);
   774                             Stick.transform.position = posAtom1;
   783                             StickUpdate comp = (club as GameObject).GetComponent<StickUpdate>();
   785                             if(clubatom0 == atoms[i])
   788                                 if(clubatom1 == atoms[i+j])
   790                                     GameObject.DestroyImmediate(club);
   811             List<int[]> bond=
new List<int[]>();
   813             for(
int i=1; i<caChainlist.Count; i++) {
   814                 if(caChainlist[i-1] == caChainlist[i]) {
   815                     int[] splineIds = {i-1,i};
   819             Debug.Log(
"bond.Count:"+bond.Count);
   825             StringBuilder sequence = 
new StringBuilder(
new string(
'.', nucleotide_count), nucleotide_count);
   829                 int atomId = (int)entry.Value[0];
   833             return sequence.ToString();
   839             List<int[]> bonds = 
new List<int[]>();
   840             int N = atomnames.Count;
   843             for(
int i=0; i<N-1; ++i) {
   844                 string a1 = atomnames[i];
   847                     for(k=i; k>=0 && k>=i-5 && (atomnames[k])!=
"CA"; --k);
   848                     if(k>=0 && k>=i-5) bonds.Add(
new int[] {i,k});
   851                     if(atomnames[i+1] == 
"O5*")
   852                         bonds.Add(
new int[] {i,i+1});
   854                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"O5* missing");
   856                 else if(a1 == 
"O5*") {
   858                     if(atomnames[i+1] == 
"C5*")
   859                         bonds.Add(
new int[] {i,i+1});
   861                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"C5* missing");
   863                 else if(a1 == 
"C5*") {
   865                     if(atomnames[i+1] == 
"CA")
   866                         bonds.Add(
new int[] {i,i+1});
   868                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"CA missing");
   870                 else if(a1 == 
"CA") {
   872                     if(atomnames[i+1] == 
"CY")
   873                         bonds.Add(
new int[] {i,i+1});
   875                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"CY missing");
   877                 else if(a1 == 
"CY") {
   879                     string a2 = atomnames[i+1];
   880                     if(a2 == 
"G1" || a2 == 
"A1" || a2 == 
"U1" || a2 == 
"C1")
   881                         bonds.Add(
new int[] {i,i+1});
   883                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"b1 missing");
   885                 else if(a1 == 
"G1") {
   887                     if(atomnames[i+1] == 
"G2")
   888                         bonds.Add(
new int[] {i,i+1});
   890                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"G2 missing");
   892                 else if(a1 == 
"A1") {
   894                     if(atomnames[i+1] == 
"A2")
   895                         bonds.Add(
new int[] {i,i+1});
   897                         Debug.Log(
"Atom "+ (i+1) as 
string + 
"A2 missing");
   900             Debug.Log(
"HiRERNA bond count : " + bonds.Count);
   909             List<int[]> bond=
new List<int[]>();
   913             Debug.Log(
"atomsLocationlist.Count:"+atomsLocationlist.Count);
   916             for(
int i=0;i<atomsLocationlist.Count;i++) {
   918                 int[] atom0 = atomsLocationlist[i];
   940                     if(source==number[0])
   942                     if(target==number[0])
   945                 bond.Add(
new int[] {atom0sign, atom1sign});
 static List< Dictionary< string, Vector3 > > residueDictionaries
 
static List< int[]> CreateBondsList_HiRERNA(List< string > atomnames)
 
static List< int[]> CreateBondsListWindow(List< float[]> atomsLocationlist, List< AtomModel > atomsTypelist)
 
static List< int[]> bondCAList
The bonds between carbon alpha in the CA-Spline. 
 
static List< int[]> BondListFromPDB
 
static List< int[]> CreateBondsCSList(List< int[]> atomsLocationlist)
 
static List< int[]> CreateBondsCAList(List< string > caChainlist)
Creates a bond list for the carbon alpha splines. 
 
static AtomModel GetModel(string type)
 
static Vector3 Offset
The offset for the molecule. 
 
static string unknownNumber
 
static List< int[]> CreateBondsEPList(List< float[]> atomsLocationlist, List< AtomModel > atomsTypelist)
 
static List< string > atomsNamelist
The name of each atom. 
 
static List< AtomModel > atomsTypelist
The type of each atom. 
 
static List< float[]> atomsSugarLocationlist
 
static bool connectivity_calc
 
static List< float > scale_RNA
RNA Scale parameters 
 
static string directorypath
 
static List< int > residueIds
The residue identifiers. 
 
static string CreateSequenceString()
 
static List< int[]> CreateBondsList(List< float[]> atomsLocationlist, List< AtomModel > atomsTypelist)
 
static List< float[]> CatomsLocationlist
The coordinates of each Carbon alpha. 
 
static void CheckHiRERNAModel()
Checks whether the loaded PDB file follows the HiRE-RNA coarse-grain model or not. 
 
static List< int[]> CSidList
 
static void UpdateBondsFromGameObject(ArrayList atoms)
 
static GameObject BondCubeParent
 
static Vector3 cameraLocation
 
static List< AtomModel > atomsSugarTypelist
 
static List< string > backupCaSplineChainList
Sometimes inside pdbs lists are not sorted, and residues mixed So I had to create this list to sort r...
 
static List< int[]> bondEPSugarList
 
static List< float[]> CaSplineList
The coordinates of each Carbon alpha in the CA-Spline. 
 
!WiP Includes FLAGS of GUI. 
 
static void CreateResidues()
 
static string nitrogenNumber
 
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 void CreateSplines()
Creates the carbon alpha splines. 
 
static Dictionary< int, ArrayList > residues
The residues. 
 
static List< int[]> bondEPList
The bonds between atoms. 
 
static List< float[]> backupCatomsLocationlist
Backup of the coordinates of each Carbon alpha. 
 
static List< Dictionary< string, Vector3 > > residueDictionariesSugar
 
static string carbonNumber
 
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 string hydrogenNumber
 
static void RNAView_init()
 
static string oxygenNumber
 
static void BuildMoleculeComponents()
Builds the molecule's components. 
 
static string sulphurNumber
 
static GameObject[] clubs
 
static string phosphorusNumber
 
static List< int > baseIdx
The index (in tables) of the base extremity. 
 
static Vector3 Center
The barycenter of the molecule. 
 
static void BuildHireRnaHydrogenBondsStructures()
 
static List< AtomModel > CaSplineTypeList
Type of each carbon alpha in the CA-Spline. 
 
static void UpdateMoleculeCenter()
 
static bool connectivity_PDB
 
static void CreateResiduesSugar2()
 
static List< float[]> atomsLocationlist
The coordinates of each atom. 
 
static Dictionary< int, List< int > > bondEPDict
Dictionary of every bounded atoms (which atoms whith which atoms).