Exemplo n.º 1
0
/*
 *	XAUEAddHydrogensBuildExternals
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Add missing hydrogens and build the external coordinates
 *	for the UNIT.
 */
XtCallbackProc
XAUEAddHydrogensAndBuildExternals( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    LOOP		lAtom, lSpan;
    ATOM		aAtom, aStart;
    UNIT		uUnit;
    Widget		wTank;
    int		iDum;

    PushCurrentPrintSink(ziXAUEPrintSink(wCur));
    DisplayerAccumulateUpdates();


    wTank = zwXAUETank( wCur );


    uUnit = uTankUnit((TANK)wTank);
    if ( uUnit == NULL ) return NULL;

    MESSAGE(( "Building external coordinates for the UNIT\n" ));

    /* Add hydrogens */

    ModelAddHydrogens( uUnit );

    /* Try to build geometries for simple rings */

    BuildInternalsForSimpleRings( uUnit );

    /* Assign internal coordinates for all internals that */
    /* include atoms that need building */

    lAtom = lLoop((OBJEKT) uUnit, ATOMS );
    BuildInternalsUsingFlags( &lAtom, ATOMPOSITIONDRAWN, 0,
                              ATOMNEEDSBUILD,
                              ATOMPOSITIONDRAWN );

    /* Build spanning trees for all atoms that need building */
    /* and build external coordinates for those atoms */

    lAtom = lLoop((OBJEKT) uUnit, ATOMS );
    while ( (aAtom = (ATOM)oNext(&lAtom)) ) {
        if ( bAtomFlagsSet( aAtom, ATOMNEEDSBUILD ) ) {

            /* Look for a collision with an ATOM that has */
            /* already been built */
            /* Then start building from there */

            lSpan = lLoop((OBJEKT) aAtom, SPANNINGTREE );
            LoopDefineVisibleAtoms( &lSpan, ATOMNEEDSBUILD );
            while ( oNext(&lSpan) );
            if ( iLoopInvisibleCollisionCount(&lSpan) > 0 ) {
                aStart = aLoopLastCollisionAtom(&lSpan);
                lSpan = lLoop((OBJEKT) aStart, SPANNINGTREE );
            } else {
                lSpan = lLoop((OBJEKT) aAtom, SPANNINGTREE );
            }
            LoopDefineVisibleAtoms( &lSpan, ATOMNEEDSBUILD );
            iDum = 0;	/* for purify */
            BuildExternalsUsingFlags( &lSpan, ATOMNEEDSBUILD, 0,
                                      ATOMPOSITIONKNOWN,
                                      ATOMNEEDSBUILD,
                                      &iDum, &iDum, &iDum, TRUE );
        }
    }

    /* Destroy all of the INTERNALs */

    lAtom = lLoop((OBJEKT) uUnit, ATOMS );
    BuildDestroyInternals( &lAtom );

    TankRedisplayUnit((TANK) wTank );
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
Exemplo n.º 2
0
/*
 *      ResidueMutate
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *      Mutate the RESIDUE (rOld) into the RESIDUE (rNew).
 *      Do this by superimposing the coordinates from rOld onto
 *      rNew, breaking all the bonds from rOld to other residues,
 *      and rejoining them to identically named atoms in rNew,
 *      then building the coordinates for the rest of the atoms in rNew.
 *      The new RESIDUE rNew should not be bonded to anything else, it
 *      should also have EXTERNAL coordinates defined, but no INTERNALS.
 *
 */
void
ResidueMutate( RESIDUE rNew, RESIDUE rOld )
{
LOOP            lAtoms, lSpan;
ATOM            aNew, aNeighbor, aOld, aAtom, aSpan, aTemp;
STRING          sTemp, sSpan;
int             i, iDum;
FLAGS		fBondFlags;

    MESSAGE(( "Mutating: %s to: %s\n", sContainerName( rOld ),
                sContainerName(rNew) ));

                /* Build internal coordinates for the new RESIDUE */

    lAtoms = lLoop( (OBJEKT)rNew, ATOMS );
    BuildInternalsUsingFlags( &lAtoms, 
			ATOMPOSITIONKNOWN, 
			0,
			0, 
			ATOMPOSITIONKNOWN,
			&iDum, &iDum, &iDum );

                /* Define the coordinates, and the flags */
                /* if there are bonds out of the old RESIDUE, break them */
                /* and rejoin them to identically named atoms in the new */
                /* RESIDUE */

    lAtoms = lLoop( (OBJEKT)rOld, ATOMS );
    FOREACH( aOld, ATOM, lAtoms ) {
        MESSAGE(( "Searching for atom in new residue with name: %s\n",
                        sContainerName(aOld) ));
        aNew = (ATOM)cContainerFindName( (CONTAINER)rNew, ATOMid,
                                             sContainerName(aOld) );
                                             
                /* If there is a cooresponding ATOM with the same name */
                /* then define its flags and coordinates */
                
        if ( aNew != NULL ) {
            MESSAGE(( "--- Found one\n" ));
            AtomSetPosition( aNew, vAtomPosition(aOld) );
            AtomDefineFlags( aNew, fAtomFlags(aOld) );
        } else {
            MESSAGE(( "--- No atom found\n" ));
        }

                /* Search for bonds out of the old RESIDUE */
        
        for ( i=0; i<iAtomCoordination(aOld); i++ ) {
            aNeighbor = aAtomBondedNeighbor( aOld, i );
	    MESSAGE(( "--- Looking at neighbor: %s\n",
			sContainerFullDescriptor( (CONTAINER)aNeighbor, sTemp ) ));
            if ( rOld != (RESIDUE)cContainerWithin(aNeighbor) ) {
                fBondFlags = fAtomBondFlags( aOld, i );
                AtomRemoveBond( aOld, aNeighbor );
                MESSAGE(( "Removing a bond to: %s\n",
                        sContainerFullDescriptor( (CONTAINER)aNeighbor, sTemp ) ));
                if ( aNew != NULL ) {
                    MESSAGE(( "--- And rejoining it to: %s\n",
                                sContainerFullDescriptor( (CONTAINER)aNew, sTemp ) ));
                    AtomBondToFlags( aNew, aNeighbor, fBondFlags );
                } else {
                    MESSAGE(( "--- Not rejoining it to anything.\n" ));
        VP1(( "There is no atom in residue: %s with the name: %s.\n" ));
        VP1(( "--- No bond could be made to the missing atom.\n" ));
                }
            }
        }
    }