Exemplo n.º 1
0
            public static Element UpdateElement(string line)
            {
                line = (line + "                                                                                ").Substring(0, 80);
                if (Header.IsHeader(line))
                {
                    return(Header.FromString(line));                        // Title Section
                }
                if (Title.IsTitle(line))
                {
                    return(Title.FromString(line));                         // Title Section
                }
                if (Compnd.IsCompnd(line))
                {
                    return(Compnd.FromString(line));                        // Title Section
                }
                if (Source.IsSource(line))
                {
                    return(Source.FromString(line));                        // Title Section
                }
                if (Keywds.IsKeywds(line))
                {
                    return(Keywds.FromString(line));                        // Title Section
                }
                if (Expdta.IsExpdta(line))
                {
                    return(Expdta.FromString(line));                        // Title Section
                }
                if (Nummdl.IsNummdl(line))
                {
                    return(Nummdl.FromString(line));                        // Title Section
                }
                if (Author.IsAuthor(line))
                {
                    return(Author.FromString(line));                        // Title Section
                }
                if (Revdat.IsRevdat(line))
                {
                    return(Revdat.FromString(line));                        // Title Section
                }
                if (Jrnl.IsJrnl(line))
                {
                    return(Jrnl.FromString(line));                          // Title Section
                }
                if (Remark.IsRemark(line))
                {
                    return(Remark.FromString(line));                        // Title Section
                }
                if (Seqres.IsSeqres(line))
                {
                    return(Seqres.FromString(line));                        // Primary Structure Section
                }
                if (Seqadv.IsSeqadv(line))
                {
                    return(Seqadv.FromString(line));                        // Primary Structure Section
                }
                if (Helix.IsHelix(line))
                {
                    return(Helix.FromString(line));                         // Secondary Structure Section
                }
                if (Sheet.IsSheet(line))
                {
                    return(Sheet.FromString(line));                         // Secondary Structure Section
                }
                if (Site.IsSite(line))
                {
                    return(Site.FromString(line));                          // Miscellaneous Features Section
                }
                if (Cryst1.IsCryst1(line))
                {
                    return(Cryst1.FromString(line));                        // Crystallographic and Coordinate Transformation Section
                }
                if (Anisou.IsAnisou(line))
                {
                    return(Anisou.FromString(line));                        // Coordinate Section
                }
                if (Atom.IsAtom(line))
                {
                    return(Atom.FromString(line));                          // Coordinate Section
                }
                if (Endmdl.IsEndmdl(line))
                {
                    return(Endmdl.FromString(line));                        // Coordinate Section
                }
                if (Hetatm.IsHetatm(line))
                {
                    return(Hetatm.FromString(line));                        // Coordinate Section
                }
                if (Model.IsModel(line))
                {
                    return(Model.FromString(line));                         // Coordinate Section
                }
                if (Siguij.IsSiguij(line))
                {
                    return(Siguij.FromString(line));                        // Coordinate Section
                }
                if (Ter.IsTer(line))
                {
                    return(Ter.FromString(line));                           // Coordinate Section
                }
                if (Conect.IsConect(line))
                {
                    return(Conect.FromString(line));                        // Connectivity Section
                }
                if (Master.IsMaster(line))
                {
                    return(Master.FromString(line));                        // Bookkeeping Section
                }
                if (End.IsEnd(line))
                {
                    return(End.FromString(line));                           // Bookkeeping Section
                }
                if (line.Substring(0, 6) == "DBREF ")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SEQRES")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "MODRES")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "HET   ")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "HETNAM")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "FORMUL")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SSBOND")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "LINK  ")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "ORIGX1")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "ORIGX2")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "ORIGX3")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SCALE1")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SCALE2")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SCALE3")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "CISPEP")
                {
                    return(new Element(line));                                  // Connectivity Annotation Section
                }
                if (line.Substring(0, 6) == "HETSYN")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SEQADV")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SPRSDE")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "MTRIX1")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "MTRIX2")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "MTRIX3")
                {
                    return(new Element(line));
                }

                if (line.Substring(0, 6) == "MDLTYP")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SPLIT ")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "CAVEAT")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "OBSLTE")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "HYDBND")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SLTBRG")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "TVECT ")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "DBREF1")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "DBREF2")
                {
                    return(new Element(line));
                }
                if (line.Substring(0, 6) == "SIGATM")
                {
                    return(new Element(line));
                }

                HDebug.Assert(false);
                return(new Element(line));
            }
Exemplo n.º 2
0
        private Master _master; //bookkeeping

        public Pdb(string filepath)
        {
            string[] lines = File.ReadAllLines(filepath);
            string   recName;

            foreach (string line in lines)
            {
                recName = GetFromString(0, 5, line);

                switch (recName)
                {
                case "HEADER":
                    _header = new Header(
                        GetFromString(10, 49, line),
                        GetFromString(50, 58, line),
                        GetFromString(62, 65, line));
                    break;

                case "TITLE ":
                    _title.Add(new Title(
                                   TestCont(GetFromString(8, 9, line)),
                                   GetFromString(10, 79, line)));
                    break;

                case "CAVEAT":
                    _caveat.Add(new Caveat(
                                    TestCont(GetFromString(8, 9, line)),
                                    GetFromString(11, 14, line),
                                    GetFromString(19, 78, line)));
                    break;

                case "COMPND":
                    _compnd.Add(new Compnd(
                                    TestCont(GetFromString(7, 9, line)),
                                    GetFromString(10, 79, line)));
                    break;

                case "SOURCE":
                    _source.Add(new Source(
                                    TestCont(GetFromString(7, 9, line)),
                                    GetFromString(10, 78, line)));
                    break;

                case "KEYWDS":
                    _keywds.Add(new Keywds(
                                    TestCont(GetFromString(8, 9, line)),
                                    GetFromString(10, 78, line)));
                    break;

                case "EXPDTA":
                    _expdata.Add(new Expdata(
                                     TestCont(GetFromString(8, 9, line)),
                                     GetFromString(10, 78, line)));
                    break;

                case "NUMMDL":
                    _nummdl = new Nummdl(Convert.ToUInt32(GetFromString(10, 13, line)));
                    break;

                case "MDLTYP":
                    _mdltyp.Add(new Mdltyp(
                                    TestCont(GetFromString(8, 9, line)),
                                    GetFromString(10, 79, line)));
                    break;

                case "AUTHOR":
                    _author.Add(new Author(
                                    TestCont(GetFromString(8, 9, line)),
                                    GetFromString(10, 78, line)));
                    break;

                case "REVDAT":
                    _revdat.Add(new Revdat(
                                    Convert.ToUInt32(GetFromString(7, 9, line)),
                                    TestCont(GetFromString(10, 11, line)),
                                    GetFromString(13, 21, line),
                                    GetFromString(23, 26, line),
                                    Convert.ToInt32(GetFromString(31, 31, line)),
                                    GetFromString(39, 44, line),
                                    GetFromString(46, 51, line),
                                    GetFromString(53, 58, line),
                                    GetFromString(60, 65, line)));
                    break;

                case "JNRL  ":
                    _jrnl.Add(new Jrnl(GetFromString(12, 78, line)));
                    break;

                case "ATOM  ":

                    _atoms.Add(new Atom(
                                   Convert.ToUInt32(GetFromString(6, 10, line)),
                                   GetFromString(12, 15, line),
                                   Convert.ToChar(GetFromString(16, 16, line)),
                                   GetFromString(17, 19, line),
                                   Convert.ToChar(GetFromString(21, 21, line)),
                                   Convert.ToUInt32(GetFromString(22, 25, line)),
                                   Convert.ToChar(GetFromString(26, 26, line)),
                                   new Vector3(Convert.ToDouble(GetFromString(30, 37, line)),
                                               Convert.ToDouble(GetFromString(38, 45, line)),
                                               Convert.ToDouble(GetFromString(46, 53, line))),
                                   Convert.ToDouble(GetFromString(54, 59, line)),
                                   Convert.ToDouble(GetFromString(60, 65, line)),
                                   GetFromString(76, 77, line),
                                   TestCharge(GetFromString(78, 79, line)),
                                   false,
                                   new Color(255, 255, 255, 255)
                                   ));


                    break;

                case "HETATM":

                    _hetatoms.Add(new Atom(
                                      Convert.ToUInt32(GetFromString(6, 10, line)),
                                      GetFromString(12, 15, line),
                                      Convert.ToChar(GetFromString(16, 16, line)),
                                      GetFromString(17, 19, line),
                                      Convert.ToChar(GetFromString(21, 21, line)),
                                      Convert.ToUInt32(GetFromString(22, 25, line)),
                                      Convert.ToChar(GetFromString(26, 26, line)),
                                      new Vector3(Convert.ToDouble(GetFromString(30, 37, line)),
                                                  Convert.ToDouble(GetFromString(38, 45, line)),
                                                  Convert.ToDouble(GetFromString(46, 53, line))),
                                      Convert.ToDouble(GetFromString(54, 59, line)),
                                      Convert.ToDouble(GetFromString(60, 65, line)),
                                      GetFromString(76, 77, line),
                                      TestCharge(GetFromString(78, 79, line)),
                                      true,
                                      new Color(255, 255, 255, 255)
                                      ));
                    break;

                case "END   ":
                    Console.WriteLine("Finished reading!");
                    break;

                default:
                    //Console.WriteLine("Unknown type.");
                    break;
                }
            }
        }