예제 #1
0
    def test_simplifyForFcFeature(self):
        'test simplify Specifically For Fc Feature'
        self.createSimpleFastProject()
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist()
        r1 = self.r1
        r2 = self.r2
#        r3 = self.r3
        atomPairs.append((r1.MG1, r2.MG1))
        atomPairs.append((r1.MG2, r2.MG1))
        atomPairs.append((r1.MG1, r2.MG2))
        atomPairs.append((r1.MG2, r2.MG2))

#        atomPairs.append((r2.HN, r2.MG1))
#        atomPairs.append((r2.HN, r2.MG2))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        if distanceRestraint.isValid:
            _distanceRestraintList.append(distanceRestraint)
        else:
            nTerror('Failed to initialize DR with %s' % atomPairs)
#        nTdebug("dr before: %s" % formatall(distanceRestraint))

        # Takes 4 simplification iterations.
        self.assertEqual(distanceRestraint.simplifyForFc(), DistanceRestraint.STATUS_SIMPLIFIED)
#        nTdebug("dr after 1: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(), DistanceRestraint.STATUS_SIMPLIFIED)
#        nTdebug("dr after 2: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(), DistanceRestraint.STATUS_SIMPLIFIED)
#        nTdebug("dr after 3: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(), DistanceRestraint.STATUS_NOT_SIMPLIFIED)
#        nTdebug("dr after 4: %s" % formatall(distanceRestraint)) # don't print as it contains error token.
        _x = "dr after 4: %s" % formatall(distanceRestraint)
예제 #2
0
    def test_Simplify(self):
        'test Simplify'
        self.createSimpleFastProject()

        y = self.r5 # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist((y.QE, y.H),
                           (y.QE, y.H)
                           )
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
#        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(), DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #3
0
    def test_Simplify(self):
        'test Simplify'
        self.createSimpleFastProject()

        y = self.r5  # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist((y.QE, y.H), (y.QE, y.H))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        #        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(),
                         DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #4
0
    def test_CombiToPseudoQuadruple(self):
        ' test combination to Pseudo 4 some.'        
#        'Simulate 1a24 1254.00     A    3    TYR    QR    A    8    GLN    QB'
        self.createSimpleFastProject()

        y = self.r5 # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist((y.QE, y.H),
                           (y.QD, y.H)
                           )
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
#        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(), DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #5
0
    def test_CombiToPseudoQuadruple(self):
        ' test combination to Pseudo 4 some.'
        #        'Simulate 1a24 1254.00     A    3    TYR    QR    A    8    GLN    QB'
        self.createSimpleFastProject()

        y = self.r5  # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist((y.QE, y.H), (y.QD, y.H))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        #        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(),
                         DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #6
0
    def test_CombiToPseudoDouble_2(self):
        'test_CombiToPseudoDouble_2'
#        'Simulate 1a24 1254.00     A    3    TYR    QD    A    8    GLN    QB'
        self.createSimpleFastProject()

#        e = self.r3 # GLN
        y = self.r4 # TYR
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist((y.HE1, y.HB2),
                           (y.HE2, y.HB2),
                           (y.HE1, y.HB3),
                           (y.HE2, y.HB3))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
#        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(), DistanceRestraint.STATUS_SIMPLIFIED)
예제 #7
0
    def test_CombiToPseudoDouble_2(self):
        'test_CombiToPseudoDouble_2'
        #        'Simulate 1a24 1254.00     A    3    TYR    QD    A    8    GLN    QB'
        self.createSimpleFastProject()

        #        e = self.r3 # GLN
        y = self.r4  # TYR
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist((y.HE1, y.HB2), (y.HE2, y.HB2), (y.HE1, y.HB3),
                           (y.HE2, y.HB3))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        #        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(),
                         DistanceRestraint.STATUS_SIMPLIFIED)
예제 #8
0
    def test_Simplify3(self):
        'test simplify 3'
        _help = """
        For 1a24
        783.00    A    20    PRO    QB    A    23    LEU    MD1   3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        783.01    A    20    PRO    QB    A    23    LEU    QD    3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        """
        self.createSimpleFastProject()

        y = self.r8 # LEU
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist((y.QD,  y.H),
                           (y.MD1, y.H)
                           )
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
#        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.removeDuplicateAtomPairs2(), DistanceRestraint.STATUS_REMOVED_DUPLICATE)
예제 #9
0
    def test_Simplify2(self):
        'test Simplify2'
        _help = """
        For 1a24
        783.00    A    20    PRO    QB    A    23    LEU    MD1   3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        783.01    A    20    PRO    QB    A    23    LEU    QD    3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        """
        self.createSimpleFastProject()

        y = self.r5 # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist((y.QE, y.H),
                           (y.QE, y.H)
                           )
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
#        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(), DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #10
0
    def test_Simplify3(self):
        'test simplify 3'
        _help = """
        For 1a24
        783.00    A    20    PRO    QB    A    23    LEU    MD1   3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        783.01    A    20    PRO    QB    A    23    LEU    QD    3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        """
        self.createSimpleFastProject()

        y = self.r8  # LEU
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist((y.QD, y.H), (y.MD1, y.H))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        #        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.removeDuplicateAtomPairs2(),
                         DistanceRestraint.STATUS_REMOVED_DUPLICATE)
예제 #11
0
    def test_Simplify2(self):
        'test Simplify2'
        _help = """
        For 1a24
        783.00    A    20    PRO    QB    A    23    LEU    MD1   3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        783.01    A    20    PRO    QB    A    23    LEU    QD    3.20    7.90    2.96    0.56    2.56    3.35    0.32    0.45    0.64    0    0    0
        """
        self.createSimpleFastProject()

        y = self.r5  # PHE
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist((y.QE, y.H), (y.QE, y.H))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        #        nTdebug("before: %r" % distanceRestraint  )
        self.assertEqual(distanceRestraint.simplify(),
                         DistanceRestraint.STATUS_NOT_SIMPLIFIED)
예제 #12
0
    def test_simplifyForFcFeature_2(self):
        'test simplify Specifically For Fc Feature 2'        
        # disfunctional as of yet
        self.createSimpleFastProject()
        _distanceRestraintList = self.project.distances.new(DR_LEVEL, status = 'keep')
        atomPairs = NTlist()
#        r1 = self.r1
        r2 = self.r2
#        r3 = self.r3
        atomPairs.append((r2.HN, r2.MG1))
        atomPairs.append((r2.MG2, r2.HN))

#        atomPairs.append((r2.HN, r2.MG1))
#        atomPairs.append((r2.HN, r2.MG2))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        _distanceRestraintList.append(distanceRestraint)
#        nTdebug("dr before: %s" % formatall(distanceRestraint))

        self.assertEqual(distanceRestraint.simplify(), DistanceRestraint.STATUS_SIMPLIFIED)
예제 #13
0
    def test_simplifyForFcFeature_2(self):
        'test simplify Specifically For Fc Feature 2'
        # disfunctional as of yet
        self.createSimpleFastProject()
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist()
        #        r1 = self.r1
        r2 = self.r2
        #        r3 = self.r3
        atomPairs.append((r2.HN, r2.MG1))
        atomPairs.append((r2.MG2, r2.HN))

        #        atomPairs.append((r2.HN, r2.MG1))
        #        atomPairs.append((r2.HN, r2.MG2))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        _distanceRestraintList.append(distanceRestraint)
        #        nTdebug("dr before: %s" % formatall(distanceRestraint))

        self.assertEqual(distanceRestraint.simplify(),
                         DistanceRestraint.STATUS_SIMPLIFIED)
예제 #14
0
    def test_simplifyForFcFeature(self):
        'test simplify Specifically For Fc Feature'
        self.createSimpleFastProject()
        _distanceRestraintList = self.project.distances.new(DR_LEVEL,
                                                            status='keep')
        atomPairs = NTlist()
        r1 = self.r1
        r2 = self.r2
        #        r3 = self.r3
        atomPairs.append((r1.MG1, r2.MG1))
        atomPairs.append((r1.MG2, r2.MG1))
        atomPairs.append((r1.MG1, r2.MG2))
        atomPairs.append((r1.MG2, r2.MG2))

        #        atomPairs.append((r2.HN, r2.MG1))
        #        atomPairs.append((r2.HN, r2.MG2))
        distanceRestraint = DistanceRestraint(atomPairs, 0.0, 5.0)
        if distanceRestraint.isValid:
            _distanceRestraintList.append(distanceRestraint)
        else:
            nTerror('Failed to initialize DR with %s' % atomPairs)
#        nTdebug("dr before: %s" % formatall(distanceRestraint))

# Takes 4 simplification iterations.
        self.assertEqual(distanceRestraint.simplifyForFc(),
                         DistanceRestraint.STATUS_SIMPLIFIED)
        #        nTdebug("dr after 1: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(),
                         DistanceRestraint.STATUS_SIMPLIFIED)
        #        nTdebug("dr after 2: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(),
                         DistanceRestraint.STATUS_SIMPLIFIED)
        #        nTdebug("dr after 3: %s" % formatall(distanceRestraint))
        self.assertEqual(distanceRestraint.simplifyForFc(),
                         DistanceRestraint.STATUS_NOT_SIMPLIFIED)
        #        nTdebug("dr after 4: %s" % formatall(distanceRestraint)) # don't print as it contains error token.
        _x = "dr after 4: %s" % formatall(distanceRestraint)
예제 #15
0
def importUpl( project, uplFile, convention, lower = 0.0 ):
    """
    Read Cyana upl file
    return a DistanceRestraintList or None on error
    """
    
    #print 'Convention: ' + convention
    
    maxErrorCount = 50
    errorCount = 0

    # check the molecule
    if not project or not project.molecule:
        nTerror("importUpl: initialize molecule first")
        return None
    #end if
    molecule = project.molecule
    # Sometimes set from other than CYANA coordinate file.
#    chainId = molecule.chains[0].name # assumed unkown rite?

    if not os.path.exists( uplFile ):
        nTerror('importUpl: file "%s" not found', uplFile)
        return None
    #end if

    _dir,name,_ext = nTpath( uplFile )
    result        = project.distances.new( name=name, status='keep')
    atomDict      = molecule.getAtomDict(convention)

    for line in AwkLike( uplFile, commentString="#", minNF=7 ):
#        if line.isComment():
##            nTdebug("Skipping upl file line with comment: [" + line.dollar[0] +']')
#            continue
#        if line.NF < 7:
##            nTdebug("Skipping upl file line with too few fields: [" + line.dollar[0] +']')
#            continue
        atmIdxList = [[1,3],[4,6]]
        atmList = []
#        i=0
        for atmIdx in atmIdxList:
#            nTdebug("Doing atmIdx: " + repr(atmIdx))
            t = (line.int(atmIdx[0]), line.dollar[atmIdx[1]])
            atm = None
            if atomDict.has_key(t):
                atm = atomDict[t]
#            atm = molecule.decodeNameTuple( (convention, None, line.int(atmIdx[0]), line.dollar[atmIdx[1]]),
#                                            fromCYANA2CING=True)
            if not atm:
                if errorCount <= maxErrorCount:
                    nTerror('Failed to decode for atom %s; line: %s', t, line.dollar[0] )
                if errorCount == maxErrorCount+1:
                    nTerror("And so on")
                errorCount += 1
#                i+=1
                continue
            atmList.append( atm )
#            i+=1
        if len(atmList) != 2:
            continue
        # Unpack convenience variables.
        atm1 = atmList[0]
        atm2 = atmList[1]
#        nTdebug("atom 1: " + repr(atm1))
#        nTdebug("atom 2: " + repr(atm2))
        upper = line.float(7)
        # ambiguous restraint, should be append to last one
        if upper == 0:
            result().appendPair( (atm1,atm2) )
            continue
        if not upper:
            nTerror("Skipping line without valid upper bound on line: [" + line.dollar[0]+']')
            continue



        r = DistanceRestraint( atomPairs= [(atm1,atm2)], lower=lower, upper=upper )
        result.append( r )
        # also store the Candid info if present
        if line.NF >= 9:
            r.peak = line.int( 9 )
        if line.NF >= 11:
            r.SUP = line.float( 11 )
        if line.NF >= 13:
            r.QF = line.float( 13 )
    #end for
    if errorCount:
        nTerror("Found number of errors importing upl file: %s" % errorCount)

#    nTmessage("Imported upl items: " + repr(len(result)))
    nTmessage('==> importUpl: new %s from "%s"', result, uplFile )
    return result