コード例 #1
0
ファイル: Grid.cs プロジェクト: ivogabe/Docking
        void forEachBlockAndAtom(Action <Block, int> callback)
        {
            int   radius        = (int)Math.Ceiling(maxDistance * scale);
            float radiusSquared = maxDistance * maxDistance + dimension * dimension;

            for (int i = 0; i < moleculeA.Size; i++)
            {
                Vector vector = moleculeA.GetAtom(i);
                Block  block  = GetBlock(vector);

                for (int x = block.X - radius; x <= block.X + radius; x++)
                {
                    for (int y = block.Y - radius; y <= block.Y + radius; y++)
                    {
                        for (int z = block.Z - radius; z <= block.Z + radius; z++)
                        {
                            Block current = new Block(x, y, z);
                            if (vector.DistanceSquared(BlockCenter(current)) <= radiusSquared)
                            {
                                callback(current, i);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private Output(string fileName, Molecule moleculeA, Molecule moleculeB, Transformation transform, float value)
        {
            writer = new StreamWriter(File.Open(fileName, FileMode.Create));

            addRemark(new string [] { "Binding of " + moleculeA.FileName, "with " + moleculeB.FileName });
            addRemark(new string [] { "Energy between molecules: " + Utils.FloatToString(value) });
            addRemark(new string [] {
                "Transformation:",
                "rotate " + transform.RotationString(),
                "transpose "
                + Utils.FloatToString(transform.Transpose.X)
                + ", " + Utils.FloatToString(transform.Transpose.Y)
                + ", " + Utils.FloatToString(transform.Transpose.Z)
            });

            for (int i = 0; i < moleculeA.Size; i++)
            {
                addAtom(
                    moleculeA.IsHetAtm[i],
                    moleculeA.AtomId[i],
                    moleculeA.AtomNames[i],
                    moleculeA.AminoAcids[i],
                    'A',
                    moleculeA.AminoAcidIds[i],
                    moleculeA.X[i],
                    moleculeA.Y[i],
                    moleculeA.Z[i],
                    moleculeA.Charge[i],
                    moleculeA.Diameter[i]
                    );
            }
            for (int i = 0; i < moleculeB.Size; i++)
            {
                Vector vector = transform.Transform(moleculeB.GetAtom(i));
                addAtom(
                    moleculeB.IsHetAtm[i],
                    moleculeA.MaxAtomId + moleculeB.AtomId[i],
                    moleculeB.AtomNames[i],
                    moleculeB.AminoAcids[i],
                    'B',
                    moleculeA.MaxAminoAcidId + moleculeB.AminoAcidIds[i],
                    vector.X,
                    vector.Y,
                    vector.Z,
                    moleculeB.Charge[i],
                    moleculeB.Diameter[i]
                    );
            }
            for (int i = 0; i < moleculeA.Connections.Length; i++)
            {
                addConnect(moleculeA.Connections[i], 0);
            }
            for (int i = 0; i < moleculeB.Connections.Length; i++)
            {
                addConnect(moleculeB.Connections[i], moleculeA.MaxAtomId);
            }
            writer.Write("END");
            writer.Flush();
        }
コード例 #3
0
ファイル: Grid.cs プロジェクト: ivogabe/Docking
        public Grid(Molecule moleculeA, Molecule moleculeB)
        {
            scale = 1 / dimension;
            maxDistanceSquared = maxDistance * maxDistance;

            this.moleculeA = moleculeA;
            this.moleculeB = moleculeB;

            for (int i = 0; i < moleculeA.Size; i++)
            {
                Block block = GetBlock(moleculeA.GetAtom(i));
                if (block.X < minX)
                {
                    minX = block.X;
                }
                if (block.X > maxX)
                {
                    maxX = block.X;
                }
                if (block.Y < minY)
                {
                    minY = block.Y;
                }
                if (block.Y > maxY)
                {
                    maxY = block.Y;
                }
                if (block.Z < minZ)
                {
                    minZ = block.Z;
                }
                if (block.Z > maxZ)
                {
                    maxZ = block.Z;
                }
            }
            // Add small buffer to all edges
            int edge = (int)Math.Ceiling(4 * maxDistance * scale);

            minX -= edge;
            minY -= edge;
            minZ -= edge;
            maxX += edge;
            maxY += edge;
            maxZ += edge;

            rangeX = maxX - minX + 1;
            rangeY = maxY - minY + 1;
            rangeZ = maxZ - minZ + 1;

            blocks          = rangeX * rangeY * rangeZ;
            atomsInBlock    = new int[blocks];
            blockStartIndex = new int[blocks];
            int atomIndicesSize = 0;

            forEachBlockAndAtom((block, atom) => {
                atomsInBlock[GetIndex(block)]++;
                atomIndicesSize++;
            });
            int pos = 0;

            for (int i = 0; i < blocks; i++)
            {
                blockStartIndex[i] = pos;
                pos            += atomsInBlock[i];
                atomsInBlock[i] = 0;
            }
            atomIndices = new int[atomIndicesSize];
            forEachBlockAndAtom((block, atom) => {
                int i = GetIndex(block);
                atomIndices[blockStartIndex[i] + atomsInBlock[i]] = atom;
                atomsInBlock[i]++;
            });
        }