コード例 #1
0
ファイル: Mol2Reader.cs プロジェクト: tam10/oniom_gui
    public IEnumerator AtomsFromMol2File(string path, Atoms atoms, Atom atomPrefab)
    {
        atoms.globalSettings = globalSettings;
        atoms.setSourceFile(path);

        atoms.name = Path.GetFileName(path);
        gc         = Instantiate <GaussianCalculator> (GameObject.FindObjectOfType <PrefabManager>().gaussianCalculatorPrefab, atoms.transform);
        atoms.gaussianCalculator = gc;

        int index = 0;

        Vector3 position = new Vector3();

        List <Data.AmberToElement> amberToElementList = data.amberToElementData;

        Data.AmberToElement amberToElement;
        int amberToElementNum;

        List <int[]> connectionList = new List <int[]> ();
        int          a0;
        int          a1;
        int          bondOrder;

        bool readAtoms        = false;
        bool readConnectivity = false;

        string[] lines = FileIO.Readlines(path);
        string[] splitLine;

        int    lineNumber;
        string line;

        for (lineNumber = 0; lineNumber < lines.Length; lineNumber++)
        {
            line = lines [lineNumber];
            if (line.StartsWith("@<TRIPOS>"))
            {
                readAtoms = line.Contains("ATOM");
                //readConnectivity = line.Contains("BOND");
            }
            else if (readAtoms)
            {
                splitLine = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
                Atom atom = Instantiate <Atom> (atomPrefab);

                //Atom types
                atom.pdbName = splitLine [1];

                atom.amberName = splitLine [5];

                for (amberToElementNum = 0; amberToElementNum < amberToElementList.Count; amberToElementNum++)
                {
                    amberToElement = amberToElementList [amberToElementNum];
                    if (amberToElement.amberName == atom.amberName)
                    {
                        atom.element      = amberToElement.element;
                        atom.formalCharge = amberToElement.formalCharge;
                    }
                }


                //Position
                position.x = float.Parse(splitLine [2]);
                position.y = float.Parse(splitLine [3]);
                position.z = float.Parse(splitLine [4]);
                atom.transform.position = position;

                //Residue
                atom.residueNumber = int.Parse(splitLine [6]);
                atom.residueName   = splitLine [7];

                if (splitLine.Length > 8)
                {
                    atom.partialCharge = float.Parse(splitLine [8]);
                }

                atom.index = index;
                atoms.AddAtom(atom);
                //atom.resolution = globalSettings.ballResolution;
                //atom.transform.SetParent(atoms.atomsHolder.transform);
                //atoms.atomList.Add (atom);

                index++;
            }
            else if (readConnectivity)
            {
                splitLine = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
                a0        = int.Parse(splitLine [1]) - 1;
                a1        = int.Parse(splitLine [2]) - 1;
                bondOrder = int.Parse(splitLine [3]);
                connectionList.Add(new int[3] {
                    a0, a1, bondOrder
                });
            }

            if (lineNumber % globalSettings.maxLinesToYield == 0)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }

        atoms.graph.SetAtoms(atoms);
        gc.SetAtoms(atoms);
        foreach (int[] connectionPair in connectionList)
        {
            atoms.graph.Connect(connectionPair [0], connectionPair [1], (double)connectionPair [2]);
        }
    }
コード例 #2
0
    public IEnumerator AtomsFromGaussianInput(string path, Atoms atoms, Atom atomPrefab)
    {
        atoms.globalSettings = globalSettings;
        atoms.setSourceFile(path);

        atoms.name = Path.GetFileName(path);
        gc         = Instantiate <GaussianCalculator> (GameObject.FindObjectOfType <PrefabManager>().gaussianCalculatorPrefab, atoms.transform);
        atoms.gaussianCalculator = gc;


        int    index      = 0;
        int    lineNumber = 0;
        string line;

        string[] lines = FileIO.Readlines(path, "!");
        string[] stringArray;
        int      stringArrayIndex;
        int      maxLines = lines.Length;

        //Link 0 commands
        while (lineNumber < maxLines)
        {
            line = lines [lineNumber].Trim();
            if (line.StartsWith("#"))
            {
                break;
            }
            else if (line.ToUpper().StartsWith("%CHK"))
            {
                gc.checkpointPath = GetValueFromPair(line);
            }
            else if (line.ToUpper().StartsWith("%OLDCHK"))
            {
                gc.oldCheckpointPath = GetValueFromPair(line);
            }
            else if (line.ToUpper().StartsWith("%MEM"))
            {
                gc.jobMemoryMB = GetMemoryMB(GetValueFromPair(line));
            }
            else if (line.ToUpper().StartsWith("%NPROC"))
            {
                gc.nProcessors = int.Parse(GetValueFromPair(line));
            }
            else if (line.ToUpper().StartsWith("%KJOB"))
            {
                stringArray    = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
                gc.killJobLink = stringArray [1];

                if (stringArray.Length > 2)
                {
                    gc.killJobAfter = int.Parse(stringArray [2]);
                }
                else
                {
                    gc.killJobAfter = 1;
                }
            }

            lineNumber++;
        }


        List <string> keywordsList = new List <string> ();
        string        keywordItem;


        //Keywords
        while (lineNumber < maxLines)
        {
            line = lines [lineNumber].Trim();
            if (line == "")
            {
                break;
            }

            stringArray = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
            for (stringArrayIndex = 0; stringArrayIndex < stringArray.Length; stringArrayIndex++)
            {
                keywordsList.Add(stringArray [stringArrayIndex].ToLower());
            }
            lineNumber++;
        }

        //Parse keywords - only one line so don't need to worry about optimisation
        for (stringArrayIndex = 0; stringArrayIndex < keywordsList.Count; stringArrayIndex++)
        {
            keywordItem = keywordsList [stringArrayIndex];
            //Print level
            if (keywordItem.StartsWith("#"))
            {
                gc.gaussianPrintLevel = keywordItem.Replace("#", "");

                //Method
            }
            else if (keywordItem.StartsWith("oniom"))
            {
                string oniomMethodsStr = GetStringInParentheses(keywordItem);
                string oniomOptionsStr = GetStringInParentheses(GetValueFromPair(keywordItem, checkEnclosed: true));

                string[] oniomOptions = oniomOptionsStr.Split(new [] { "," }, System.StringSplitOptions.RemoveEmptyEntries);

                foreach (string oniomOption in oniomOptions)
                {
                    gc.oniomOptions.Add(oniomOption);
                }

                string[] methods = oniomMethodsStr.Split(new [] { ":" }, System.StringSplitOptions.RemoveEmptyEntries);

                string[] highMBO = GetMethodFromString(methods [0]);
                gc.layers.AddLayer(highMBO [0], highMBO [1], highMBO [2], 'H');

                if (methods.Length == 2)
                {
                    string[] lowMBO = GetMethodFromString(methods [1]);
                    gc.layers.AddLayer(lowMBO [0], lowMBO [1], lowMBO [2], 'L');
                }
                else if (methods.Length == 3)
                {
                    string[] mediumMBO = GetMethodFromString(methods [1]);
                    gc.layers.AddLayer(mediumMBO [0], mediumMBO [1], mediumMBO [2], 'M');

                    string[] lowMBO = GetMethodFromString(methods [2]);
                    gc.layers.AddLayer(lowMBO [0], lowMBO [1], lowMBO [2], 'L');
                }
            }
            else if (keywordItem.StartsWith("guess"))
            {
                string   guessOptionsStr = GetStringInParentheses(GetValueFromPair(keywordItem, checkEnclosed: true));
                string[] guessOptions    = guessOptionsStr.Split(new [] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
                foreach (string guessOption in guessOptions)
                {
                    gc.guessOptions.Add(guessOption);
                }
            }
            else if (keywordItem.StartsWith("geom"))
            {
                string   geomOptionsStr = GetStringInParentheses(GetValueFromPair(keywordItem, checkEnclosed: true));
                string[] geomOptions    = geomOptionsStr.Split(new [] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
                foreach (string geomOption in geomOptions)
                {
                    gc.geomOptions.Add(geomOption);
                }
            }
            else
            {
                foreach (string methodName in data.gaussianMethods)
                {
                    if (keywordItem.StartsWith(methodName))
                    {
                        string[] highMBO = GetMethodFromString(keywordItem);
                        gc.layers.AddLayer(highMBO [0], highMBO [1], highMBO [2], 'H');
                        break;
                    }
                }
            }
        }

        //Title
        List <string> titleLines = new List <string>();

        if (!gc.geomOptions.Contains("allcheck"))
        {
            while (lineNumber < maxLines)
            {
                line = lines [lineNumber].Trim();
                if (line != "")
                {
                    titleLines.Add(line);
                }
                else if (titleLines.Count != 0)
                {
                    break;
                }

                lineNumber++;
            }
        }
        gc.title = string.Join("\n", titleLines.ToArray());

        //Layer Charge/Multiplicity
        if (!gc.geomOptions.Contains("allcheck"))
        {
            while (lineNumber < maxLines)
            {
                line = lines [lineNumber].Trim();
                if (line != "")
                {
                    string[] cmStr = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                    int numLayersSpecified = cmStr.Length / 2;

                    for (int layerIndex = 0; layerIndex < numLayersSpecified; layerIndex++)
                    {
                        gc.layers.SetLayerCharge(gc.layers.layerNames[layerIndex], int.Parse(cmStr [2 * layerIndex]));
                        gc.layers.SetLayerMultiplicity(gc.layers.layerNames[layerIndex], int.Parse(cmStr [2 * layerIndex + 1]));
                    }

                    lineNumber++;
                    break;
                }
                lineNumber++;
            }
        }

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        int        charNum           = 0;
        int        phase             = 0;
        char       lineChar;
        int        pdbOption   = 0;
        string     linkType    = "";
        int        linkIndex   = 0;
        Vector3    position    = new Vector3();
        List <int> highAtoms   = new List <int>();
        List <int> mediumAtoms = new List <int>();
        List <int> lowAtoms    = new List <int>();

        //Atoms - AtomFromGaussianInputLine should be optimised
        if (!(gc.geomOptions.Contains("allcheck") && gc.geomOptions.Contains("check") && gc.geomOptions.Contains("checkpoint")))
        {
            while (lineNumber < maxLines)
            {
                line = lines [lineNumber].Trim();
                if (line == "")
                {
                    lineNumber++;
                    break;
                }

                Atom atom = Instantiate <Atom> (atomPrefab);
                atom.index = index;
                charNum    = 0;
                phase      = (int)atomPhase.ELEMENT;
                sb.Length  = 0;

                while (charNum <= line.Length)
                {
                    if (charNum == line.Length)
                    {
                        lineChar = ' ';
                    }
                    else
                    {
                        lineChar = line [charNum];
                    }


                    //Read element
                    if (phase == (int)atomPhase.ELEMENT)
                    {
                        if (lineChar == '-')
                        {
                            phase = (int)atomPhase.AMBER_NAME;
                        }
                        else if (lineChar == '(')
                        {
                            phase = (int)atomPhase.PDB;
                        }
                        else if (lineChar == ' ')
                        {
                            phase = (int)atomPhase.FROZEN;
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        atom.element = sb.ToString();

                        sb.Length = 0;
                    }
                    else if (phase == (int)atomPhase.AMBER_NAME)
                    {
                        if (lineChar == '-')
                        {
                            phase = (int)atomPhase.PARTIAL_CHARGE;
                        }
                        else if (lineChar == '(')
                        {
                            phase = (int)atomPhase.PDB;
                        }
                        else if (lineChar == ' ')
                        {
                            phase = (int)atomPhase.FROZEN;
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        atom.amberName = sb.ToString();
                        sb.Length      = 0;
                    }
                    else if (phase == (int)atomPhase.PARTIAL_CHARGE)
                    {
                        if (lineChar == '(')
                        {
                            phase = (int)atomPhase.PDB;
                        }
                        else if (lineChar == ' ')
                        {
                            phase = (int)atomPhase.FROZEN;
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        if (sb.Length > 0)
                        {
                            atom.partialCharge = float.Parse(sb.ToString());
                        }

                        sb.Length = 0;
                    }
                    else if (phase == (int)atomPhase.PDB)
                    {
                        if (lineChar == '=')
                        {
                            phase = (int)atomPhase.PDB_VALUE;
                        }
                        else if (lineChar == ')')
                        {
                            phase = (int)atomPhase.FROZEN;
                        }
                        else if (sb.Length == 5)
                        {
                            if (sb.ToString().ToUpper() == "PDBNA")
                            {
                                pdbOption = (int)pdbOptions.PDBNAME;
                            }
                            if (sb.ToString().ToUpper() == "RESNA")
                            {
                                pdbOption = (int)pdbOptions.RESNAME;
                            }
                            if (sb.ToString().ToUpper() == "RESNU")
                            {
                                pdbOption = (int)pdbOptions.RESNUM;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                    }
                    else if (phase == (int)atomPhase.PDB_VALUE)
                    {
                        if (lineChar == ',')
                        {
                            if (pdbOption == (int)pdbOptions.PDBNAME)
                            {
                                atom.pdbName = sb.ToString();
                            }
                            else if (pdbOption == (int)pdbOptions.RESNAME)
                            {
                                atom.residueName = sb.ToString();
                            }
                            else if (pdbOption == (int)pdbOptions.RESNUM)
                            {
                                atom.residueNumber = int.Parse(ToNumber(sb.ToString()));
                            }
                            phase = (int)atomPhase.PDB;
                        }
                        else if (lineChar == ')')
                        {
                            if (pdbOption == (int)pdbOptions.PDBNAME)
                            {
                                atom.pdbName = sb.ToString();
                            }
                            else if (pdbOption == (int)pdbOptions.RESNAME)
                            {
                                atom.residueName = sb.ToString();
                            }
                            else if (pdbOption == (int)pdbOptions.RESNUM)
                            {
                                atom.residueNumber = int.Parse(ToNumber(sb.ToString()));
                            }
                            phase = (int)atomPhase.FROZEN;
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;

                        //Frozen is optional, so this could be the X coordinate
                    }
                    else if (phase == (int)atomPhase.FROZEN)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else if (sb.Length == 1)
                            {
                                atom.frozen = int.Parse(sb.ToString());
                                phase       = (int)atomPhase.X;
                            }
                            else
                            {
                                position.x = float.Parse(sb.ToString());
                                phase      = (int)atomPhase.Y;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.X)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                position.x = float.Parse(sb.ToString());
                                phase      = (int)atomPhase.Y;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.Y)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                position.y = float.Parse(sb.ToString());
                                phase      = (int)atomPhase.Z;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.Z)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                position.z = float.Parse(sb.ToString());
                                atom.transform.position = position;
                                phase = (int)atomPhase.LAYER_NAME;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.LAYER_NAME)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                if (sb[0] == 'H')
                                {
                                    highAtoms.Add(index);
                                }
                                else if (sb[0] == 'M')
                                {
                                    mediumAtoms.Add(index);
                                }
                                else if (sb[0] == 'L')
                                {
                                    lowAtoms.Add(index);
                                }

                                phase = (int)atomPhase.LINK;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.LINK)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                linkType = sb.ToString();
                                phase    = (int)atomPhase.LINK_INDEX;
                            }
                        }
                        else if (lineChar == '-')
                        {
                            sb.Length = 0;
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }
                    else if (phase == (int)atomPhase.LINK_INDEX)
                    {
                        if (lineChar == ' ')
                        {
                            if (sb.Length == 0)
                            {
                                ;
                            }
                            else
                            {
                                linkIndex = int.Parse(sb.ToString());
                                gc.layers.AddLink(index, linkIndex, linkType);
                                charNum++;
                                continue;
                            }
                        }
                        else
                        {
                            sb.Append(lineChar);
                            charNum++;
                            continue;
                        }

                        sb.Length = 0;
                        charNum++;
                        continue;
                    }


                    charNum++;
                }
                atoms.AddAtom(atom);

                index++;
                lineNumber++;

                if (lineNumber % globalSettings.maxLinesToYield == 0)
                {
                    yield return(null);
                }
            }
        }

        gc.SetAtoms(atoms);
        gc.layers.SetHighAtoms(highAtoms);
        gc.layers.SetMediumAtoms(mediumAtoms);
        gc.layers.SetLowAtoms(lowAtoms);


        //Connectivity
        atoms.graph.SetAtoms(atoms);

        if (gc.geomOptions.Contains("connectivity"))
        {
            string[] splitConn;

            int connectionNum;
            int numConnections;

            int    connectionIndex0;
            int    connectionIndex1;
            double bondOrder;

            while (lineNumber < maxLines)
            {
                line = lines [lineNumber].Trim();
                if (line == "")
                {
                    break;
                }

                splitConn = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                connectionIndex0 = int.Parse(splitConn [0]) - 1;
                numConnections   = (splitConn.Length - 1) / 2;

                for (connectionNum = 0; connectionNum < numConnections; connectionNum++)
                {
                    connectionIndex1 = int.Parse(splitConn [connectionNum * 2 + 1]) - 1;
                    bondOrder        = double.Parse(splitConn [connectionNum * 2 + 2]);

                    atoms.graph.Connect(connectionIndex0, connectionIndex1, bondOrder);
                }

                lineNumber++;

                if (lineNumber % globalSettings.maxLinesToYield == 0)
                {
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }

        //Parameters
        List <string> parameterLines = new List <string>();

        while (lineNumber < maxLines)
        {
            line = lines [lineNumber].Trim();
            parameterLines.Add(line);
            lineNumber++;
        }

        IEnumerator iEnumerator = prmReader.ParametersFromPRMLines(parameterLines.ToArray(), atoms.graph.parameters);

        while (iEnumerator.MoveNext())
        {
        }

        atoms.graph.parameters.transform.parent = atoms.transform;
    }
コード例 #3
0
ファイル: PQRReader.cs プロジェクト: tam10/oniom_gui
    public IEnumerator AtomsFromPQRFile(string path, Atoms atoms, Atom atomPrefab)
    {
        atoms.globalSettings = globalSettings;
        atoms.setSourceFile(path);

        atoms.name = Path.GetFileName(path);
        gc         = Instantiate <GaussianCalculator> (GameObject.FindObjectOfType <PrefabManager>().gaussianCalculatorPrefab, atoms.transform);
        atoms.gaussianCalculator = gc;

        int     index = 0;
        int     residueNumber;
        int     offset;
        Vector3 position;

        string[]   splitLine;
        List <int> highAtoms = new List <int>();
        List <int> lowAtoms  = new List <int>();

        string[] lines = FileIO.Readlines(path, "#");
        for (lineNumber = 0; lineNumber < lines.Length; lineNumber++)
        {
            line = lines [lineNumber];
            if ((line.StartsWith("ATOM") || line.StartsWith("HETATM")))
            {
                Atom atom = Instantiate(atomPrefab, atoms.atomsHolder.transform);

                splitLine = line.Split(new [] { " " }, System.StringSplitOptions.RemoveEmptyEntries);

                //PDB
                atom.pdbName = line.Substring(12, 4).Trim();

                //Element
                if (data.pdbToElementDict.ContainsKey(atom.pdbName.ToUpper()))
                {
                    atom.element = data.pdbToElementDict [atom.pdbName];
                }
                else
                {
                    atom.element = atom.pdbName.Substring(0, 1);
                }

                //Residue
                atom.residueName = splitLine[3];

                if (line.StartsWith("HETATM") && !(atom.residueName == "WAT" || atom.residueName == "HOH"))
                {
                    highAtoms.Add(index);
                }
                else
                {
                    lowAtoms.Add(index);
                }

                //Chain ID is optional in PQR, but can also merge with residue number
                residueNumber = 0;
                offset        = 0;
                if (!int.TryParse(splitLine [4], out residueNumber))
                {
                    if (splitLine [4].Length == 1)
                    {
                        offset        = 1;
                        atom.chainID  = splitLine [4];
                        residueNumber = int.Parse(splitLine [5]);
                    }
                    else
                    {
                        atom.chainID  = splitLine [4].Substring(0, 1);
                        residueNumber = int.Parse(splitLine [4].Substring(1));
                    }
                }
                atom.residueNumber = residueNumber;

                //Position
                position   = new Vector3();
                position.x = float.Parse(splitLine[5 + offset]);
                position.y = float.Parse(splitLine[6 + offset]);
                position.z = float.Parse(splitLine[7 + offset]);
                atom.transform.position = position;

                atom.partialCharge = float.Parse(splitLine[8 + offset]);
                atom.vdwRadius     = float.Parse(splitLine[9 + offset]);

                atom.index = index;
                atoms.AddAtom(atom);
                //atom.resolution = globalSettings.ballResolution;
                //atom.transform.SetParent(atoms.atomsHolder.transform);
                //atoms.atomList.Add (atom);

                index++;
            }

            if (lineNumber % globalSettings.maxLinesToYield == 0)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }

        atoms.graph.SetAtoms(atoms);
        gc.SetAtoms(atoms);
        gc.layers.SetLowAtoms(lowAtoms);
        gc.layers.SetHighAtoms(highAtoms);

        yield return(null);
    }
コード例 #4
0
ファイル: PDBReader.cs プロジェクト: tam10/oniom_gui
    public IEnumerator AtomsFromPDBFile(string path, Atoms atoms, Atom atomPrefab, string alternateLocationID = "A")
    {
        atoms.globalSettings = globalSettings;
        atoms.setSourceFile(path);

        atoms.name = Path.GetFileName(path);
        gc         = Instantiate <GaussianCalculator> (GameObject.FindObjectOfType <PrefabManager>().gaussianCalculatorPrefab, atoms.transform);
        atoms.gaussianCalculator = gc;

        string     element;
        Vector3    position;
        string     chargeStr;
        List <int> highAtoms = new List <int>();
        List <int> lowAtoms  = new List <int>();

        int index = 0;

        string[] lines = FileIO.Readlines(path, "#");
        for (lineNumber = 0; lineNumber < lines.Length; lineNumber++)
        {
            line = lines [lineNumber];
            if (
                (
                    line.StartsWith("ATOM") ||
                    line.StartsWith("HETATM")
                ) && (
                    line [16].ToString() == " " ||
                    line [16].ToString() == alternateLocationID
                    ))
            {
                Atom atom = Instantiate(atomPrefab, atoms.atomsHolder.transform);

                element = line.Substring(76, 2).Trim();

                //PDB
                atom.pdbName = line.Substring(12, 4).Trim();

                //Use PDB to get Atom
                if (element == string.Empty)
                {
                    //If 12th column is a letter, it is a metal
                    if (char.IsLetter(line [12]))
                    {
                        element      = line.Substring(12, 2).Trim();
                        atom.element = ToAlpha(element);
                    }
                    else
                    {
                        element      = line.Substring(12, 4).Trim();
                        atom.element = ToAlpha(element) [0].ToString();
                    }
                }
                else
                {
                    if (element.Length > 1)
                    {
                        atom.element = element.Substring(0, 1).ToUpper() + element.Substring(1).ToLower();
                    }
                    else
                    {
                        atom.element = element;
                    }
                }



                //Residue
                atom.residueName   = line.Substring(17, 3).Trim();
                atom.residueNumber = int.Parse(line.Substring(22, 4).Trim());
                atom.chainID       = line [21].ToString();

                if (line.StartsWith("HETATM") && !(atom.residueName == "WAT" || atom.residueName == "HOH"))
                {
                    highAtoms.Add(index);
                }
                else
                {
                    lowAtoms.Add(index);
                }

                //Position
                position   = new Vector3();
                position.x = float.Parse(line.Substring(30, 8));
                position.y = float.Parse(line.Substring(38, 8));
                position.z = float.Parse(line.Substring(46, 8));
                atom.transform.position = position;

                chargeStr = line [79].ToString();
                if (chargeStr != " ")
                {
                    if (line [78].ToString() == "-")
                    {
                        atom.formalCharge = -int.Parse(chargeStr);
                    }
                    else
                    {
                        atom.formalCharge = int.Parse(chargeStr);
                    }
                }

                atom.index = index;
                atoms.AddAtom(atom);

                index++;
            }

            if (lineNumber % globalSettings.maxLinesToYield == 0)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }

        atoms.graph.SetAtoms(atoms);
        gc.SetAtoms(atoms);
        gc.layers.SetLowAtoms(lowAtoms);
        gc.layers.SetHighAtoms(highAtoms);
        yield return(null);
    }