Beispiel #1
0
        static void Main(string[] args)
        {
            atom[] atoms = new atom[6500];
            int counter = 0;

            try
            {   // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader("../../../1kam.pdb"))
                {
                    // Read the stream to a string, and write the string to the console.
                    while (sr.Peek() >= 0)
                    {

                        string line = sr.ReadLine();
                        if (line.Substring(0, 4) == "ATOM")
                        {

                            counter++;
                            atom temp = new atom();
                            temp.atomName = line.Substring(13,4);
                            temp.resName = line.Substring(17,3);
                            temp.resSeq = Int32.Parse(line.Substring(23, 4));
                            temp.xCoord = Decimal.Parse(line.Substring(31, 8));
                            temp.yCoord = Decimal.Parse(line.Substring(39, 8));
                            temp.zCoord = Decimal.Parse(line.Substring(47, 8));
                            atoms[counter] = temp;
                            Console.WriteLine("Atom # {0} name = {1} resName = {2} x={3} y={4} z={5}",counter, temp.atomName,temp.resName,temp.xCoord,temp.yCoord, temp.zCoord);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
Beispiel #2
0
        public readonly int AbsoluteNumber; // for ordering

        public ClueId(atom word, int number, int absolute)
        {
            Word           = word;
            Number         = number;
            AbsoluteNumber = absolute;
        }
Beispiel #3
0
 public void insertAattribute(LinkedList list, atom X, string inputAtt)
 {
     X.attribute = Double.Parse(inputAtt);
     list.Add(X);
 }
Beispiel #4
0
        static LinkedList input(StreamReader reader)
        {
            LinkedList list = new LinkedList();
            string     String, word = "", massString = "";
            int        mass;
            bool       atom = false, inorganic = false, organic = true, massCount = false;

            while ((String = reader.ReadLine()) != null)
            {
                if (String.Length != 0)
                {
                    for (int i = 0; i < String.Length; i++)
                    {
                        if (String[0] == '/')
                        {
                            break;
                        }

                        if ((Char.IsLetterOrDigit(String[i]) || String[i] == ',') && (massCount == false))   //счет digit
                        {
                            if (String[i] == ',')
                            {
                                atom = true; organic = false;
                            }
                            ;
                            word += String[i];
                        }
                        else
                        {
                            if (String[i] == '-' || massCount == true)
                            {
                                massCount = true;
                                if (Char.IsDigit(String[i]))
                                {
                                    if (massCount)
                                    {
                                        massString += String[i];
                                    }
                                    if (String[i + 1] == '*')
                                    {
                                        massCount = false;
                                    }
                                }
                            }
                            else
                            {
                                if (Char.IsLetter(word[0]))
                                {
                                    organic   = false;
                                    inorganic = true;
                                }
                                mass = int.Parse(massString);
                                if (inorganic)
                                {
                                    inorganic_matter X = new inorganic_matter(mass);
                                    X.insertAattribute(list, X, word);
                                }
                                if (atom)
                                {
                                    atom X = new atom(mass);
                                    X.insertAattribute(list, X, word);
                                }
                                if (organic)
                                {
                                    organic_matter X = new organic_matter(mass);
                                    X.insertAattribute(list, X, word);
                                }

                                word       = "";
                                massString = "";
                                atom       = false;
                                massCount  = false;
                                organic    = true;
                                inorganic  = false;
                            }
                        }
                    }
                }
            }
            return(list);
        }