Exemplo n.º 1
0
void
zMol2FileWriteAtomRecord( MOL2WRITEt *pwPFile, ATOM aAtom, int choice )
{
    pdb_record      p;
#ifdef DEBUG
    STRING          sElement;
#endif
    STRING          sName, sTemp, sTypeAt;

    p.pdb.atom.serial_num = pwPFile->iRecordNumber++;
    strcpy( p.pdb.atom.residue.name, pwPFile->sResidueName );

    strcpy( sName, sAtomType(aAtom) );
    strcpy( sTemp, sContainerName((CONTAINER)aAtom) );


    if (choice == 0) {
        strcpy( sTypeAt, sTemp);
        sTypeAt[1] = '\0';
        strcpy( p.pdb.atom.type_at, sTypeAt );
    }
    if (choice == 1) {
        strcpy( sTypeAt, sName);
        strcpy( p.pdb.atom.type_at, sTypeAt );
    }

    strcpy( p.pdb.atom.name, sTemp );

    MESSAGE(( "Element: |%s|   pdb_name=|%s|\n", sElement, sName ));

    p.pdb.atom.residue.chain_id = ' ';
    p.pdb.atom.residue.seq_num = pwPFile->iResidueSeq;
    p.pdb.atom.residue.insert_code=' ';
    /*    p.pdb.atom.alt_loc = ' ' ; */
    p.pdb.atom.x = dVX(&vAtomPosition(aAtom));
    p.pdb.atom.y = dVY(&vAtomPosition(aAtom));
    p.pdb.atom.z = dVZ(&vAtomPosition(aAtom));
    p.pdb.atom.occupancy = 1.0;
    p.pdb.atom.temp_factor = dAtomCharge(aAtom);
    p.pdb.atom.ftnote_num = 0;
    p.record_type = MOL2_ATOM;
    pdb_write_record( pwPFile->fPdbFile, &p, NULL, 0 );

}
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" ));
                }
            }
        }
    }