/* * SelectResidueWithAtom * * Author: Christian Schafmeister (1991) * * Select the RESIDUE that contains the ATOM. */ void SelectResidueWithAtom( UNIT uUnit, ATOM aAtom, BOOL bOn ) { LOOP lAtoms; ATOM aCur; lAtoms = lLoop( (OBJEKT)cContainerWithin((CONTAINER)aAtom), ATOMS ); while ( (aCur = (ATOM)oNext(&lAtoms)) ) { if ( bOn ) AtomSetFlags( aCur, ATOMSELECTED ); else AtomResetFlags( aCur, ATOMSELECTED ); } }
/* * XAUESelectResidues * * Author: Christian Schafmeister (1991) * * Select all of the RESIDUES that have ATOMs selected. */ XtCallbackProc XAUESelectResidues( Widget wCur, caddr_t PAppData, caddr_t PArg ) { UNIT uUnit; LOOP lAtoms; ATOM aFirst; Widget wTank; PushCurrentPrintSink(ziXAUEPrintSink(wCur)); DisplayerAccumulateUpdates(); wTank = zwXAUETank( wCur ); uUnit = uTankUnit((TANK)wTank); if ( uUnit == NULL ) return NULL; /* First turn off the ATOMTOUCHED flags for all ATOMs */ ContainerResetAllAtomsFlags((CONTAINER) uUnit, ATOMTOUCHED ); /* Look over all the ATOMs that are selected and select */ /* all of the ATOMs within the RESIDUEs that they are */ /* part of. Use the ATOMTOUCHED to prevent duplicating */ /* work. */ lAtoms = lLoop((OBJEKT) uUnit, ATOMS ); while ( (aFirst = (ATOM)oNext(&lAtoms)) ) { if ( bAtomFlagsSet( aFirst, ATOMSELECTED ) && !bAtomFlagsSet( aFirst, ATOMTOUCHED ) ) { ContainerSetAllAtomsFlags( cContainerWithin(aFirst), ATOMSELECTED|ATOMTOUCHED ); } } TankRedisplayUnit((TANK) wTank ); DisplayerReleaseUpdates(); PopCurrentPrintSink(); return NULL; }
/* * 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" )); } } } }