예제 #1
0
    def __init__(self,
                 num,
                 assign,
                 ppm,
                 width,
                 box,
                 shape,
                 volume,
                 intensity,
                 status,
                 isReading=True):

        self.num = returnInt(num, default=None)
        self.volume = self.returnFloat(volume)
        self.intensity = self.returnFloat(intensity)
        self.status = returnInt(status, default=None)
        self.shape = shape[:]

        self.assign = []
        self.ppm = []
        self.width = []  # In ppm!!
        self.box = []  # In ppm!!

        for i in range(0, len(assign)):
            self.ppm.append(self.returnFloat(ppm[i]))
            self.width.append(self.returnFloat(width[i]))
            self.box.append(self.returnFloat(box[i]))

            # Get rid of ?, when reading
            if isReading and assign[i] == '?':
                assign[i] = None

            self.assign.append(assign[i])
예제 #2
0
    def __init__(self,
                 parent,
                 serial,
                 atomName,
                 resName,
                 chainId,
                 seqCode,
                 x,
                 y,
                 z,
                 segId,
                 insertionCode=defaultSeqInsertCode):

        self.parent = parent
        self.serial = returnInt(serial)
        self.atomName = string.strip(atomName)
        self.resName = string.strip(resName)
        self.chainId = chainId
        self.seqCode = returnInt(seqCode)
        self.x = returnFloat(x)
        self.y = returnFloat(y)
        self.z = returnFloat(z)
        self.segId = string.strip(segId)
        self.insertionCode = insertionCode

        if not self.segId:
            self.segId = self.chainId
예제 #3
0
    def __init__(self,
                 serial,
                 atomName,
                 seqCode,
                 resName,
                 chainId,
                 x,
                 y,
                 z,
                 insertionCode=defaultSeqInsertCode,
                 refChainId=None,
                 verbose=False):

        self.serial = returnInt(serial, verbose=verbose)
        self.atomName = atomName.strip()
        self.seqCode = returnInt(seqCode, verbose=verbose)
        self.resName = resName.strip()
        self.chainId = chainId
        self.x = returnFloat(x, default=None, verbose=verbose)
        self.y = returnFloat(y, default=None, verbose=verbose)
        self.z = returnFloat(z, default=None, verbose=verbose)
        self.segId = ''
        self.insertionCode = insertionCode

        if refChainId:
            self.refChainId = refChainId
        else:
            self.refChainId = chainId
예제 #4
0
    def __init__(self,
                 num,
                 ppm,
                 colour,
                 userCode,
                 volume,
                 volumeError,
                 intCode,
                 assign,
                 verbose=False,
                 comment=None,
                 textAssign=False):

        self.num = returnInt(num, default=None, verbose=verbose)
        self.volume = returnFloat(volume, default=None, verbose=verbose)
        self.volumeError = returnFloat(volumeError,
                                       default=None,
                                       verbose=verbose)
        self.colour = returnInt(colour, default=None, verbose=verbose)
        self.userCode = userCode
        self.intCode = intCode

        self.comment = comment
        self.textAssign = textAssign

        self.ppm = []
        self.assign = []
        self.ambiguousAssign = []

        for i in range(len(assign)):
            self.ppm.append(returnFloat(ppm[i], default=None, verbose=verbose))

            self.assign.append(self.getAssignmentValue(assign[i]))
예제 #5
0
    def read(self, verbose=0):

        if verbose == 1:
            print "Reading %s assignment file %s" % (self.format, self.name)

        fin = open(self.name, 'rU')

        # Read, look for first line
        line = fin.readline()

        while line:
            cols = line.split()

            if self.patt['emptyline'].search(line) or self.patt['hash'].search(
                    line):
                pass

            if len(cols) == 3:
                (ccpCode, seqId) = cols[0].split(self.residueSep)
                (void, spinSystemId) = cols[1].split(self.residueSep)
                reliability = cols[2][1]

                self.assignments.append(
                    MarsAssignment(returnInt(spinSystemId), returnInt(seqId),
                                   ccpCode, reliability))

            line = fin.readline()

        fin.close()
예제 #6
0
    def __init__(self,
                 serial,
                 atomName,
                 resName,
                 segId,
                 seqCode,
                 x,
                 y,
                 z,
                 insertionCode=defaultSeqInsertCode,
                 altLoc=defaultAltLoc,
                 chainId=None):

        self.serial = returnInt(serial)
        self.atomName = atomName.strip()
        self.resName = resName.strip()
        self.seqCode = returnInt(seqCode)
        self.x = returnFloat(x)
        self.y = returnFloat(y)
        self.z = returnFloat(z)
        self.insertionCode = insertionCode
        self.altLoc = altLoc

        self.segId = segId.strip()

        if chainId == None:
            self.chainId = self.segId
            if not self.chainId:
                self.chainId = defaultMolCode
        else:
            self.chainId = chainId
예제 #7
0
    def __init__(self, parent, atomSerial, x, y, z, atomType, massDiff, charge,
                 Hcount, stereoCare, valence):

        self.parent = parent
        self.parent.numAtoms -= 1

        self.serial = atomSerial

        self.x = returnFloat(x, verbose=0)
        self.y = returnFloat(y, verbose=0)
        self.z = returnFloat(z, verbose=0)
        """
    entry in periodic table or L for atom list, 
    A, Q, * for unspecified atom, and LP for 
    lone pair, or R# for Rgroup label
    """

        atomType = string.strip(atomType)

        if atomType in ['A', 'Q', '*']:
            atomType = None
        elif atomType == 'LP':
            atomType = None
            #atomType = 'lone pair' TODO TODO can't handle this yet

        self.atomType = atomType
        """
    -3, -2, -1, 0, 1, 2, 3, 4 
    (0 if value beyond these limits)
    """

        self.massDiff = returnInt(massDiff, verbose=0)
        """
    0 = uncharged or value other than these,
    1 = +3, 2 = +2, 3 = +1,  
    4 = doublet radical, 5 = -1, 6 = -2, 7 = -3
    """

        chargeCode = returnInt(charge, verbose=0)
        self.charge = [0, 3, 2, 1, 'dr', -1, -2, -3][chargeCode]
        """
    1 = H0, 2 = H1, 3 = H2, 4 = H3, 5 = H4
    """
        self.Hcount = returnInt(Hcount, verbose=0) - 1
        """
    0 = ignore stereo configuration of this 
    double bond atom, 1 = stereo 
    configuration of double bond atom 
    must match        
    """
        self.stereoCare = returnInt(stereoCare, verbose=0)
        """
    0 = no marking (default) 
    (1 to 14) = (1 to 14) 15 = zero valence
    """
        self.valence = returnInt(valence, verbose=0)
예제 #8
0
    def setAtomMembers(self, chainCode, seqCode1, atomName1, seqCode2,
                       atomName2):

        self.items.append(ModuleConstraintItem())

        self.items[-1].members.append(
            ModuleConstraintMember(chainCode, returnInt(seqCode1),
                                   string.upper(atomName1)))
        self.items[-1].members.append(
            ModuleConstraintMember(chainCode, returnInt(seqCode2),
                                   string.upper(atomName2)))
예제 #9
0
    def __init__(self, Id, origId, patt=None, format=None):

        self.Id = returnInt(Id)

        if origId != None:
            self.origId = returnInt(origId)
        else:
            self.origId = None

        self.items = []
        self.patt = patt
        self.format = format
예제 #10
0
  def __init__(self,serial,chainId,atomName,resName,seqCode,x,y,z, insertionCode = defaultSeqInsertCode):
  
    self.serial = returnInt(serial)
    self.atomName = atomName.strip()
    self.resName = resName.strip()
    self.seqCode = returnInt(seqCode)

    self.x = returnFloat(x)
    self.y = returnFloat(y)
    self.z = returnFloat(z)
    self.insertionCode = insertionCode

    self.chainId = chainId
예제 #11
0
  def __init__(self,serial,atomName,resName,segId,seqCode,segSeqCode,x,y,z, insertionCode = defaultSeqInsertCode,verbose=False):
  
    self.serial = returnInt(serial,verbose=verbose)
    self.atomName = string.strip(atomName)
    self.resName = string.strip(resName)
    self.seqCode = returnInt(seqCode,verbose=verbose)
    self.segSeqCode = returnInt(segSeqCode,verbose=verbose)
    self.x = returnFloat(x,default=None,verbose=verbose)
    self.y = returnFloat(y,default=None,verbose=verbose)
    self.z = returnFloat(z,default=None,verbose=verbose)
    self.insertionCode = insertionCode

    self.chainId = self.segId = string.strip(segId)
    if not self.chainId:
      self.chainId = defaultMolCode
예제 #12
0
파일: Pdb.py 프로젝트: fenglb/ccpnmr2.4
def getPdbChainInfo():

  """
  Read info on chain information of PDB entries
  """
  
  pdbChainInfoDict = {}
   
  dataLines = getReferenceTextFileFromHttp(pdbChainInfoUrl,pdbChainInfoFilePath,refText = "PDB entry chain information", isGzipped = True)
  
  for dataLine in dataLines:
  
    cols = dataLine.split()
    
    if cols and cols[0][0] == '>':
      
      (pdbCode,chainCode) = cols[0][1:].split("_")
      molType = cols[1][4:]
      chainLength = returnInt(cols[2][7:])
      molName = ' '.join(cols[3:])
      
      if not pdbChainInfoDict.has_key(pdbCode):
        pdbChainInfoDict[pdbCode] = {}
      
      pdbChainInfoDict[pdbCode][chainCode] = [chainLength,molName,None]
    
    else:
    
      pdbChainInfoDict[pdbCode][chainCode][2] = cols[0]
      
  return pdbChainInfoDict
예제 #13
0
 def setRdcData(self,value,error=0.00, energyCst=1.0, orientation=0):
 
   self.error = returnFloat(error)
   self.value = returnFloat(value)
   self.energyCst = returnFloat(energyCst)
   
   self.orientation = returnInt(orientation)
예제 #14
0
    def readDsspInfoFile(self, fileName):

        fin = open(fileName)
        lines = fin.readlines()
        fin.close()

        dataLine = False
        for line in lines:
            cols = line.split()

            if cols[0] == '#' and cols[1] == 'RESIDUE':
                dataLine = True

            elif dataLine:
                # Note; No insertion code?
                seqCodeStr = line[5:10]
                seqCodeStr = seqCodeStr.strip()
                if len(seqCodeStr) < 1:
                    # happens for PDB entry 1cjg for 2 residues
                    # and for 2k6q for 2 residues.
                    nTdebug("Skipping DSSP line for Vasco with empty seqCode string: " + line.strip()) 
                    continue                
                seqCode = returnInt(seqCodeStr)
                chainCode = line[11:12]
                secStruc = line[16:17]

                if not self.allSsInfo.has_key(chainCode):
                    self.allSsInfo[chainCode] = {}

                seqKey = (seqCode, ' ')

                if not self.allSsInfo[chainCode].has_key(seqKey):
                    self.allSsInfo[chainCode][seqKey] = []

                self.allSsInfo[chainCode][seqKey].append(secStruc)
예제 #15
0
    def setAtomMembers(self, chainCode, seqCode, resLabel, refAtomName):

        refAtom = self.cyanaLib.findAtom(resLabel, refAtomName)

        seqCode = returnInt(seqCode)

        if refAtom:

            if refAtom.bondedAtomSerials.count(0) != 3:
                print "  Error: invalid single atom %s (%s %s, chain '%s'). No or multiple bonded atoms" % (
                    refAtomName, resLabel, seqCode, chainCode)

            else:

                self.items.append(DyanaConstraintItem())

                self.items[-1].members.append(
                    DyanaConstraintMember(chainCode, seqCode, resLabel,
                                          refAtomName))

                atomSerial = refAtom.bondedAtomSerials[0]
                bondedAtom = self.cyanaLib.findAtomBySerial(
                    resLabel, atomSerial)

                self.items[-1].members.append(
                    DyanaConstraintMember(chainCode, seqCode, resLabel,
                                          bondedAtom.name))

        else:

            print "  Error: cannot write RDC restraint, atom %s for residue %s not found." % (
                refAtomName, resLabel)
예제 #16
0
    def __init__(self,
                 numPoints,
                 numPointsOrig,
                 valuePerPoint,
                 nucleus,
                 phase=None):

        self.numPoints = returnInt(numPoints)
        self.numPointsOrig = returnInt(numPointsOrig)
        self.valuePerPoint = returnFloat(valuePerPoint)
        self.nucleus = nucleus

        if phase:
            self.phase = returnFloats(phase)
        else:
            self.phase = 2 * [0.0]
예제 #17
0
    def __init__(self, parent, peakNum):

        self.peakNum = returnInt(peakNum)
        self.parent = parent

        self.assignments = []
        self.assignCombinations = []
예제 #18
0
 def __init__(self,serial,name,atomSerials):
 
   self.serial = returnInt(serial)
   self.name = name
   self.atomSerials = returnInts(atomSerials)
   self.atomNames = []
   self.atoms = []
예제 #19
0
    def read(self, isOutputFile=False, headerCols=None, verbose=0):

        if verbose == 1:
            print "Reading %s chemical shift list %s" % (self.format,
                                                         self.name)

        fin = open(self.name, 'rU')

        headerCols = []

        line = fin.readline()

        while line:

            if self.patt['emptyline'].search(line):

                line = fin.readline()
                continue

            #
            # Get the info...
            #

            cols = line.split()

            if cols[0].count('NUM'):
                headerCols = line.split()
                colLen = len(headerCols)

            elif len(cols) == colLen and not cols[0].count("-"):

                badShifts = False

                # These are fishy shifts, need to remove the *!
                if cols[0][0] == '*':
                    cols[0] = cols[0][1:]
                    badShifts = True

                seqCode = returnInt(cols[0], default=None, verbose=False)
                resLabel = cols[1]

                if seqCode != None:
                    self.seqCodeLabels[seqCode] = resLabel

                    for i in range(2, colLen):
                        atomName = headerCols[i]
                        value = returnFloat(cols[i],
                                            default=None,
                                            verbose=False)

                        # Ignore if value is 0.00. This is stupid but has to be done because format is set up this way.
                        if value != 0.00:

                            self.chemShifts.append(
                                self.shiftClass(self, value, atomName, seqCode,
                                                resLabel, self.defaultMolCode))

            line = fin.readline()

        fin.close()
예제 #20
0
def setOriginalData(format,parent,rawData,name,isUnique = True):

  #
  # Code to set original data in the data model as application data
  #

  if hasattr(rawData,name):

    keyword = 'orig' + name[0].upper() + name[1:]
    value = getattr(rawData,name)
    appDataClass = None
    
    if value != None:

      if type(returnInt(value,default=None,verbose=0)) == type(value):
        appDataClass = 'AppDataInt'
      elif type(returnFloat(value,default=None,verbose=0)) == type(value):
        appDataClass = 'AppDataFloat'
      elif type(returnLong(value,default=None,verbose=0)) == type(value):
        appDataClass = 'AppDataLong'
    
    if not appDataClass:
      appDataClass = 'AppDataString'
      value = str(value)
    
    if isUnique:
      setUniqueAppData(appDataClass,parent,format,keyword,value)
    else:
      appData = getattr(Implementation,appDataClass)(application = format,keyword = keyword,value = value)
      parent.addApplicationData(appData)

    return True

  return False
예제 #21
0
    def read(self, verbose=0):

        #
        # TODO TODO not sure if this is correct!!! Check!
        #

        if verbose == 1:
            print "Reading %s sequence file %s" % (self.format, self.name)

        self.sequences.append(PippSequence())

        seqCode = 1

        fin = open(self.name, 'rU')

        # Read, look for first line
        line = fin.readline()

        while line:
            cols = line.split()

            if len(cols) == 0 or self.patt['hash'].search(line):
                pass

            else:
                if len(cols) == 2:
                    seqCode = returnInt(cols[1])

                self.sequences[-1].elements.append(
                    PippSequenceElement(seqCode, cols[0]))
                seqCode += 1

            line = fin.readline()

        fin.close()
예제 #22
0
    def __init__(self, parent, atomSerial1, atomSerial2, bondType, bondStereo,
                 bondTopology):

        self.parent = parent
        self.parent.numBonds -= 1

        self.atomSerial1 = returnInt(atomSerial1, verbose=0)
        self.atom1 = self.parent.atoms[self.atomSerial1 - 1]

        self.atomSerial2 = returnInt(atomSerial2, verbose=0)
        self.atom2 = self.parent.atoms[self.atomSerial2 - 1]
        """
    1 = Single, 2 = Double, 
    3 = Triple, 4 = Aromatic, 
    5 = Single or Double, 
    6 = Single or Aromatic, 
    7 = Double or Aromatic, 8 = Any
    """

        bondTypeCode = returnInt(bondType, verbose=0)
        self.bondType = [
            'void', 'single', 'double', 'triple', 'aromatic', 'single/double',
            'single/aromatic', 'double/aromatic', 'unknown'
        ][bondTypeCode]
        """        
    Single bonds: 0 = not stereo, 
    1 = Up, 4 = Either, 
    6 = Down,
    
    Double bonds: 0 = Use x-, y-, z-coords 
    from atom block to determine cis or trans, 
    3 = Cis or trans (either) double bond
    """

        bondStereoCode = returnInt(bondStereo, verbose=0)
        if self.bondType == 'single':
            self.bondStereo = [None, 'up', None, None, 'either', None,
                               'down'][bondStereoCode]
        elif self.bondType == 'double':
            self.bondStereo = ['coordinates', None, None,
                               'either'][bondStereoCode]
        """        
    0 = Either, 1 = Ring, 2 = Chain        
    """

        bondTopologyCode = returnInt(bondTopology, verbose=0)
        self.bondTopology = ['either', 'ring', 'chain'][bondTopologyCode]
예제 #23
0
    def read(self, verbose=0):

        if verbose == 1:
            print "Reading %s sequence file %s" % (self.format, self.name)

        self.sequences.append(ShiftxSequence())

        fin = open(self.name, 'rU')

        headerCols = []

        # Read, look for first line
        line = fin.readline()

        colLen = None
        lastSeqCode = None

        while line:

            if self.patt['emptyline'].search(line):

                line = fin.readline()
                continue

            #
            # Get the info...
            #

            cols = line.split()

            if cols[0] == 'NUM' and not colLen:
                headerCols = line.split()
                colLen = len(headerCols)

            elif len(cols) == colLen and not cols[0].count("-"):

                # These are fishy shifts, need to remove the *!
                if cols[0][0] == '*':
                    cols[0] = cols[0][1:]

                seqCode = returnInt(cols[0])
                resLabel = cols[1]

                if lastSeqCode == None:
                    lastSeqCode = seqCode
                elif lastSeqCode != seqCode - 1:
                    for tmpSeqCode in range(lastSeqCode + 1, seqCode):
                        self.sequences[-1].elements.append(
                            ShiftxSequenceElement(tmpSeqCode, 'X'))
                    lastSeqCode = seqCode
                else:
                    lastSeqCode = seqCode

                self.sequences[-1].elements.append(
                    ShiftxSequenceElement(seqCode, resLabel))

            line = fin.readline()

        fin.close()
예제 #24
0
  def readGeneric(self,verbose = 0):

    if verbose == 1:
      print "Reading %s file %s" % (self.format,self.name)
      
    #
    # Read all information...
    #

    fin = open(self.name, 'rU')
    line = fin.readline()
    
    triposSection = None

    while line:
    
      if self.patt['emptyline'].search(line):
        line = fin.readline()
        continue
    
      triposTagSearch = self.patt[self.format + 'TriposTag'].search(line)
      
      if triposTagSearch:
        triposSection = triposTagSearch.group(1).strip()      
        sectionLine = 0
        if not self.infoDict.has_key(triposSection):
          self.infoDict[triposSection] = {}
      
      elif triposSection:
      
        sectionLine += 1

        if triposSection == 'MOLECULE':
        
          if sectionLine in (1,3,4,5,6):
            infoName = self.readDict[triposSection][sectionLine][0]
            self.infoDict[triposSection][infoName] = line.strip()
          
          elif sectionLine == 2:
            numbers = line.split()
            for i in range(len(numbers)):
              infoName = self.readDict[triposSection][sectionLine][i]
              self.infoDict[triposSection][infoName] = returnInt(numbers[i])
           
        elif triposSection in ('ATOM','BOND','SUBSTRUCTURE'):
        
          if not self.infoDict[triposSection]:
            self.infoDict[triposSection] = []
          
          self.infoDict[triposSection].append({})

          atomCols = line.split()
          for i in range(len(atomCols)):
            (infoName,returnFunc) = self.readDict[triposSection][i]
            self.infoDict[triposSection][-1][infoName] = returnFunc(atomCols[i])

      line = fin.readline()
      
    fin.close()
예제 #25
0
    def __init__(self, serial, chainCode, seqCode, atomName, atomNumber,
                 resName, x, y, z):

        self.serial = returnInt(serial)
        self.atomName = atomName.strip()
        self.atomNumber = returnInt(atomNumber)
        self.resName = resName.strip().upper()
        self.seqCode = seqCode
        self.chainCode = chainCode.strip()

        self.x = returnFloat(x)
        self.y = returnFloat(y)
        self.z = returnFloat(z)

        # Not supported
        self.insertionCode = defaultSeqInsertCode
        self.chainId = defaultMolCode
예제 #26
0
 def __init__(self,Id,name,cyanaLib,verbose=False):
   
   self.Id = returnInt(Id,default=None,verbose=verbose)
   self.items = []
   self.name = name
   self.seqCode = None
   
   self.cyanaLib = cyanaLib
예제 #27
0
 def __init__(self,serial,name,atomType,bondedAtomSerials):
 
   self.serial = returnInt(serial)
   self.name = name
   self.atomType = atomType
   self.location = 0
   
   self.bondedAtomSerials = returnInts(bondedAtomSerials)
예제 #28
0
 def __init__(self,parent,atomSerial,value,valueError,atomName,seqCode,verbose=False):
 
   self.atomSerial = returnInt(atomSerial,default=None,verbose=verbose)
   self.value = returnFloat(value,default=None,verbose=verbose)
   self.valueError = returnFloat(valueError,default=None,verbose=verbose)
   self.atomName = atomName
   (self.seqCode,self.seqInsertCode) = getSeqAndInsertCode(seqCode)
   self.molCode = parent.defaultMolCode
예제 #29
0
    def getAssignmentValue(self, assignInitValue):

        if not self.textAssign:
            assignValue = returnInt(assignInitValue, default=None)
        else:
            assignValue = assignInitValue

        return assignValue
예제 #30
0
파일: peaksIO.py 프로젝트: fenglb/ccpnmr2.4
    def setValue(self, valueKey, values):

        if len(values) == 1 and type(values[0]) == type(''):

            value = values[0]

            if not self.parent.patt['emptyline'].search(value):

                if valueKey == 'num':
                    self.num = returnInt(value)

                elif valueKey == 'assignment':
                    assignment = value.strip()
                    self.assign = assignment.split(self.parent.assignSep)

                elif self.intensity == None and valueKey in ('dataHeight',
                                                             'height'):
                    self.intensity = returnFloat(value)

                elif valueKey == 'fitHeight':
                    self.intensityFit = returnFloat(value)

                elif valueKey == 'intensity':
                    self.intensity = returnFloat(value)

                elif valueKey == 'volume':
                    (volume, volumeMethod) = value.strip().split()
                    self.volume = returnFloat(volume)

                    if volumeMethod == 'ga':
                        self.volumeMethod = 'Gaussian'
                    elif volumeMethod == 'lo':
                        self.volumeMethod = 'Lorentzian'
                    elif volumeMethod == 'bx':
                        self.volumeMethod = 'Sum over box'
                    elif volumeMethod == 'el':
                        self.volumeMethod = 'Sum over ellipse'
                    elif volumeMethod == '--':
                        self.volumeMethod = 'Unknown method'
                    else:
                        self.volumeMethod = 'Unknown method'
                        print "  Error: unknown volume method %s in sparky peaks file (please define)." % volumeMethod

        elif len(values) >= 1:

            if valueKey == 'freqDimsPpm':
                self.ppm = returnFloats(values)

            elif valueKey == 'freqDimsHz':
                self.hz = returnFloats(values)

            elif valueKey == 'freqDimsWidth':
                self.widths = returnFloats(values[:-1])

        else:

            print "  Warning: empty data field for Sparky peak file."
            pass
예제 #31
0
  def __init__(self,serial,atomName,resName,segId,seqCode,x,y,z, insertionCode = defaultSeqInsertCode):
  
    self.serial = returnInt(serial)    
    self.atomName = atomName.strip()
    self.resName = resName.strip()
    self.seqCode = returnInt(seqCode)
    self.x = returnFloat(x)
    self.y = returnFloat(y)
    self.z = returnFloat(z)
    self.insertionCode = insertionCode

    self.chainId = self.segId = segId.strip()
    if not self.chainId:
      self.chainId = defaultMolCode

    # Hack - the naming system is otherwise an esoteric mix of other ones
    if self.atomName == 'HN':
      self.atomName = 'H'
예제 #32
0
    def readWhatIfAsaInfoFile(self, fileName):
        'Return True on error.'

#        nTdebug('Now in ' + getCallerName() + ' for ' + fileName)
        fin = open(fileName)
        lines = fin.readlines()
        fin.close()
        atomsRead = 0
        _hydrogensSkipped = 0
        skipHydrogens = False # already corrected for elsewhere?
#        dataLine = False
        for line in lines:
            line = line.strip()
#            nTdebug('Line: ' + line)
            if line[0] == '*' or not line:
                continue

            fields = line.split(';')

            resLabel = fields[1]
            seqId = fields[2]
            insertionCode = fields[3]
            chainCode = fields[4]
            # field 5 has nothing?
            atomName = fields[6]
            accessibility = fields[7]
            
            
            if skipHydrogens and atomName[0] == 'H':
                _hydrogensSkipped += 1 # are zero anyway.
                continue
            
            if not insertionCode:
                insertionCode = ' '
            seqKey = (returnInt(seqId), insertionCode)

            if not (accessibility[0] == '|' and accessibility[-1] == '|'):
                nTerror("Skipping line without valid format for accessibility: " + line)
                continue
            if len(accessibility) < 3:
                nTerror("Skipping line with too short accessibility string: " + line)
                continue
            accessibilityStr = accessibility[1:-1]
            accessibilityStr = accessibilityStr.strip()
            if len(accessibilityStr) < 1:
                nTerror("Skipping line with empty accessibility string: " + line) # happens for PDB entry 1cjg for 2 residues
                continue         
            accessibility = returnFloat(accessibilityStr)
            d = self.allWhatIfInfo['chains']
            if not d.has_key(chainCode):
                d[chainCode] = {}
            if not d[chainCode].has_key(seqKey):                
                d[chainCode][seqKey] = {'hasBadAtoms': False, 'resLabel': resLabel, 'atoms': {}}
            if not d[chainCode][seqKey]['atoms'].has_key(atomName):
                d[chainCode][seqKey]['atoms'][atomName] = []

            d[chainCode][seqKey]['atoms'][atomName].append(accessibility)
            # TODO: match to cing data model for storage at atom level and to RDB cingresidue.wi_wsvacc using
            # WSVACC_STR
            atomsRead += 1
        # end for
#        nTdebug("Read %s atoms" % atomsRead)
#        nTdebug("Skipped %s hydrogen" % hydrogensSkipped)
#        nTdebug("Seen %s atoms" % (atomsRead + hydrogensSkipped))
        if not atomsRead:
            nTerror("Failed to read any atom")
            return True