コード例 #1
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUESelectRings
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Select all of the rings that have ATOMs selected.
 */
XtCallbackProc
XAUESelectRings( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    LOOP		lInternals, lAtoms;
    int		i;
    INTERNAL	iInt;
    UNIT		uUnit;
    VARARRAY	vaRings;
    ATOM		aFirst, aAtom;
    Widget		wTank;

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


    wTank = zwXAUETank( wCur );


    uUnit = uTankUnit((TANK)wTank);
    vaRings = vaVarArrayCreate(sizeof(INTERNAL));

    /* Find all of the rings in the UNIT and search through the */
    /* INTERNALs of the atom that the user selected for the INTERNAL */
    /* that represents the smallest ring the ATOM is in */

    GraphUtilFindAllSmallestRings(uUnit);

    lAtoms = lLoop((OBJEKT) uUnit, ATOMS );
    while ( (aFirst = (ATOM)oNext(&lAtoms)) ) {
        if ( !bAtomFlagsSet( aFirst, ATOMSELECTED ) )
            continue;
        lInternals = lLoop((OBJEKT) aFirst, INTERNALS );
        while ( (iInt = (INTERNAL)oNext(&lInternals)) ) {
            if ( iInternalType(iInt) == INTERNALRING ) {
                VarArrayAdd( vaRings, (GENP)&iInt );
            }
        }
    }

    for ( i=0; i<iVarArrayElementCount(vaRings); i++ ) {
        iInt = *PVAI( vaRings, INTERNAL, i );
        InternalRingLoopAtoms(iInt);
        MESSAGE(( "Ring size: %d\n", iInternalRingSize(iInt) ));
        while ( (aAtom = aInternalRingNextAtom(iInt)) ) {
            MESSAGE(( "Selecting atom: %s\n", sAtomName(aAtom) ));
            AtomSetFlags( aAtom, ATOMSELECTED );
        }
    }

    lAtoms = lLoop((OBJEKT) uUnit, ATOMS );
    BuildDestroyInternals(&lAtoms);
    VarArrayDestroy( &vaRings );

    TankRedisplayUnit((TANK)wTank);
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
コード例 #2
0
ファイル: ambmov.c プロジェクト: jmainpri/libmove3d
OBJEKT AMBER_loadPrep(char *file_prep)
{
	DICTIONARY      dUnits;
	DICTLOOP        dlLoop ;
	UNIT            uUnit = NULL;
	STRING          sName;
	LOOP            lResidues;
	RESIDUE         rRes;
	
	/* Read an AMBER PREP file into a dictionary.*/
	dUnits = dAmberReadPrepFile(file_prep);
	if ( dUnits != NULL )
	{
		dlLoop = ydlDictionaryLoop( dUnits );
		uUnit=(UNIT)yPDictionaryNext( dUnits, &dlLoop );
		strcpy( sName, sContainerName((CONTAINER) uUnit) );
		PrintInfo(( "Loaded UNIT: %s", sName ));
		/* Set the name for the UNIT */
		ContainerSetName( (CONTAINER) uUnit, sName );
		/* Set the name for the only residue in the unit */
		lResidues = lLoop( (OBJEKT)uUnit, RESIDUES );
		rRes = (RESIDUE)oNext(&lResidues);
		ContainerSetName( (CONTAINER) rRes, sName );    
		VariableSet( sName, (OBJEKT) uUnit );       /* adds 1 REF */
		return((OBJEKT)uUnit);
	}
	if (uUnit == NULL)
	PrintError( ("-- no UNIT  loaded \n"));
	return(NULL);
}
コード例 #3
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUEHideAllButSelection
 *
 *	Author:	Christian Schafmeister (1991)
 */
XtCallbackProc
XAUEHideAllButSelection( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    LOOP		lAtoms;
    ATOM		aAtom;
    UNIT		uUnit;
    Widget		wTank;

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


    wTank = zwXAUETank( wCur );


    uUnit = uTankUnit((TANK)wTank);

    if ( uUnit == NULL ) return NULL;
    lAtoms = lLoop((OBJEKT) uUnit, ATOMS );
    while ( (aAtom = (ATOM)oNext(&lAtoms)) ) {
        if ( !bAtomFlagsSet( aAtom, ATOMSELECTED ) ) {
            AtomSetFlags( aAtom, ATOMNOTDISPLAYED );
        }
    }
    TankRedisplayUnit((TANK) wTank );
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
コード例 #4
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUESelectedAtomsFlipChirality
 *
 *	Author:	Christian Schafmeister (1991)
 */
XtCallbackProc
XAUESelectedAtomsFlipChirality( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    UNIT		uUnit;
    LOOP		lAtoms;
    ATOM		aAtom;
    Widget		wTank;

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


    wTank = zwXAUETank( wCur );


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

    lAtoms = lLoop((OBJEKT) uUnit, ATOMS );
    while ( (aAtom = (ATOM)oNext(&lAtoms)) ) {
        if ( bAtomFlagsSet( aAtom, ATOMSELECTED ) ) {
            bBuildFlipChiralityFor( uUnit, aAtom );
        }
    }
    TankRedisplayUnit((TANK) wTank );
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
コード例 #5
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUEMarkBuilt
 *
 *	Author:	Christian Schafmeister (1991)
 */
XtCallbackProc
XAUEMarkBuilt( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    UNIT		uTemp;
    LOOP		lAtoms;
    Widget		wTank;
    ATOM		aAtom;

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


    wTank = zwXAUETank( wCur );
    uTemp = uTankUnit((TANK)wTank);
    lAtoms = lLoop((OBJEKT) uTemp, ATOMS );
    while ( (aAtom = (ATOM)oNext(&lAtoms)) ) {
        if ( bAtomFlagsSet( aAtom, ATOMSELECTED ) ) {
            AtomResetFlags( aAtom, ATOMPOSITIONDRAWN|ATOMNEEDSBUILD );
            AtomSetFlags( aAtom, ATOMPOSITIONKNOWN );
        }
    }
    TankRedisplayUnit((TANK)wTank);
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
コード例 #6
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUESelectMolecules
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Select all of the MOLECULEs that have ATOMs selected.
 */
XtCallbackProc
XAUESelectMolecules( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    UNIT		uUnit;
    LOOP		lAtoms, lSpan;
    ATOM		aFirst, aAtom;
    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 ) ) {

            lSpan = lLoop((OBJEKT) aFirst, SPANNINGTREE );
            while ( (aAtom = (ATOM)oNext(&lSpan)) ) {
                AtomSetFlags( aAtom, ATOMSELECTED|ATOMTOUCHED );
            }
        }
    }
    TankRedisplayUnit((TANK) wTank );
    DisplayerReleaseUpdates();
    PopCurrentPrintSink();
    return NULL;
}
コード例 #7
0
ファイル: select.c プロジェクト: choderalab/ambermini
/*
 *	SelectMoleculeWithAtom
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Select the molecule that contains the ATOM.
 *	Do this by generating a spanning tree.
 */
void
SelectMoleculeWithAtom( UNIT uUnit, ATOM aAtom, BOOL bOn )
{
LOOP		lSpan;

    lSpan = lLoop( (OBJEKT)aAtom, SPANNINGTREE );
    while ( (aAtom = (ATOM)oNext(&lSpan)) ) {
	if ( bOn ) AtomSetFlags( aAtom, ATOMSELECTED );
	else	AtomResetFlags( aAtom, ATOMSELECTED );
    }
}
コード例 #8
0
ファイル: select.c プロジェクト: choderalab/ambermini
/*
 *	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 );
    }
}
コード例 #9
0
ファイル: mol2File.c プロジェクト: swails/ambermini
static void
zMol2FileWriteContainer( MOL2WRITEt *pwPFile, CONTAINER cCont, int choice )
{
//const char      C_TERMINAL_PREFIX = 'C';
//const char      N_TERMINAL_PREFIX = 'N';
    const int       RESIDUE_NAME_LENGTH = 4;
    LOOP            lContents;
    ATOM            aAtom;
    char            *cPTemp;

    cPTemp = sContainerName(cCont);
    strncpy( pwPFile->sResidueName, cPTemp, RESIDUE_NAME_LENGTH );

    pwPFile->sResidueName[ RESIDUE_NAME_LENGTH ] = '\0';
    if ( strlen(cPTemp) > RESIDUE_NAME_LENGTH ) {
        VP0(( " Truncating residue name for PDB format: %s -> %s\n",
              sContainerName(cCont), pwPFile->sResidueName ));
    }
    /*   }
    */
    if ( iObjectType(cCont) == ATOMid ) {
        zMol2FileWriteAtomRecord( pwPFile, (ATOM)cCont, choice);
        pwPFile->iResidueSeq++;
    } else if ( iObjectType(cCont) == RESIDUEid ) {
        RESIDUE rRes = (RESIDUE) cCont;
        pwPFile->iResidueSeq = rRes->iTemp;
        if ( pwPFile->iResidueSeq == 0 )
            pwPFile->iResidueSeq = 1;
        lContents = lLoop( (OBJEKT)cCont, DIRECTCONTENTSBYSEQNUM );
        while ( (aAtom = (ATOM)oNext(&lContents)) ) {
            zMol2FileWriteAtomRecord( pwPFile, aAtom, choice);
        }
    } else if ( iObjectType(cCont) == MOLECULEid ) {
        lContents = lLoop( (OBJEKT)cCont, ATOMS );
        while ( (aAtom = (ATOM)oNext(&lContents)) ) {
            zMol2FileWriteAtomRecord( pwPFile, aAtom, choice );
        }
        pwPFile->iResidueSeq++;
    }
}
コード例 #10
0
ファイル: select.c プロジェクト: choderalab/ambermini
/*
 *	SelectEverything
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Select all of the ATOMs in the UNIT.
 */
void
SelectEverything( UNIT uUnit, BOOL bOn )
{
LOOP		lAtoms;
ATOM		aAtom;

    MESSAGE(( "Selecting everything.  Select=%s\n", sBOOL(bOn) ));
    lAtoms = lLoop( (OBJEKT)uUnit, ATOMS );
    while ( (aAtom = (ATOM)oNext(&lAtoms)) ) {
	if ( bOn ) AtomSetFlags( aAtom, ATOMSELECTED );
	else	AtomResetFlags( aAtom, ATOMSELECTED );
    }
}
コード例 #11
0
ファイル: residue.c プロジェクト: luolingqi/fragmap_2
/*
 *      ResidueDescribe
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *      Call the specific routine for the class to print a description 
 *      of the RESIDUE to the file fOut.
 *
 *      Arguments:
 *      oObject -       The object to describe.
 *
 */
void
ResidueDescribe( RESIDUE rResidue )
{
int             i;
LOOP            lContents;
OBJEKT          oObj;
STRING          sTemp;

    VP0(( "RESIDUE name: %s\n", rResidue->cHeader.sName ));
    if ( bResidueFlagsSet( rResidue, RESIDUEUNKNOWN ) ) 
        VP0(( "!!!This is an unknown residue!\n" ));
    VP0(( "RESIDUE sequence number: %d\n", 
                        iContainerSequence(rResidue) ));
    VP0(( "RESIDUE PDB sequence number: %d\n",
			iResiduePdbSequence(rResidue) ));
    VP0(( "Type: %s\n", 
	  sResidueTypeNameFromChar(cResidueType(rResidue)) ));
    if ( cResidueType(rResidue) == RESTYPESOLVENT ) {
	VP0(( "Solvent imaging atom: " ));
	if ( aResidueImagingAtom(rResidue) == NULL ) {
	    VP0(( "None.\n" ));
	} else {
	    VP0(( "%s\n", 
		sContainerDescriptor((CONTAINER)aResidueImagingAtom(rResidue),sTemp) ));
	}
    }	
    VP0(( "Connection atoms:\n" ));
     for ( i=0; i<MAXCONNECT; i++ ) {
        if ( bResidueConnectUsed(rResidue,i) ) {
            VP0(( " Connect atom %d: %s\n", i, 
                sContainerDescriptor( (CONTAINER)rResidue->aaConnect[i], sTemp ) ));
        }
    }
    if ( rResidue->vaImpropers ) {
	VP0(( "No improper torsions\n" ));
    } else {
	VP0(( "Improper torsions:\n" ));
    }
    BasicsResetInterrupt();
    VP0(( "Contents: \n" ));
    lContents = lLoop( (OBJEKT)rResidue, DIRECTCONTENTS );
    while ( oObj = oNext(&lContents ) ) {
        VP0(( "%s\n", sContainerDescriptor( (CONTAINER)oObj, sTemp ) ));
	if ( bBasicsInterrupt() ) {
	    BasicsResetInterrupt();
	    VP0(( "Interrupted\n" ));
	    break;
	}
    }
}
コード例 #12
0
ファイル: bio_2amber.c プロジェクト: jmainpri/libmove3d
OBJEKT AMBER_loadPrep(char*file_prep)
{
  /* version of function  oCmd_loadAmberPrep */

  DICTIONARY      dUnits;
  DICTLOOP        dlLoop ;
  UNIT            uUnit = NULL;
  STRING          sName;
  LOOP            lResidues;
  RESIDUE         rRes;

  /* Read an AMBER PREP file into a dictionary.*/

  dUnits = dAmberReadPrepFile(file_prep);

  if ( dUnits != NULL ) {
    dlLoop = ydlDictionaryLoop( dUnits );

      /* for move3d version only one UNIT with one residue loaded */

    uUnit=(UNIT)yPDictionaryNext( dUnits, &dlLoop );
    strcpy( sName, sContainerName((CONTAINER) uUnit) );
    printf( "Loaded UNIT: %s\n", sName );

                /* Set the name for the UNIT */

    ContainerSetName( (CONTAINER) uUnit, sName );

                /* Set the name for the only residue in the unit */

    lResidues = lLoop( (OBJEKT)uUnit, RESIDUES );
    rRes = (RESIDUE)oNext(&lResidues);
    ContainerSetName( (CONTAINER) rRes, sName );
    VariableSet( (char*)sName, (OBJEKT) uUnit );       /* adds 1 REF */
    
    if (uUnit != NULL)
      return((OBJEKT)uUnit);
    else{
      printf ("-- no UNIT  loaded \n");
      return(NULL);
    }
  }
  else
    return(NULL);
}
コード例 #13
0
ファイル: bio_2amber.c プロジェクト: jmainpri/libmove3d
OBJEKT 
AMBER_Combine(OBJEKT  objProt, OBJEKT objLig)
{
  // version of function oCmd_combine 

  UNIT            uCombined, uCurrent;
  LOOP            lTemp;
  RESIDUE         rRes = NULL;
  OBJEKT          oObj;


  /* add only one uCurrent unit (Ligand) to uCombined unit (Protein)  */

    uCombined = (UNIT)objProt;
    oObj = objLig;
    if ( iObjectType( oObj ) != UNITid ) {
      printf( "%s:  is type %s\n", 
	      "Ligand", sObjectType(oObj) );
    }
    uCurrent = (UNIT)objLig;
    printf( "  Ligand: %s\n", sContainerName((CONTAINER) uCurrent) );

    if ( uCombined == NULL ) {
      printf( "--- no Protein unit \n" );
    } else {
       printf( "Joining Protein and Ligand \n" );
      UnitJoin( uCombined, uCurrent );
    }

    if ( uCombined == NULL ) {
        printf( "No UNITS, so no combine performed\n" );
        return(NULL);
	}   

              /* Define PDB sequence */
     
    lTemp = lLoop( (OBJEKT)uCombined, RESIDUES );
    while ( rRes == (RESIDUE)oNext(&lTemp) ) {
        ResidueSetPdbSequence( rRes, iContainerSequence((CONTAINER) rRes) );
    }
   
    return((OBJEKT)uCombined);
}
コード例 #14
0
ファイル: residue.c プロジェクト: luolingqi/fragmap_2
/*
 *      ResidueCheck
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *      Check the RESIDUE and its contents as the whether or
 *      not calculations can be run on it.
 *
 *      Arguments:
 *              rRes -          Residue to check.
 *              iPErrors -      Add the number of errors found.
 *              iPWarnings -    Add the number of warnings found.
 */
void
ResidueCheck( RESIDUE rRes, int *iPErrors, int *iPWarnings )
{
LOOP            lContents;
CONTAINER       cCont;
STRING          sTemp;

        /* Print a warning if the residue is an unknown one */

    if ( bResidueFlagsSet( rRes, RESIDUEUNKNOWN ) ) {
        (*iPWarnings)++;
        VP0(( "Warning: Unknown residue: %s\n", 
                sContainerFullDescriptor( (CONTAINER)rRes, sTemp ) ));
    }

    lContents = lLoop( (OBJEKT)rRes, DIRECTCONTENTS );
    while ( cCont = (CONTAINER)oNext(&lContents) ) {
        ContainerCheck( cCont, iPErrors, iPWarnings );
    }
}
コード例 #15
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	XAUEPrintAllInternals
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	List all of the bonds, angles, and torsions that are on the
 *	selected ATOMs.
 */
XtCallbackProc
XAUEPrintAllInternals( Widget wCur, caddr_t PAppData, caddr_t PArg )
{
    UNIT		uUnit;
    ATOM		aAtom;
    LOOP		lSelected;
    LOOP		lTemp;
    ATOM		a1, a2, a3, a4;
    STRING		s1, s2, s3, s4;

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

    /* Define where the output should go */


    /* Get the UNIT being edited and put it */
    /* in an ASSOC to pass it to the command */
    /* handler */

    VP0(( "--- Bonds, angles, torsions of selected ATOMs\n" ));
    uUnit = zuXAUEUnit( wCur );
    lSelected = lLoop((OBJEKT) uUnit, ATOMS );
    LoopDefineVisibleAtoms( &lSelected, ATOMSELECTED );
    while ( (aAtom = (ATOM)oNext(&lSelected)) ) {
        VP0(( "Looking at atom: %s\n",
              sContainerFullDescriptor((CONTAINER)aAtom,s1) ));

        LOOPOVERALL( aAtom, BONDS, a1, ATOM, lTemp ) {
            LoopGetBond( &lTemp, &a1, &a2 );
            VP0(( "BOND: %s - %s\n",
                  sContainerFullDescriptor((CONTAINER)a1,s1),
                  sContainerFullDescriptor((CONTAINER)a2,s2) ));
        }
        LOOPOVERALL( aAtom, ANGLES, a1, ATOM, lTemp ) {
            LoopGetAngle( &lTemp, &a1, &a2, &a3 );
            VP0(( "ANGLE: %s - %s - %s\n",
                  sContainerFullDescriptor((CONTAINER)a1,s1),
                  sContainerFullDescriptor((CONTAINER)a2,s2),
                  sContainerFullDescriptor((CONTAINER)a3,s3) ));
        }
コード例 #16
0
ファイル: ambmov.c プロジェクト: jmainpri/libmove3d
OBJEKT AMBER_Combine(OBJEKT  objProt, OBJEKT objLig)
{
	UNIT            uCombined, uCurrent;
	LOOP            lTemp;
	RESIDUE         rRes = NULL;
	OBJEKT          oObj;
	uCombined = (UNIT)objProt;
	oObj = objLig;
	if ( iObjectType( oObj ) != UNITid ) 
	{
		PrintInfo(( "%s:  is type %s", "Ligand", sObjectType(oObj) ));
	}
	uCurrent = (UNIT)oCopy(oObj );
	PrintInfo(( "  Sequence: %s", sContainerName((CONTAINER) uCurrent) ));
	
	if ( uCombined == NULL ) 
	{
		printf( "Copying the first UNIT\n" );
		uCombined = uCurrent;
	} else 
	{
		printf( "Copied a subsequent UNIT\n" );
		printf( "Joining two UNITS \n" );
		UnitJoin( uCombined, uCurrent );
	}
	
	if ( uCombined == NULL ) 
	{
		printf( "No UNITS, so no combine performed\n" );
		return(NULL);
	}
	lTemp = lLoop( (OBJEKT)uCombined, RESIDUES );
	while ( rRes == (RESIDUE)oNext(&lTemp) ) 
	{
		ResidueSetPdbSequence( rRes, iContainerSequence((CONTAINER) rRes) );
	}
	
	return((OBJEKT)uCombined);
}
コード例 #17
0
ファイル: select.c プロジェクト: choderalab/ambermini
/*
 *	bSelectChainBetween
 *
 *	Author:	Christian Schafmeister (1991)
 *
 *	Select the shortest chain of ATOMs between aA and aB.
 *	Return FALSE if no chain was found.
 */
BOOL
bSelectChainBetween( UNIT uUnit, ATOM aA, ATOM aB, BOOL bOn )
{
LOOP		lSpan;
ATOM		aCur;

		/* Span out from aA looking for aB */

    lSpan = lLoop( (OBJEKT)aA, SPANNINGTREE );
    while ( (aCur = (ATOM)oNext(&lSpan)) ) {
	if ( aCur == aB ) break;
    }
    if ( aCur == NULL ) return(FALSE);

		/* Select the chain back to aA */

    for ( aCur = aB; aCur; aCur = aAtomBackSpan(aCur) ) {
	if ( bOn ) AtomSetFlags( aCur, ATOMSELECTED );
	else	AtomResetFlags( aCur, ATOMSELECTED );
    }
    return(TRUE);
}
コード例 #18
0
ファイル: xaUnitEditor.c プロジェクト: swails/ambermini
/*
 *	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;
}
コード例 #19
0
ファイル: residue.c プロジェクト: luolingqi/fragmap_2
/*
 *      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" ));
                }
            }
        }
    }
コード例 #20
0
ファイル: mol2File.c プロジェクト: swails/ambermini
void
Mol2Write( FILE *fOut, UNIT uUnit, int choice )
{

//      int             i, iResidueCount, iAtomCount = 0, iAtom, iBondCount, iCount;
    int             i, iResidueCount, iAtomCount = 0, iBondCount, iCount;
//`		int             j,k,l,m,n;
    int             j,k;
    LOOP            lContents,lTemp,lResidues;
    SAVERESIDUEt    *srPResidue;
    SAVECONNECTIVITYt *scPCon;
    MOL2WRITEt      pwFile;
    STRING     sTemp;
    char     *sName;
    ATOM       aAtom1,aAtom2;
    RESIDUE rRes1;
    BOOL   bPert,bFailedGeneratingParameters;
//		STRING sAtom1, sAtom2, sDesc;


    zMol2FileBegin( &pwFile, fOut );

    /* @<TRIPOS>MOLECULE Bloc */
    fprintf(fOut, "@<TRIPOS>MOLECULE\n") ;
    iResidueCount = zUnitIOAmberOrderResidues( uUnit );


    strcpy( sTemp, sContainerName((CONTAINER) uUnit));

    iCount = 0;
    bPert = FALSE;
    lTemp = lLoop((OBJEKT) uUnit, BONDS);
    while (oNext(&lTemp) != NULL)
        iCount++;

    iAtomCount = 0;
    lTemp = lLoop((OBJEKT) uUnit, ATOMS);
    while (oNext(&lTemp) != NULL)
        iAtomCount++;

    iBondCount = iCount;

    fprintf(fOut, "%s\n", sTemp) ;
    fprintf(fOut, "%5d %5d %5d     0     1 \n", iAtomCount,iBondCount,iResidueCount) ;
    fprintf(fOut, "SMALL\n");
    fprintf(fOut, "USER_CHARGES\n");



    /* @<TRIPOS>ATOM Bloc */
    fprintf(fOut, "@<TRIPOS>ATOM\n") ;

    srPResidue = PVAI(uUnit->vaResidues, SAVERESIDUEt, 0);
    for (i = 0; i < iResidueCount; srPResidue++, i++) {
        RESIDUE rRes = srPResidue->rResidue;
        rRes->iTemp = i + 1;
        zMol2FileWriteContainer( &pwFile, (CONTAINER) rRes, choice);
    }
    fprintf(fOut, "@<TRIPOS>BOND\n") ;

    /* Now generate the connectivity table */
    /* Inspired by zUnitIOBuildTables in unitio.c */

    /*zbUnitIOIndexBondParameters(plParameters, uUnit, bPert); */

    iAtomCount = 0;
    lTemp = lLoop((OBJEKT) uUnit, ATOMS);
    while (oNext(&lTemp) != NULL)
        iAtomCount++;

    if (iAtomCount) {
        uUnit->vaAtoms = vaVarArrayCreate(sizeof(SAVEATOMt));
        VarArraySetSize((uUnit->vaAtoms), iAtomCount);
        i = 0;


        lResidues = lLoop((OBJEKT) uUnit, DIRECTCONTENTSBYSEQNUM);
        while ((rRes1 = (RESIDUE) oNext(&lResidues)) != NULL) {
            zUnitDoAtoms(uUnit, NULL, rRes1, &i, &bFailedGeneratingParameters, bPert);
        }
    }

    iCount = 0;
    lTemp = lLoop((OBJEKT) uUnit, BONDS);
    while (oNext(&lTemp) != NULL)
        iCount++;
    uUnit->vaConnectivity = vaVarArrayCreate(sizeof(SAVECONNECTIVITYt));
    VarArraySetSize((uUnit->vaConnectivity), iCount);

    if (iCount) {
        i = 0;
        lTemp = lLoop((OBJEKT) uUnit, BONDS);
        scPCon = PVAI(uUnit->vaConnectivity, SAVECONNECTIVITYt, 0);
        while (oNext(&lTemp) != NULL) {
            /*LoopGetBond(&lTemp, &aAtom1, &aAtom2); */
            (*(&aAtom1))=(ATOM)(&lTemp)->oaObj[0] ;
            (*(&aAtom2))=(ATOM)(&lTemp)->oaObj[1] ;
            i++;
            scPCon++;
            fprintf(fOut, "%5d %5d %5d 1\n", i,(((CONTAINER)(aAtom1))->iTempInt),(((CONTAINER)(aAtom2))->iTempInt));
        }
    }


    fprintf(fOut, "@<TRIPOS>SUBSTRUCTURE\n") ;
    srPResidue = PVAI(uUnit->vaResidues, SAVERESIDUEt, 0);
    k=0;
    for (i = 0; i < iResidueCount; srPResidue++, i++) {
        ATOM aAtom;
        RESIDUE rRes = srPResidue->rResidue;
        j=0;
        sName = zMol2FileWriteResidueContainer( &pwFile, (CONTAINER) rRes);
        lContents = lLoop((OBJEKT)rRes, DIRECTCONTENTSBYSEQNUM );
        while((aAtom = (ATOM)oNext(&lContents)) )
            j=j+1 ;
        k=k+j;
        fprintf(fOut, "%7d %4s %14d ****               0 ****  **** \n", i+1, sName, k-j+1);

    }
}
コード例 #21
0
ファイル: residue.c プロジェクト: luolingqi/fragmap_2
        VP1(( "There is no atom in residue: %s with the name: %s.\n" ));
        VP1(( "--- No bond could be made to the missing atom.\n" ));
                }
            }
        }
    }

        /* Build the coordinates for ATOMs that do not have them */

    BuildFixInternals( rNew );

                /* Loop through all ATOMs looking for those that */
                /* do not have positions known and build externals */
                /* for them and neighbors that are bonded to them */

    lAtoms = lLoop( (OBJEKT)rNew, ATOMS );
    while ( aAtom = (ATOM)oNext(&lAtoms) ) {
        if ( !bAtomFlagsSet( aAtom, ATOMPOSITIONKNOWN ) ) {
            lSpan = lLoop( (OBJEKT)aAtom, SPANNINGTREE );
            LoopDefineInvisibleAtoms( &lSpan, ATOMPOSITIONKNOWN );

                        /* Look for a collision with an ATOM whos */
                        /* ATOMPOSITIONKNOWN flag is set */
            aSpan = NULL;
            while ( aTemp = (ATOM)oNext(&lSpan) ) {
                if ( aSpan == NULL ) aSpan = aTemp;
                if ( aLoopLastCollisionAtom(&lSpan) != NULL ) {
                    aSpan = aLoopLastCollisionAtom(&lSpan);
                    break;
                }
            }