Esempio n. 1
0
def exportShifts2Sparky(molecule, fileName=None, onlyAssigned=1):
    """Export shifts to sparky format
    """

    if not molecule:
        return None
    #end if

    if not fileName:
        fileName = molecule.name + '.sparky'
    #end if

    f = open(fileName, 'w')

    count = 0
    for ac in allAtoms(molecule):
        #        shift = ac.resonances().value
        assigned = ac.isAssigned(resonanceListIdx=RESONANCE_LIST_IDX_ANY)
        if (onlyAssigned and assigned) or (not onlyAssigned):
            fprintf(f, '%-5s %-5s %-5s %10.3f %10.3f %7d\n',
                    ac._parent.shortName, ac.translate(SPARKY), ac.db.spinType,
                    ac.resonances().value,
                    ac.resonances().error, 1)
            count += 1
        #end if
    #end for
    f.close()

    nTmessage('==> exportShifts2Sparky: %-4d shifts   written to "%s"', count,
              fileName)
Esempio n. 2
0
def exportShifts2Sparky( molecule, fileName=None, onlyAssigned=1)   :
    """Export shifts to sparky format
    """

    if not molecule:
        return None
    #end if

    if not fileName:
        fileName = molecule.name + '.sparky'
    #end if

    f = open( fileName, 'w' )

    count = 0
    for ac in allAtoms( molecule ):
#        shift = ac.resonances().value
        assigned = ac.isAssigned(resonanceListIdx=RESONANCE_LIST_IDX_ANY)
        if (onlyAssigned and assigned) or (not onlyAssigned):
            fprintf(  f,'%-5s %-5s %-5s %10.3f %10.3f %7d\n',
                      ac._parent.shortName,
                      ac.translate(SPARKY),
                      ac.db.spinType,
                      ac.resonances().value,
                      ac.resonances().error,
                      1
                   )
            count += 1
        #end if
    #end for
    f.close()

    nTmessage('==> exportShifts2Sparky: %-4d shifts   written to "%s"', count, fileName)
Esempio n. 3
0
def restoreCoordinates( molecule, fileName, append = True ):
    """Restore coordinates from fileName
       Optionally append to existing settings
       Return self or None on error
    """
    if not os.path.exists( fileName ):
        io.error('restoreCoordinates: file "{0}" not found\n', fileName )
        return None
    #end if
    if not append:
        for atm in molecule.allAtoms():
            atm.coordinates = ntu.NTlist()
        #end for
    #end if
    #execfile(fileName);
    # 25 Sep 2007: Explicit coding, less memory, better:
    file = open(fileName, 'r')
    for line in file:
        exec(line)
    #end for
    file.close()
    #nTdebug('Molecule.restoreCoordinates: %s (%d)', fileName, self.modelCount)
    return molecule
#end def