예제 #1
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)
예제 #2
0
def cyana2cing( name, convention ):
    """Read the data from the cyana directory and store in new project
    """
    
    printf("\n==> Opening Project %s\n", name )
    
    project = Project.open(name, 'new', verbose=False )
    from cing.Libs.disk import matchfilelist
    seqfile = matchfilelist( project.name +'/*.seq')[0]
    
    project.newMolecule( project.name, seqfile, convention, verbose=False )
    project.importXeasy( seqfile, project.name + '/all-final.prot', convention )
    parseCyanaStereoFile( project, project.name + '/finalstereo.cya', convention )
    
    project.c13peaks = project.importXeasyPeaks( seqfile, project.name + '/all-final.prot', project.name + '/c13.peaks', convention )
    project.aropeaks = project.importXeasyPeaks( seqfile, project.name + '/all-final.prot', project.name + '/aro.peaks', convention )
    project.n15peaks = project.importXeasyPeaks( seqfile, project.name + '/all-final.prot', project.name + '/n15.peaks', convention )
    project.upl      = project.importUpl( project.name +'/final.upl', convention )
# comment because of crash in export and not needed anyway
#    project.aco      = project.importAco( project.name +'/talos.aco', convention )
    
    print project.format()
    return project
예제 #3
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 )
예제 #4
0
def checkAssignments( project ):
    """
    Check assignments for potential trivial errors
    """
    if project == None: return
    
    printf("==> Assignment check Project %s\n", project )
    
    for atm in project.molecule.allAtoms():
        if atm.isAssigned():
            # Check database
            av = atm.db.shift.average
            sd = atm.db.shift.sd
        
            #print atm, atm.db.pseudo
            
            # Check the shift against the database
            if (math.fabs(atm.resonances().value - av) > 3.0*sd):
                printf('SHIFT                         %s: more than 3*sd away from average\n', atm )
            #end if
        
            # Check if not both realAtom and pseudoAtom are assigned
            if atm.hasPseudoAtom() and atm.pseudoAtom().isAssigned():
                printf('MULTIPLE_ASSIGNMENT           %s: also has %s assigned\n', atm, atm.pseudoAtom() )
            #end if
            
            # Check if not pseudoAtom and realAtom are assigned
            if atm.isPseudoAtom():
                for a in atm.realAtoms():
                    if a.isAssigned():
                        printf('MULTIPLE_ASSIGNMENT          %s: also has %s assigned\n', atm, a )
                    #end if
                #end for
            #end if
            
            # Check if all realAtoms are assigned in case there is a pseudoatom
            if atm.hasPseudoAtom():
                ratms = atm.pseudoAtom().realAtoms()
                allAssigned = True
                for a in ratms:
                    if not a.isAssigned():
                        printf('MISSING_PROTON_ASSIGNMENT     %s: expected also %s to be assigned\n', atm, a )
                        allAssigned = False
                    #end if
                #end for
                
#                 if len( ratms ) == 2 and allAssigned and ratms[0].resonances().value > ratms[1].resonances().value:
#                         printf('SWAPPED_PROTON_ASSIGNMENTS    %s: and %s\n', ratms[0], ratms[1] )
#                 #end if                    
            #end if
            
            # Check for protons with unassigned heavy atoms
            if atm.db.spinType == '1H':
                heavyAtm = atm.topology()[0]
                if not heavyAtm.isAssigned():
                    printf('MISSING_HEAVY_ATOM_ASSIGNMENT %s: expected %s to be assigned\n', atm, heavyAtm )
                #end if
            #end if
            
            pc = atm.proChiralPartner()
            if removeStereo and pc and not (atm.hasProperties('isMethyl') or atm.hasProperties('isMethylProton')):
                # check the order and the value of resonances; i.e. HB2 < HB3
                if ( (atm < pc and atm.resonances().value > pc.resonances().value) or
                     (atm > pc and atm.resonances().value < pc.resonances().value)
                   ):
                    swapAssignments(tmp,pc)
                    printf( 'SWAPPED assignments           %s and %s\n',atm, pc)
                #end if
                atm.stereoAssigned = False
                pc.stereoAssigned = False