/* * 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; }
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); }
/* * bSelectRingWithAtom * * Author: Christian Schafmeister (1991) * * Select the RINGs that contain the ATOM. * If there are no RINGs then return FALSE, otherwise TRUE. */ BOOL bSelectRingWithAtom( UNIT uUnit, ATOM aAtom, BOOL bOn ) { BOOL bFoundOne; ATOM aCur; INTERNAL iRing; LOOP lInternals, lAtoms; bFoundOne = FALSE; GraphUtilFindAllSmallestRings( uUnit ); /* Now check if the ATOM contains ring INTERNALs */ lInternals = lLoop( (OBJEKT)aAtom, INTERNALS ); while ( (iRing = (INTERNAL)oNext(&lInternals)) ) { if ( iInternalType(iRing) == INTERNALRING ) { bFoundOne = TRUE; InternalRingLoopAtoms(iRing); while ( (aCur = aInternalRingNextAtom(iRing)) ) { if ( bOn ) AtomSetFlags( aCur, ATOMSELECTED ); else AtomResetFlags( aCur, ATOMSELECTED ); } } } /* Destroy the INTERNALS */ lAtoms = lLoop( (OBJEKT)uUnit, ATOMS ); BuildDestroyInternals(&lAtoms); return(bFoundOne); }
/* * 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; }
/* * 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; }
/* * 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; }
/* * 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; }
/* * 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 ); } }
/* * 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 ); } }
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++; } }
/* * 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 ); } }
/* * 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; } } }
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); }
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); }
/* * 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 ); } }
/* * 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) )); }
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); }
/* * 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); }
/* * 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; }
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); } }
template <typename _ArgT> _return_t<_ArgT> operator()(_ArgT&& oArg) const{ auto & oNext = static_cast<const _next_t&>(*this); auto & oSuper = static_cast<const _super_t&>(*this); return oSuper(oNext(std::forward<_ArgT>(oArg))); }