Ejemplo n.º 1
0
def compare( project1, project2 ):
    """Compare the shifts of all equivalent atoms.
    """
    if project1 is None or project1.molecule is None:
        return True
    if project2 is None or project2.molecule is None:
        return True

    mol1 = project1.molecule
    mol2 = project2.molecule

    nTmessage('==> comparing %s and %s\n', mol1, mol2)

    mapMolecule(mol1, mol2)

    for atm1 in mol1.allAtoms():
        if atm1.has_key('delta'): del(atm1['delta'])
    #end for
    for atm1 in mol1.allAtoms():
        compareAtms(atm1, atm1.map)
    #end for

    # average; taken the values of directly bonded atoms into account
    for atm in mol1.allAtoms():
        average(atm)
    #end for

    # generate scripts
    mkYasaraMacro(mol1, 'delta', sprintf('yasara-%s-%s.mcr', project1.name, project2.name))
    mkYasaraMacro(mol1, 'deltaAverage', sprintf('yasara-%s-%s-averaged.mcr', project1.name, project2.name))
Ejemplo n.º 2
0
def compareShifts( projectA, projectB ):
    """Compare the shifts of the two molecules of both projects
    """
    # Loop through all the residues
    for res1 in projectA.molecule.allResidues():
        res2=res1.map
        #compare the two residues
        if res2 != None:
            # check if they are the same type
            if (res1.db.name == res2.db.name):
                identity = "(S)"
            else:
                identity = '(D)'
            #end if

            printf("\n==== %s %s ==== %s\n", res1.name, res2.name, identity)

            # loop through all the atoms of res1
            for a1 in res1.atoms:
                a2=a1.map #check if this atom exists in res2
                a1.delta   = None
                if a2 and (a1.isAssigned() and a2.isAssigned()):
                    a1.delta = a1.resonances().value - a2.resonances().value
                #end if
                
                # calc differences with potential prochiral 
                a1.pc = a1.proChiralPartner()
                if a1.pc: 
                    pc2 = a1.pc.map # atom of second set
                else:
                    pc2 = None
                #end if
                a1.deltaPC = None # delta with prochiral atom 
                if pc2 and (a1.isAssigned() and pc2.isAssigned()):
                    a1.deltaPC = a1.resonances().value - pc2.resonances().value
                #end if
            #end for
            
            for a1 in res1.atoms:
                a2=a1.map #check if this atom exists in res2
                doPrint = False
                swapText = ''
                if a1.delta:
                    if ((a1.isProton() and math.fabs( a1.delta ) >= limits[0]) or
                        (a1.isCarbon() and math.fabs( a1.delta ) >= limits[1]) or
                        (a1.isNitrogen() and math.fabs( a1.delta ) >= limits[2]) 
                       ):
                       doPrint = True
                       swapText = sprintf('%7.3f ', a1.delta)
                    #end if
                # check for altered assignment
                if a1.delta and a1.deltaPC and a1.pc.delta and a1.pc.deltaPC:
                    if (math.fabs( a1.deltaPC ) + math.fabs( a1.pc.deltaPC ) <  
                        math.fabs( a1.delta ) + math.fabs( a1.pc.delta )
                       ):
                       doPrint = True
                       swapText = sprintf("%7.3f >> Potential Swapped assignment %s and %s", a1.deltaPC, a1.map, a1.pc.map)
                #end if       
                if doPrint:
                    printf('%s  %s    %s    %7.3f  %s\n', identity, printatom( a1 ), printatom( a2 ), a1.delta, swapText)
Ejemplo n.º 3
0
def printatom( atm ):
    if atm.isStereoAssigned():
        ss = '(stereo)'
    else:
        ss = '()      '
    #end if
    return sprintf('%-12s %10.3f  %s', atm._Cname(1), atm.resonances().value, ss )
Ejemplo n.º 4
0
def getUniqueName(objectListWithNameAttribute, baseName, nameFormat = "%s_%d" ):
    """
    Return unique name or False on error.
    E.g. for ResonanceSources object in which the ResonanceList objects have a name attribute.

    nameFormat may be specified to receive a string and an integer argument.
    Works on any NTlist that has name attributes in each element.
    """
    nameList = objectListWithNameAttribute.zap( NAME_STR )
#    nTdebug("Already have names: %s" % str(nameList))

    nameDict = nTlist2dict(nameList)
    if not nameDict.has_key( baseName):
        return baseName
    i = 1
    while i < MAX_TRIES_UNIQUE_NAME: # This code is optimal unless number of objects get to 10**5.
        newName = sprintf( nameFormat, baseName, i)
        if not nameDict.has_key( newName ):
            return newName
        i += 1
Ejemplo n.º 5
0
def getUniqueName(objectListWithNameAttribute, baseName, nameFormat="%s_%d"):
    """
    Return unique name or False on error.
    E.g. for ResonanceSources object in which the ResonanceList objects have a name attribute.

    nameFormat may be specified to receive a string and an integer argument.
    Works on any NTlist that has name attributes in each element.
    """
    nameList = objectListWithNameAttribute.zap(NAME_STR)
    #    nTdebug("Already have names: %s" % str(nameList))

    nameDict = nTlist2dict(nameList)
    if not nameDict.has_key(baseName):
        return baseName
    i = 1
    while i < MAX_TRIES_UNIQUE_NAME:  # This code is optimal unless number of objects get to 10**5.
        newName = sprintf(nameFormat, baseName, i)
        if not nameDict.has_key(newName):
            return newName
        i += 1
Ejemplo n.º 6
0
    def updateGui(self, event=None):

        projOption = self.projOptionsSelect.get()
        buttons = self.buttonBar.buttons

        # Disable entries
        for e in [self.projEntry, self.pdbEntry, self.ccpnEntry, self.cyanaEntry, self.nameEntry]:
            e.configure(state='disabled')
        #end for

        if projOption == self.projectOptions[0]:
            # Enable entries
            self.projEntry.configure(state='normal')

            if (len(self.projEntry.get()) > 0):
                self.openProjectButton.enable()
                self.runButton.enable()
            else:
                self.openProjectButton.disable()
                self.runButton.disable()
            #end if

        elif projOption == self.projectOptions[1]:
            # Enable entries
            self.pdbEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.pdbEntry.get()) > 0 and len(self.nameEntry.get())  > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        elif projOption == self.projectOptions[2]:
            # Enable entries
            self.ccpnEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.ccpnEntry.get()) > 0 and len(self.nameEntry.get())  > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        elif projOption == self.projectOptions[3]:
            # Enable entries
            self.cyanaEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.cyanaEntry.get()) > 0 and len(self.nameEntry.get())  > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        self.projectStatus.clear()
        if not self.project:
            self.projectStatus.setText('No open project')
            self.closeProjectButton.setText('Close Project')
            self.closeProjectButton.disable()
        else:
            self.projectStatus.setText(self.project.format())
            self.closeProjectButton.enable()
            self.closeProjectButton.setText(sprintf('Close Project "%s"', self.project.name))
Ejemplo n.º 7
0
def compareNoeNetWork( projectA, projectB, verbose ):
    """
    Generate B-peakLists for NOEs of A not present in B.
    Mapping and NOE sorting should have been done before
    
    Expand the NOEs to/from pseudo atoms by using the set() method (already 
    present as the '.s' attribute).
    The sets should take care of the comparison of 'like' atoms;
    i.e. pseudo with real atoms
    """
    NTmessage('==> comparing NOEs %s with %s\n', projectA, projectB )

    prepareNOEs( projectA )
    prepareNOEs( projectB )
    
    count = 0

    for atmA1 in projectA.molecule.allAtoms():
        # check all the NOEs for this atom
        for atmA2 in atmA1.NOEs:

            if verbose:
                printf('Checking NOE %-40s : ', sprintf('(%s,%s)', atmA1, atmA2) )
            #end if
            
            atmB1 = atmA1.map
            atmB2 = atmA2.map
            found = False
            atmB1.setdefault('newNOEs', NTlist() )
            
            if atmB2 in atmB1.newNOEs:
                if verbose:  printf('Peak has been generated previously\n')
            else:
                # check all the possibilities of the set of atomB1
                for b1 in atmB1.s:
                    # A set comparison yields true if there is one or more common elements
                    if b1.NOEs == atmB2.s:
                        count += 1
                        found = True
                        if verbose: printf('Found NOE %s\n', sprintf('(%s,%s)', b1, atmB2.s) )
                        break
                    else:
                        pass
                    #end if
                #end for
            
                if (not found):
                    # generate an atmB1-atmB2 peak since this NOE (atmA1,atmA2) was not found in the B-set
                    # the reverse peak is accounted for by the (atmA2-atmA1) Noe
                    peak = atoms2peak( atmB1, atmB2, projectB.c13peaks, projectB.aropeaks, projectB.n15peaks )
                    if peak:
                        peak.xeasyColor = peakColor
                        count          += 1
                        atmB1.newNOEs.append( atmB2 )
                        if verbose:  printf('New %s\n', peak)
                    else: 
                        if verbose:  printf('Skipped because of lacking assignments\n')
                    #end if
                #end if
            #end if
        #end for
    #end for

    if verbose:
        NTmessage('==> Appended %d peaks\n', count )
Ejemplo n.º 8
0
    def updateGui(self, event=None):

        projOption = self.projOptionsSelect.get()
        buttons = self.buttonBar.buttons

        # Disable entries
        for e in [
                self.projEntry, self.pdbEntry, self.ccpnEntry, self.cyanaEntry,
                self.nameEntry
        ]:
            e.configure(state='disabled')
        #end for

        if projOption == self.projectOptions[0]:
            # Enable entries
            self.projEntry.configure(state='normal')

            if (len(self.projEntry.get()) > 0):
                self.openProjectButton.enable()
                self.runButton.enable()
            else:
                self.openProjectButton.disable()
                self.runButton.disable()
            #end if

        elif projOption == self.projectOptions[1]:
            # Enable entries
            self.pdbEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.pdbEntry.get()) > 0
                    and len(self.nameEntry.get()) > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        elif projOption == self.projectOptions[2]:
            # Enable entries
            self.ccpnEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.ccpnEntry.get()) > 0
                    and len(self.nameEntry.get()) > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        elif projOption == self.projectOptions[3]:
            # Enable entries
            self.cyanaEntry.configure(state='normal')
            self.nameEntry.configure(state='normal')

            if (len(self.cyanaEntry.get()) > 0
                    and len(self.nameEntry.get()) > 0):
                buttons[0].enable()
                buttons[1].enable()
            else:
                buttons[0].disable()
                buttons[1].disable()
            #end if
        #end if

        self.projectStatus.clear()
        if not self.project:
            self.projectStatus.setText('No open project')
            self.closeProjectButton.setText('Close Project')
            self.closeProjectButton.disable()
        else:
            self.projectStatus.setText(self.project.format())
            self.closeProjectButton.enable()
            self.closeProjectButton.setText(
                sprintf('Close Project "%s"', self.project.name))