Esempio n. 1
0
 static void SaveXyzCoordinates(TextWriter stream, Vector3[] coordinates, ref int residueNumber, ref int atomNumber)
 {
     foreach (Vector3 coordinate in coordinates)
     {
         AtomRecord record = new AtomRecord();
         record.XYZ                   = coordinate;
         record.Name                  = "XYZ";
         record.ResidueName           = "XYZ";
         record.Element               = Element.H;
         record.ResidueSequenceNumber = residueNumber++;
         record.Serial                = atomNumber++;
         stream.WriteLine(record.Text);
     }
 }
Esempio n. 2
0
        static void Save(TextWriter stream, char chainId, IAa residue, ref int atomNumber, ref int residueSequenceNumber)
        {
            foreach (IAtom atom in residue)
            {
                if (float.IsNaN(atom.Xyz.Length()) || atom.Element == Element.H && atom.Xyz == Vector3.Zero)
                {
                    continue;
                }

                AtomRecord record = new AtomRecord(atom, chainId, residue.Name.ToString(), residueSequenceNumber, atomNumber++);
                atomNumber %= 100000;
                switch (OutputPdbFormat)
                {
                case PdbFormat.DefaultPdbV3: break;

                case PdbFormat.BMRB: break;

                case PdbFormat.RosettaPdbV1:
                    string name = record.Name;
                    if (alternateAtomNamesByFormat_[OutputPdbFormat].TryGetValue(residue.Letter + "_" + name, out name) ||
                        alternateAtomNamesByFormat_[OutputPdbFormat].TryGetValue("X_" + name, out name))
                    {
                        record.Name = name;
                    }
                    break;

                default: throw new InvalidDataException();
                }
                stream.WriteLine(record.Text);
            }
            residueSequenceNumber++;
            residueSequenceNumber %= 10000;
            if (residueSequenceNumber == 0)
            {
                residueSequenceNumber++;
            }
        }