示例#1
0
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);
}
示例#2
0
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++;
    }
}
示例#3
0
static char *
zMol2FileWriteResidueContainer( MOL2WRITEt *pwPFile, CONTAINER cCont )
{
//const char      C_TERMINAL_PREFIX = 'C';
//const char      N_TERMINAL_PREFIX = 'N';
    const int       RESIDUE_NAME_LENGTH = 3;
//LOOP            lContents;
    char            *cPTemp;
    RESIDUE         rRes;

    cPTemp = sContainerName(cCont);
    strncpy( pwPFile->sResidueName, cPTemp, RESIDUE_NAME_LENGTH );
    /* The intentional side effect is to truncate long names. */
    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 ));
    }
    rRes = (RESIDUE) cCont;

    return(sContainerName(cCont));
}
示例#4
0
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);
}
示例#5
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 );

}
示例#6
0
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);
}
示例#7
0
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);
}
示例#8
0
/* Main function, write the Mol3 file */
void 
Mol3Write( FILE *fOut, UNIT uUnit, int choice ){
    int i,j,iResNumber = 0;
    VARARRAY  vaRes;
    STRING sName;
    char* cPTemp;

    Mol2Write( fOut, uUnit, choice );

    fprintf(fOut, "@<TRIPOS>HEADTAIL\n") ;

    /* Write the HEAD in the file */
    if ( aUnitHead(uUnit) != NULL ){
        iResNumber=(((CONTAINER)aUnitHead(uUnit))->cContainedBy)->iSequence;

        cPTemp = ((CONTAINER)aUnitHead(uUnit))->sName;
        strncpy( sName, cPTemp, 4 );
      
        if ( strlen(cPTemp) > 4 ) {
            VP0(( " Truncating residue name for PDB format: %s -> %s\n", ((CONTAINER)aUnitHead(uUnit))->sName, sName ));
            fprintf(fOut,"%s %d\n",sName,iResNumber);
        }
        else {
            fprintf(fOut,"%s %d\n",((CONTAINER)aUnitHead(uUnit))->sName,iResNumber);
        }
    }
    else {
        fprintf(fOut,"0 0\n");
    }

    /* Write the TAIL in the file */
    if ( aUnitTail(uUnit) != NULL ){
        iResNumber=(((CONTAINER)aUnitTail(uUnit))->cContainedBy)->iSequence;

        cPTemp = ((CONTAINER)aUnitTail(uUnit))->sName;
        strncpy( sName, cPTemp, 4 );

        if ( strlen(cPTemp) > 4 ) {
            VP0(( " Truncating residue name for PDB format: %s -> %s\n", ((CONTAINER)aUnitTail(uUnit))->sName, sName ));
            fprintf(fOut,"%s %d\n",sName,iResNumber);
        }
        else{
            fprintf(fOut,"%s %d\n",((CONTAINER)aUnitTail(uUnit))->sName,iResNumber);
        }
    }else{
        fprintf(fOut,"0 0\n");
    }

    fprintf(fOut,"@<TRIPOS>RESIDUECONNECT\n");

    /* Write Atoms Connect for every Residue */
    vaRes=uUnit->vaResidues;
    for (i = 0; i < iVarArrayElementCount((VARARRAY)vaRes); i++) {
        SAVERESIDUEt prRes = *PVAI(vaRes, SAVERESIDUEt, i);
        fprintf(fOut,"%d",prRes.iSequenceNumber);
        for (j = 0; j <= 5; j++) {
            if ( prRes.rResidue->aaConnect[j] != NULL ){
                cPTemp = sContainerName(prRes.rResidue->aaConnect[j]);
                strncpy( sName, cPTemp, 4 );
                if ( strlen(cPTemp) > 4 ) {
                    VP0(( " Truncating residue name for PDB format: %s -> %s\n", sContainerName(prRes.rResidue->aaConnect[j]), sName ));
                    fprintf(fOut," %s",sName);
                }else{
                    fprintf(fOut," %s",sContainerName(prRes.rResidue->aaConnect[j]) );
                }
            }else{
                fprintf(fOut," 0");
            }
        }
        fprintf(fOut,"\n");
    }
}
示例#9
0
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);

    }
}
示例#10
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" ));
                }
            }
        }
    }