Personal tools
You are here: Home Developers Corner Run time behaviour API use test
Document Actions

API use test

A python script that creates a project from scratch, saves, it, loads it, and backs it up. No pre-existing files are required. The content is Nmr related, but the approach is general. Courtesy of Wim Vranken

Click here to get the file

Size 90.3 kB - File type text/python-source

File contents

import memops.api.Implementation as Implementation
import ccp.api.general.Instrument as Instrument
import ccp.api.general.Method as Method
import ccp.api.molecule.MolSystem as MolSystem
import ccp.api.molecule.Molecule as Molecule
import ccp.api.general.Affiliation as Affiliation
import ccp.api.lims.Sample as Sample
import ccp.api.lims.RefSampleComponent as RefSampleComponent
import ccp.api.nmr.NmrEntry as Entry
import ccp.api.nmr.Nmr as Nmr

from memops.format.xml import XmlIO

from memops.general.Util import returnMemopsWord
import random, os, time

###########
# PROJECT #
###########

def getProject(name,setDataLocation):


  ##########################################
  # Definition of functions for processing #
  ##########################################
  
  from ccpnmr.format.general.Constants import INDIRECT_FREQ_CONV
  
  def checkPerson(proj,group,cur_person,cur_personInGroup):
  
    newline = "\\n"
    matchlist = ['givenName','title','middleInitials']
  
    person = None
  
    for tperson in proj.currentAffiliationStore.getPersons():
      if tperson.familyName == cur_person['familyName']:
        # If a match on familyName, check if the rest of matchlist fits
        # Don't bother with position: if there is no contact person, it's the head of the lab
        for attribute in matchlist:
          match_attribute = getattr(tperson,attribute)
          error_txt = ''
          if cur_person.has_key(attribute):
            if match_attribute != cur_person[attribute]:
              error_txt = "  Attribute '%s': both '%s' and '%s'" % (attribute,match_attribute,cur_person[attribute])
          elif match_attribute != None and match_attribute != ():
            error_txt = "  Attribute '%s': has value for one and is empty for other" % attribute
          
          if error_txt != '':
            print "Mismatch error in attributes for person '%s':" % tperson.familyName
            print error_txt
            print newline
        
        person = tperson
        break
  
    # In case no match found, create new person
    if not person:
      # Create CCPN person
      # familyName is mandatory on creation
      person = Affiliation.Person(proj.currentAffiliationStore, familyName = cur_person['familyName'])
      
      # Should make this into subroutine somewhere...
      validAttributes = person.__dict__.keys()
  
      for attribute in cur_person.keys():
        if validAttributes.count(attribute) == 0:
          print "Trying to set attribute %s: not a valid name!" % attribute
        else:
          person.__setattr__(attribute,cur_person[attribute])
    
    personInGroup = person.findFirstPersonInGroup(group = group)
    
    if not personInGroup:
   
      # Link to organisation/group via personInGroup
      
      personInGroup = Affiliation.PersonInGroup(person,group = group)
     
      # Should make this into subroutine somewhere...
      validAttributes = personInGroup.__dict__.keys()
  
      for attribute in cur_personInGroup.keys():
        if validAttributes.count(attribute) == 0:
          print "Trying to set attribute %s: not a valid name!" % attribute
        else:
          personInGroup.__setattr__(attribute,cur_personInGroup[attribute])
      
    return person
  
  def setupOrganisation(proj,name):
  
    setCurrentStore(proj, 'AffiliationStore')
    
    organisation = proj.currentAffiliationStore.findFirstOrganisation(name = name)
  
    if not organisation:
      organisation = Affiliation.Organisation(proj.currentAffiliationStore,name = name)
    
    return organisation
  
  def setupGroup(organisation,name,labNum):
  
    group = Affiliation.Group(organisation,name = name)
    
    appData = Implementation.AppDataInt(application = 'DEN',keyword = 'labNum', value = labNum)
    group.addApplicationData(appData)
    
    return group
  
  def findGroup(proj,labNum):
  
    groupFound = None
    
    for organisation in proj.currentAffiliationStore.organisations:
      for group in organisation.groups:
        appData = group.findFirstApplicationData(application = 'DEN', keyword = 'labNum')
        if appData and appData.value == labNum:
          groupFound = group
          break
          
    return groupFound
  
  def setupMolComponent(proj,keywds):
  
    setCurrentStore(proj, 'RefSampleComponentStore')
  
    component = proj.currentRefSampleComponentStore.findFirstComponent(**keywds)
    
    if not component:
   
      component = RefSampleComponent.MolComponent(proj.currentRefSampleComponentStore, **keywds)
      
    return component
  
  def setupSubstance(proj,keywds):
  
    setCurrentStore(proj, 'RefSampleComponentStore')
  
    component = proj.currentRefSampleComponentStore.findFirstComponent(**keywds)
    
    if not component:
    
      component = RefSampleComponent.Substance(proj.currentRefSampleComponentStore, **keywds)
      
    return component
   
  def setupExpDimRef(expdim,isotopes,expdimref_unit,sfo,folding,exp):
  
  
    # ExpDimRef setup
    # ---------------
  
    # sf is supposed to be MHz
    expdimref = Nmr.ExpDimRef(expdim, sf = sfo)  
    
    expdimref.unit = expdimref_unit      # This is the unit for the nominalRefValue (and DataDimRef)
    expdimref.isotopeCodes = isotopes   # Not sure that this is the place for 1H!
    expdimref.isFolded = folding         # Folding in this dimension?
  
    return (expdimref)
  
  def setupFid(exp_origin,exp):
  
    if exp_origin == 'varian':
      name = 'varian'
    elif exp_origin == 'bruker':
      name = 'bruker'
  
    # DataSource setup
    # ----------------
  
    datasource = Nmr.DataSource(exp, name = name, numDim = exp.numDim, dataType = 'FID') 
    datasource.filetype = exp_origin
    
    return datasource
  
  def setupFreq(program,exp):
  
    # Keep these options! Are checked for in make<...>proc.py
    if program == 'nmrPipe':
      name = 'nmrPipe'
    elif program == 'Azara':
      name = 'azara'
    else:
      name = 'Unknown origin'
  
    # DataSource setup
    # ----------------
  
    datasource = Nmr.DataSource(exp, name = name, numDim = exp.numDim, dataType = 'processed') 
    datasource.filetype = program
    
    return datasource
  
  def setupFidDataDim(fiddatadim_unit,isComplex,valppoint,npoints,npointsvalid,datasource,expdim):
  
    fiddatadim = Nmr.FidDataDim(datasource, expDim = expdim, dim = expdim.dim, isComplex = isComplex, valuePerPoint = valppoint,numPoints = npoints, numPointsValid = npointsvalid)
    fiddatadim.unit = fiddatadim_unit
    
    return fiddatadim
    
    # Need to add more attributes here from top list!
  
  def setupFreqDataDim(freqdatadim_unit,isComplex,valppoint,npoints,npointsorig,datasource,expdim):
  
    freqdatadim = Nmr.FreqDataDim(datasource, expDim = expdim, dim = expdim.dim, isComplex = isComplex,valuePerPoint = valppoint, numPoints = npoints, numPointsOrig = npointsorig)
    freqdatadim.unit = freqdatadim_unit
    
    return freqdatadim
    
  def getFreqDataDims(datasource,program):
    freqdatadimlist = {}
    for freqdatadim in datasource[program].getDataDims():
      sdim = str(freqdatadim.dim)
      freqdatadimlist[sdim] = freqdatadim
    
    return freqdatadimlist
  
  def setupDataDimRef(expDim,exp):
  
    dataDimRefs = []
  
    for dataDim in expDim.getDataDims():
      if dataDim.metaclass.name != 'FreqDataDim':
        continue
            
      for expDimRef in expDim.getExpDimRefs():
      
        dataDimRefs.append(Nmr.DataDimRef(dataDim, expDimRef = expDimRef))
   
    return dataDimRefs
  
  def listattr(clazz):
    for key in clazz.__dict__.keys():
      print "%-30s %-s" % (key,getattr(clazz,key))
  
  def calculateNominalRefFreq(exp,expdimref,nomRefProton):
  
    expdimreflist = expdimref.keys()
    expdimreflist.sort()
    freq = 0
  
    # Getting reference 1H frequency from first 1H found
    for sdim in expdimreflist:
      for curExpDimRef in expdimref[sdim]:
        isotopes = curExpDimRef.getIsotopeCodes()
        isotope = isotopes[0]
        if isotope == '1H':
          freq = curExpDimRef.sf
          break
  
    if freq == 0:
      print "ERROR: no proton dimension found for %s. Can't set nominal references." % exp.name
    else:
      protonfreq_zero = freq / (nomRefProton / 1000000 + 1)
      
      # Handling multiple expdimrefs for one expdim
      for sdim in expdimref.keys():
        for curExpDimRef in expdimref[sdim]:
          isotopes = curExpDimRef.getIsotopeCodes()
          if len(isotopes) > 1:
            print "Warning: two isotopes for dim %s." % sdim
          isotope = isotopes[0]
        
          freq_zero = protonfreq_zero * INDIRECT_FREQ_CONV[isotope] / 100
  
          curExpDimRef.nominalRefValue = ((curExpDimRef.sf - freq_zero) / freq_zero) * 1000000
  
  def calculateDanielNominalRefFreq(expdimref):
    # Set SFO to (SFOn-BFn)*1000000/BFn ppm (BFn is 0 ppm).
    # Specific for Daniel spectrum referencing!
    for sdim in expdimref.keys():
      for curExpDimRef in expdimref[sdim]:
        nomRef = (curExpDimRef.sf - curExpDimRef.baseFrequency) * 1000000.0 / curExpDimRef.baseFrequency
        curExpDimRef.nominalRefValue = nomRef
  
  def setChemShiftReference(datasource,refValues):
  
    #
    # RefValues of form: {'1': {0: [33,0.00]}, '2': {0: [11.2,120.1], 1: [11.2,56.3]}}
    # Where '1','2' is sdim for freqdatadim,
    #       0,1     is expDimRef index for relevant expDim
    #       in list refPoint is first, refValue is second
    #
  
    for program in datasource.keys():
    
      if program == 'fid':
        continue
    
      for freqDataDim in datasource[program].getDataDims():
  
        sdim = str(freqDataDim.dim)
        expDim = freqDataDim.expDim
  
        freqDataDimRefValues = None   
        if refValues.has_key(sdim):
          freqDataDimRefValues = refValues[sdim]
  
        for i in range(0,len(expDim.expDimRefs)):
  
          expDimRef = expDim.expDimRefs[i]
          dataDimRef = expDimRef.findFirstDataDimRef(dataDim = freqDataDim)
  
          if not freqDataDimRefValues or i not in freqDataDimRefValues.keys():
  
            refPoint = freqDataDim.numPoints/2 + 1
            refValue = expDimRef.nominalRefValue
  
          else:
  
            (refPoint,refValue) = freqDataDimRefValues[i]
  
          dataDimRef.refPoint = refPoint
          dataDimRef.refValue = refValue
  
  def setExperimentSpectrometerLink(exp,spec):
  
    exp.spectrometer = spec
  
  ##############################
  # Special processing options #
  ##############################
  
  def setNegateAlternatePoint(fiddatadim):
    # When this option is set, every alternate point (real+imag) will be negated.
    # Eg when x y -x -y recording of data, this will become x y x y
  
    # Functions listed under fiddatadim should be applied before all other
    # functions for processing!
    appl = Implementation.AppDataString(fiddatadim,application = 'allProcessing', keyword = 'negateAlternatePoint', value = 'on')
    # TODO: change all code to recognize following!
    fiddatadim.alternateSign = True
  
  def setConjugate(fiddatadim):
    # When this option is set, conjugate of data will be taken
    # This will switch the axis direction (flip axis)
  
    # Functions listed under fiddatadim should be applied before all other
    # functions for processing!
    appl = Implementation.AppDataString(fiddatadim,application = 'allProcessing', keyword = 'conjugate', value = 'on')
    # TODO: change all code to recognize following!
    fiddatadim.negateImaginary = True
  
  def setReal(fiddatadim):
    # When this option is set, data will be treated as real!
    # TODO: Need COPY function in API (or clone function at least)
    
    # CAN I GET THIS FROM THE ACQU FILES THEMSELVES?!?!?!?!?!
    
    # TODO: Do I have to change the number of points? Or is the number reported (by Bruker
    # or Varian) different anyway when real/complex?
    fiddatadim.isComplex = False
  
    # Functions listed under fiddatadim should be applied before all other
    # functions for processing!
    appl = Implementation.AppDataString(fiddatadim,application = 'allProcessing', keyword = 'real', value = 'on')
  
    return fiddatadim
  
  def setEchoAntiEcho(fiddatadim):
    # Echo-AntiEcho recording of this dimension (sensitivity enhancement)
    # TODO: will be in fiddatadim!
  
    # Functions listed under fiddatadim should be applied before all other
    # functions for processing!
    appl = Implementation.AppDataString(fiddatadim,application = 'allProcessing', keyword = 'echoAntiEcho', value = 'on')
  
    ds = fiddatadim.parent
    ds.isNormalStorage = False
    ds.storageDetails = "echoAntiEcho"
  
  def setRanceKay(fiddatadim):
    # Rance-Kay type recording of this dimension (sensitivity enhancement)
    # TODO: will be in fiddatadim!
    
    # Functions listed under fiddatadim should be applied before all other
    # functions for processing!
    appl = Implementation.AppDataString(fiddatadim,application = 'allProcessing', keyword = 'ranceKay', value = 'on')
  
    ds = fiddatadim.parent
    ds.isNormalStorage = False
    ds.storageDetails = "ranceKay"
  
  def setVarianAcqOrd(datasource,newvalue):
    # Set acquisition order... default assumed d3,d2,ph2,ph for 3D, d4,d3,d2,ph3,ph2,ph for 4D
    # Set value to 1 if order is d3,d2,ph,ph2 for 3D, d4,d3,d2,ph,ph2,ph3 for 4D!
    # TODO: set in dataSource.storageOrder
    
    if newvalue == '1':
      datasource.storageOrder = ('dim3','dim2','phase1','phase2')
  
  def invertSign(freqdatadim):
    # Inverts sign (by adding 180 to phase0)
    
    freqdatadim.phase0 += 180
  
  
  #####################################################
  # Definitions for molecule creation (protein only!) #
  #####################################################
  
  # Are currently created off the seqString - will change in future
  
  resCode = {}
  resCode['A']='ALA'
  resCode['C']='CYS'
  resCode['D']='ASP'
  resCode['E']='GLU'
  resCode['F']='PHE'
  resCode['G']='GLY'
  resCode['H']='HIS'
  resCode['I']='ILE'
  resCode['K']='LYS'
  resCode['L']='LEU'
  resCode['M']='MET'
  resCode['N']='ASN'
  resCode['P']='PRO'
  resCode['Q']='GLN'
  resCode['R']='ARG'
  resCode['S']='SER'
  resCode['T']='THR'
  resCode['V']='VAL'
  resCode['W']='TRP'
  resCode['Y']='TYR'
  
  BMRBtoIUPAC = {}
  
  BMRBtoIUPAC['VAL'] = {}
  BMRBtoIUPAC['VAL']['HG1'] = ['HG11','HG12','HG13']
  BMRBtoIUPAC['VAL']['HG2'] = ['HG21','HG22','HG23']
  
  BMRBtoIUPAC['LEU'] = {}
  BMRBtoIUPAC['LEU']['HD1'] = ['HD11','HD12','HD13']
  BMRBtoIUPAC['LEU']['HD2'] = ['HD21','HD22','HD23']
  
  BMRBtoIUPAC['ILE'] = {}
  BMRBtoIUPAC['ILE']['HG2'] = ['HG21','HG22','HG23']
  BMRBtoIUPAC['ILE']['HD1'] = ['HD11','HD12','HD13']
  
  BMRBtoIUPAC['MET'] = {}
  BMRBtoIUPAC['MET']['HE'] = ['HE1','HE2','HE3']
  
  BMRBtoIUPAC['ALA'] = {}
  BMRBtoIUPAC['ALA']['HB'] = ['HB1','HB2','HB3']
  
  BMRBtoIUPAC['THR'] = {}
  BMRBtoIUPAC['THR']['HG2'] = ['HG21','HG22','HG23']
  
  BMRBtoIUPAC['PHE'] = {}
  BMRBtoIUPAC['PHE']['HD1'] = ['HD1']
  BMRBtoIUPAC['PHE']['HD2'] = ['HD2']
  BMRBtoIUPAC['PHE']['HE1'] = ['HE1']
  BMRBtoIUPAC['PHE']['HE2'] = ['HE2']
  
  BMRBtoIUPAC['TYR'] = {}
  BMRBtoIUPAC['TYR']['HD1'] = ['HD1']
  BMRBtoIUPAC['TYR']['HD2'] = ['HD2']
  BMRBtoIUPAC['TYR']['HE1'] = ['HE1']
  BMRBtoIUPAC['TYR']['HE2'] = ['HE2']
  
  BMRBtoIUPAC['TRP'] = {}
  BMRBtoIUPAC['TRP']['HE3'] = ['HE3']
  
  def makeMolResidues(mol,molType,molSequence):
    
    print "  Creating molResidues..."
  
    proj = mol.root
  
    for resPos in range(0,len(molSequence)):
      oneLetterCode = molSequence[resPos]
      ccpCode = resCode[oneLetterCode]
      
      chemCompHead = getChemCompHead(proj,molType,ccpCode)
    
      if resPos == 0:
        location = 'start'
      elif resPos == len(molSequence)-1:
        location = 'end'
      else:
        location = 'middle'
      
      chemCompVar = chemCompHead.chemComp.findFirstChemCompVar(linking = location, isDefaultVar = True)
      
      if not chemCompVar:
      
        chemCompVar = chemCompHead.chemComp.findFirstChemCompVar(linking = location)
        molRes = Molecule.MolResidue(molecule,seqId = resPos + 1, seqCode = resPos + 1, chemCompHead = chemCompHead, linking = chemCompVar.linking, descriptor = chemCompVar.descriptor)
  
        #
        # Set the linking information...
        #
  
        if chemCompVar.linking in ['middle','end']:
  
          prevLink = molRes.findFirstMolResLinkEnd(linkCode = 'prev')
          prevMolRes = molecule.findFirstMolResidue(seqId = resPos)
  
          if prevLink and prevMolRes:
  
            nextLink = prevMolRes.findFirstMolResLinkEnd(linkCode = 'next')
  
            if nextLink:
  
              molResLink = Molecule.MolResLink(molecule,molResLinkEnds = [nextLink,prevLink])
  
  def getAtomSet(resid,res,atomName):
  
    code3Letter = resid.molResidue.code3Letter
    atomNames = []
  
    # Extra bit for simple atom renaming IUPAC - PDB
    if BMRBtoIUPAC.has_key(code3Letter):
      if BMRBtoIUPAC[code3Letter].has_key(atomName):
        atomNames = BMRBtoIUPAC[code3Letter][atomName]
    
    if atomNames == []:
      if BMRBtoIUPAC.has_key(atomName):
        atomNames = BMRBtoIUPAC[atomName]
      else:
        atomNames = [atomName]
  
    atoms = []
  
    for atomName in atomNames:
      atom = resid.findFirstAtom(name = atomName)
      
      if atom != None:
        atoms.append(atom)
      else:
        print "Unrecognized atom name %s for residue %d.%s" % (atomName,resid.seqId,code3Letter)
  
    if atoms != []:
      return Nmr.AtomSet(proj.currentNmrProject,name = res.atomSiteType, atoms = atoms)
  
  def checkValidResidueName(resid,resName):
  
    code3Letter = resid.molResidue.code3Letter
    
    if code3Letter != resName:
      print "  ERROR: bad residue name match for residue (code = %s, resNames %s and %s)" % (resid.resCode,code3Letter,resName)
  """
  def setXyz(struc,resid,atomName,chainCode,seqCode,x,y,z):
  
    foundAtom = None
  
    for atom in resid.getAtoms():
      if atom.name == atomName:
        foundAtom = atom
        break
    
    if foundAtom == None:
      code3Letter = resid.molResidue.code3Letter
      print "    ERROR: Unrecognized atom name for coordinate linking: %s.%s %s" % (code3Letter,resid.seqCode,atomName)
  
    else:
      coord = Xyz(struc,chainCode = chainCode, seqCode = seqCode, atomName = foundAtom.name, x = x, y = y, z = z)
  """
  
  def setCurrentStore(project, className, linkName = None):
    
    currentStore = None
  
    if className:
      
      currentName = "current%s" % (className)
      
      if not linkName:
        linkName = "sorted%ss" % className
        
      currentStore = getattr(project,currentName)
   
      if not currentStore:
        storeList = getattr(project,linkName)()
  
        if storeList:
          setattr(project,currentName,storeList[0])
        else:
          # this automatically sets project.current..Store
          newStore = getattr(project,"new%s" % className)(name=project.name)
          setattr(project,currentName,newStore)
        
        currentStore = getattr(project,currentName)
  
    return currentStore

#NBNB  proj = Implementation.MemopsRoot(name=name, details = 'Made by makeTestProject on GMT 25 February 2007 at 17:42:12')
  proj = Implementation.MemopsRoot(name=name)
  proj.details = 'Made by makeTestProject on GMT 25 February 2007 at 17:42:12'
  nmrProject = Nmr.NmrProject(proj, name = proj.name)
  print " Creating project %s (%s)" % (proj.name, proj.details)

  classification = proj.newClassification(namingSystem = "local")
  sampleCategory = classification.newSampleCategory(name = "NMR samples")
##########################
# LABORATORY INFORMATION #
##########################

  ################
  # Laboratory 1 #
  ################

  labNum = 1


  # Create lab info
  name = 'University of Toronto'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = 'Ontario Cancer Institute, University Health Network, Division of Molecular and Structural Biology'
  organisation.city = 'Toronto'
  organisation.country = 'Canada'
  #organisation.url = ''
  
  name = 'Biomolecular NMR group'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Arrowsmith'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Cheryl'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  #curPersonInGroup['phoneNumbers'] = ['']
  #curPersonInGroup['faxNumber'] = ''
  #curPersonInGroup['emailAddress'] = ''
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 2 #
  ################

  labNum = 2


  # Create lab info
  name = 'Rutgers University'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = 'Center for Advanced Biotechnology and Medicine'
  organisation.city = 'Piscataway'
  organisation.country = 'USA'
  #organisation.url = ''
  
  name = 'Protein NMR Spectroscopy Laboratory'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Montelione'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Gaetano'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  curPersonInGroup['phoneNumbers'] = ['+1-732-2355321']
  #curPersonInGroup['faxNumber'] = ''
  curPersonInGroup['emailAddress'] = 'guy@cabm.rutgers.edu'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 3 #
  ################

  labNum = 3


  # Create lab info
  name = 'University College London'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = 'Dept. Biochemistry and Molecular Biology'
  organisation.city = 'London'
  organisation.country = 'UK'
  #organisation.url = ''
  
  name = 'Bloomsbury Centre For Structural Biology'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  
  curPerson = {}
  curPerson['familyName'] = 'Driscoll'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Paul'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  #curPersonInGroup['phoneNumbers'] = ['']
  #curPersonInGroup['faxNumber'] = ''
  #curPersonInGroup['emailAddress'] = ''
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 4 #
  ################

  labNum = 4


  # Create lab info
  name = 'University of Cambridge'
  organisation = setupOrganisation(proj,name)
  
  #organisation.address = ''
  organisation.city = 'Cambridge'
  organisation.country = 'United Kingdom'
  organisation.url = 'http://www.cam.ac.uk/'
  
  name = 'Department of Biochemistry'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Laue'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Ernest'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  #curPersonInGroup['phoneNumbers'] = ['']
  #curPersonInGroup['faxNumber'] = ''
  curPersonInGroup['emailAddress'] = 'e.d.laue@bioc.cam.ac.uk'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 5 #
  ################

  labNum = 5


  # Create lab info
  name = 'Biotechnology Research Institute'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = '6100 Royalmount Ave., Montreal, QC H4P 2R2, Canada'
  organisation.city = 'Montreal'
  organisation.country = 'Canada'
  organisation.url = 'http://www.bri.nrc.ca/'
  
  name = 'Bacterial Structural Genomics Center'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  curPerson = {}
  curPerson['familyName'] = 'Ekiel'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Irena'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  curPersonInGroup['phoneNumbers'] = ['+1-514-4966329']
  curPersonInGroup['faxNumber'] = '+1-514-4965143'
  curPersonInGroup['emailAddress'] = 'irena.ekiel@nrc.ca'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 6 #
  ################

  labNum = 6


  # Create lab info
  name =  'University of Edinburgh'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = "King's Buildings, Edinburgh EH9 3JR, UK"
  organisation.city = 'Edinburgh'
  organisation.country = 'United Kingdom'
  #organisation.url = ''
  
  name = 'Institute of Cell and Molecular Biology'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Barlow'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Paul'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  #curPersonInGroup['phoneNumbers'] = ['']
  #curPersonInGroup['faxNumber'] = ''
  curPersonInGroup['emailAddress'] = 'Paul.Barlow@ed.ac.uk'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 7 #
  ################

  labNum = 7


  # Create lab info
  name = 'Pacific Northwest National Laboratory (PNNL)'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = "790 6th Street, Richland, WA 99352, USA"
  organisation.city = 'Richland'
  organisation.country = 'United States'
  #organisation.url = ''
  
  name = 'William R. Wiley Environmental Molecular Sciences Laboratory (EMSL)'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Kennedy'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Michael'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  curPersonInGroup['phoneNumbers'] = ['+1-509-372 2168']
  curPersonInGroup['faxNumber'] = '+1-376-2303?'
  curPersonInGroup['emailAddress'] = 'makennedy@pnl.gov'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)

  ################
  # Laboratory 8 #
  ################

  labNum = 8


  # Create lab info
  name = 'Biotechnology Research Institute'
  organisation = setupOrganisation(proj,name)
  
  organisation.address = '6100 Royalmount Ave., Montreal, QC H4P 2R2, Canada'
  organisation.city = 'Montreal'
  organisation.country = 'Canada'
  organisation.url = 'http://www.bri.nrc.ca/'
  
  name = 'Biomolecular NMR group'
  group = setupGroup(organisation,name,labNum)
  
  # -----------
  # Head of lab
  # -----------
  
  curPerson = {}
  curPerson['familyName'] = 'Ni'
  curPerson['title'] = 'Dr.'
  curPerson['givenName'] = 'Feng'
  
  curPersonInGroup = {}
  curPersonInGroup['position'] = 'Head'
  curPersonInGroup['phoneNumbers'] = ['+1-514-4966729']
  curPersonInGroup['faxNumber'] = '+1-514-4965143'
  curPersonInGroup['emailAddress'] = 'fengni@bri.nrc.ca'
  
  # Following function determines whether person already exists, creates new
  # one if not.
  
  checkPerson(proj,group,curPerson,curPersonInGroup)
  

#####################
# Molecule number 4 #
#####################

  print " Creating molecule 4..."
  molDict = {'name': 'Spectrin Src Homology 3 (SH3) domain'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('Spectrin Src Homology 3 (SH3) domain')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Spectrin Src Homology 3 (SH3) domain')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 4 #
################

  group = findGroup(proj,4)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is on CD from biochem lab (Feb 2002, /monster/dn0/sh3-100D)'}
  entryKeywds['name'] = 'DEN entry 4/4'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 4/4'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Following are related BMRB entries
  Entry.RelatedEntry(entry, bmrbId = '4145')
  Entry.RelatedEntry(entry, bmrbId = '4860')
  Entry.RelatedEntry(entry, bmrbId = '4888')
  Entry.RelatedEntry(entry, bmrbId = '4889')

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Daniel', 'familyName': 'Nietlispach', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+44-1223-766018'], 'emailAddress': 'dn0@mole.bio.cam.ac.uk', 'faxNumber': '+44-1223-766002'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 5.5, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 298, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_4_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.001, 'isotopicLabelling': '[U-97% 13C; U-??% 15N; U-100% 2H]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Bruker_DRX_600'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '600', 'model': 'DRX', 'protonFreq': 600.13}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Bruker_DRX_800'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '800', 'model': 'DRX', 'protonFreq': 800.13}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 5 #
#####################

  print " Creating molecule 5..."
  molDict = {'name': 'YBCJ', 'details': '(gi|1786740|gb|AAC73630.1| orf, hypothetical protein [Escherichia coli K12]). First two residues (GS) is tag, rest real sequence'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('YBCJ system')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'YBCJ')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 5 #
################

  group = findGroup(proj,5)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is download from BRI directory /home/nmr/irena/easy/WV_EBI (July 2002)'}
  entryKeywds['name'] = 'DEN entry 5/5'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 5/5'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Carine', 'familyName': '?', 'title': 'Ms.'}
  curPersonInGroup = {'position': 'Contact'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.7999999999999998, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 313, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_5_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00050000000000000001, 'concentration': 0.0060000000000000001, 'isotopicLabelling': '[U-95% 13C; U-95% 15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00050000000000000001, 'concentration': 0.0060000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.050000000000000003, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.29999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'DTT'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.014999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Bruker_DRX_500'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '500', 'model': 'DRX', 'protonFreq': 500.13235250000002}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 2 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.7999999999999998, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 313, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample2'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_5_2'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00050000000000000001, 'concentration': 0.0060000000000000001, 'isotopicLabelling': '[U-95% 15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00050000000000000001, 'concentration': 0.0060000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.050000000000000003, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.29999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'DTT'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.014999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Bruker_DRX_500'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '500', 'model': 'DRX', 'protonFreq': 500.13235250000002}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 3 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.7999999999999998, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 313, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample3'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_5_3'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
  sampleCompKeywds = {'concentrationError': 0.00050000000000000001, 'concentration': 0.0060000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.050000000000000003, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.29999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'DTT'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.014999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Bruker_DRX_500'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '500', 'model': 'DRX', 'protonFreq': 500.13235250000002}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 6 #
#####################

  print " Creating molecule 6..."
  molDict = {'name': 'Hemolysin expression modulating protein Hha'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('Hha system')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Hemolysin expression modulating protein Hha')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 1 #
################

  group = findGroup(proj,1)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is bmrb ID 5166'}
  entryKeywds['name'] = 'DEN entry 6/1'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 6/1'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Adelinda', 'familyName': 'Yee', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+1-416-9462017'], 'emailAddress': 'aayee@uhnres.utoronto.ca'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.5, 'condition': 'pH', 'error': 0.20000000000000001}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 298, 'condition': 'Temperature', 'error': 1}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'mM', 'value': 150, 'condition': 'Ionic strength'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'atm', 'value': 1, 'condition': 'Pressure'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_6_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentration': 0.002, 'isotopicLabelling': '[U-13C; U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentration': 0.002, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.10000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.14999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'DTT'}
  component = setupSubstance(proj,compKeywds)
#NBNB  sampleCompKeywds = {'isotopeLabeling': 'd4', 'concentration': 0.002, 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentration': 0.002, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Inova', 'protonFreq': 498.203689, 'details': 'Also reported protonFreq 496.8123942'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 600.29539499999998, 'details': 'Also reported protonFreq 600.2637025'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 7 #
#####################

  print " Creating molecule 7..."
  molDict = {'name': 'Ku86'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('Ku86 system')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Ku86')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 3 #
################

  group = findGroup(proj,3)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is from temporary download off Richard Harris web pages'}
  entryKeywds['name'] = 'DEN entry 7/3'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 7/3'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Richard', 'familyName': 'Harris', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+44-20-76791354'], 'emailAddress': 'rharris@biochem.ucl.ac.uk', 'faxNumber': '+44-20-76797193'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 7.0, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 0, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_7_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'isotopicLabelling': '[U-99% 13C; U-98% 15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.10000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Unity+_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Unity+', 'protonFreq': 499.83760000000001, 'details': 'Also reported for protonFreq: 499.85462'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Unity+_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Unity+', 'protonFreq': 599.93290000000002, 'details': 'Also reported for protonFreq: 599.93146'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[2] #
  ###################

  name = 'Varian_Inova_800'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '800', 'model': 'Inova', 'protonFreq': 800.30470000000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 2 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 7.0, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 0, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample2'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_7_2'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'isotopicLabelling': '[U-98% 15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.10000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Unity+_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Unity+', 'protonFreq': 499.83760000000001, 'details': 'Also reported for protonFreq: 499.85462'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Unity+_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Unity+', 'protonFreq': 599.93290000000002, 'details': 'Also reported for protonFreq: 599.93146'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[2] #
  ###################

  name = 'Varian_Inova_800'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '800', 'model': 'Inova', 'protonFreq': 800.30470000000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 3 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 7.0, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 0, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample3'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_7_3'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'isotopicLabelling': 'None?', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.10000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'D2O'}
  component = setupSubstance(proj,compKeywds)
#NBNB  sampleCompKeywds = {'isotopeLabeling': 'U-99.9% 2H', 'concentration': 100, 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentration': 100, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Unity+_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Unity+', 'protonFreq': 499.83760000000001, 'details': 'Also reported for protonFreq: 499.85462'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Unity+_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Unity+', 'protonFreq': 599.93290000000002, 'details': 'Also reported for protonFreq: 599.93146'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[2] #
  ###################

  name = 'Varian_Inova_800'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '800', 'model': 'Inova', 'protonFreq': 800.30470000000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 8 #
#####################

  print " Creating molecule 8..."
  molDict = {'name': 'mth1743 from M. thermoautotrophicum'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('mth1743')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'mth1743 from M. thermoautotrophicum')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 1 #
################

  group = findGroup(proj,1)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry is download from temporary link Arrowsmith web pages.'}
  entryKeywds['name'] = 'DEN entry 8/1'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 8/1'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Following are related BMRB entries
  Entry.RelatedEntry(entry, bmrbId = '5106')

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Bin', 'familyName': 'Wu', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+1-416-???????'], 'emailAddress': 'bwu@uhnres.utoronto.ca'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.5, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 298, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_8_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'isotopicLabelling': '[U-13C; U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00020000000000000001, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Disodiumphosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.025000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.45000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Inova', 'protonFreq': 498.203689, 'details': 'Also reported protonFreq 496.8123942'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 600.29539499999998, 'details': 'Also reported protonFreq 600.2637025'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 9 #
#####################

  print " Creating molecule 9..."
  molDict = {'name': 'CR1~15-16, the Immune Adherence Receptor'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('CR1~15-16')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'CR1~15-16, the Immune Adherence Receptor')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 6 #
################

  group = findGroup(proj,6)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry is download from temporary link Brian Smith web pages.'}
  entryKeywds['name'] = 'DEN entry 9/6'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 9/6'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Brian', 'familyName': 'Smith', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+44-0131 650 7051', '+44-0131 650 7045', '+44-0131 650 4704'], 'emailAddress': 'Brian.O.Smith@ed.ac.uk', 'faxNumber': '+44-0131 650 7055'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 7.4000000000000004, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 310, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1', 'details': 'This is sample 15N.1 - concentrations and pH might have been different.'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_9_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'isotopicLabelling': '[U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.025000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.14999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 599.94384500000001}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Bruker_Avance_800'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '800', 'model': 'Avance', 'protonFreq': 800.13381500000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 2 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.0, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 310, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1', 'details': 'This is sample 15N.3.'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_9_2'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'isotopicLabelling': '[U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.025000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.14999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 599.94384500000001}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Bruker_Avance_800'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '800', 'model': 'Avance', 'protonFreq': 800.13381500000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
####################
# Experiment set 3 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.0, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 310, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1', 'details': 'This is sample CN.1.'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_9_3'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'isotopicLabelling': '[U-13C; U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.00059999999999999995, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.025000000000000001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'NaCl'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentration': 0.14999999999999999, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 599.94384500000001}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Bruker_Avance_800'

  manufacturer = setupOrganisation(proj,'Bruker')
  specKeywds = {'nominalFreq': '800', 'model': 'Avance', 'protonFreq': 800.13381500000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 1 #
#####################

  print " Creating molecule 1..."
  molDict = {'name': 'Rna Polymerase Subunit Rpb5 From Methanobacterium Thermoautotrophicum'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('Rpb5 system')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Rna Polymerase Subunit Rpb5 From Methanobacterium Thermoautotrophicum')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 1 #
################

  group = findGroup(proj,1)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is bmrb ID 4678'}
  entryKeywds['name'] = 'DEN entry 1/1'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 1/1'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Adelinda', 'familyName': 'Yee', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+1-416-9462017'], 'emailAddress': 'aayee@uhnres.utoronto.ca'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 6.5, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 298, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_1_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.00029999999999999997, 'concentration': 0.001, 'isotopicLabelling': '[U-13C; U-15N]', 'concentrationUnit': 'M'}
  sampleCompKeywds = {'concentrationError': 0.00029999999999999997, 'concentration': 0.001, 'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Inova', 'protonFreq': 498.203689, 'details': 'Also reported protonFreq 496.8123942'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Inova_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Inova', 'protonFreq': 600.29539499999998, 'details': 'Also reported protonFreq 600.2637025'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 2 #
#####################

  print " Creating molecule 2..."
  molDict = {'name': 'Basic Pancreatic Trypsin Inhibitor'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('BPTI system')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Basic Pancreatic Trypsin Inhibitor')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 2 #
################

  group = findGroup(proj,2)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is bmrb ID 5307'}
  entryKeywds['name'] = 'DEN entry 2/2'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 2/2'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Gaetano', 'familyName': 'Montelione', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 5.7999999999999998, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 303, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_2_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'purityUnit': '%', 'concentration': 0.001, 'isotopicLabelling': '[U-100% 13C; U-100% 15N]', 'concentrationUnit': 'M', 'purity': 95}
  sampleCompKeywds = {'concentration': 0.001, 'concentrationUnit': 'M', 'purity': 95}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  methodKeywds = {'procedure': 'SDS gel electrophoresis'}
  setCurrentStore(proj,'MethodStore')
  puritymethod = Method.Method(proj.currentMethodStore,**methodKeywds)
  samplecomp.purityMethod = puritymethod

  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Inova_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Inova', 'protonFreq': 499.70659999999998, 'details': 'Software version VNMR6.1B'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
#####################
# Molecule number 3 #
#####################

  print " Creating molecule 3..."
  molDict = {'name': 'Ubiquitin'}
  mol = Molecule.Molecule(proj, isFinalised = True, **molDict)
  molSysCode = returnMemopsWord('Ubiquitin')
  molSystem = MolSystem.MolSystem(proj,code = molSysCode)
  print '  Creating chains...'
  mol = proj.findFirstMolecule(name = 'Ubiquitin')
  chain = MolSystem.Chain(molSystem,molecule = mol, code = 'A')

################
# Lab number 3 #
################

  group = findGroup(proj,3)
  print '  Creating entry...'
  #########
  # Entry #
  #########

  # Is effectively reference info for this lab, this molecule
  entryKeywds = {'details': 'Entry origin is from http://www.biochem.ucl.ac.uk/bsm/nmr/ubq/index.html'}
  entryKeywds['name'] = 'DEN entry 3/3'
  entryKeywds['title'] = 'DEN information for the molNumber/labNumber entry 3/3'
  setCurrentStore(proj,'NmrEntryStore')
  entry = Entry.Entry(proj.currentNmrEntryStore, molSystem = molSystem, **entryKeywds)

  # Following are related BMRB entries
  Entry.RelatedEntry(entry, bmrbId = '1520')
  Entry.RelatedEntry(entry, bmrbId = '2573')
  Entry.RelatedEntry(entry, bmrbId = '2574')
  Entry.RelatedEntry(entry, bmrbId = '4132')
  Entry.RelatedEntry(entry, bmrbId = '4245')
  Entry.RelatedEntry(entry, bmrbId = '4375')
  Entry.RelatedEntry(entry, bmrbId = '4493')
  Entry.RelatedEntry(entry, bmrbId = '4663')
  Entry.RelatedEntry(entry, bmrbId = '4769')
  Entry.RelatedEntry(entry, bmrbId = '5101')
  Entry.RelatedEntry(entry, bmrbId = '68')

  # Link to current entry.
  entry.addLaboratory(group)

  print '  Creating contact person..'
  # ----------------------
  # Contact for this entry
  # ----------------------

  curPerson = {'givenName': 'Richard', 'familyName': 'Harris', 'title': 'Dr.'}
  curPersonInGroup = {'position': 'Contact', 'phoneNumbers': ['+44-20-76791354'], 'emailAddress': 'rharris@biochem.ucl.ac.uk', 'faxNumber': '+44-20-76797193'}

  # Following function determines whether person already exists, creates new
  # one if not.

  person = checkPerson(proj,group,curPerson,curPersonInGroup)

  # Link to current entry. Is one-way link from this entry.
  entry.addContactPerson(person)

####################
# Experiment set 1 #
####################

  print '   Creating sample conditions...'
  ########################
  # Sample condition set #
  ########################

  samplecondset = Nmr.SampleConditionSet(nmrProject)
  sampleCondKeywds = {'value': 5.7999999999999998, 'condition': 'pH'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  sampleCondKeywds = {'unit': 'K', 'value': 298, 'condition': 'Temperature'}
  samplecond = Nmr.SampleCondition(samplecondset,**sampleCondKeywds)
  print '   Creating sample...'
  ##########
  # Sample #
  ##########

  sampleKeywds = {'name': 'Sample1'}
  sampleKeywds['sampleCategories'] = [sampleCategory]
  setCurrentStore(proj,'SampleStore')
  sampleKeywds['name'] += '_3_1'
  sample = Sample.Sample(proj.currentSampleStore,**sampleKeywds)
  ###################
  # Sample contents #
  ###################

  compKeywds = {}
  compKeywds['molecule'] = mol
  compKeywds['name'] = mol.name
  # THIS IS A HACK - remove when model updated!
  transDict = {'protein': 'Protein', 'nonPolymer': 'Non Polymer'}
  compTypeName = compKeywds['molecule'].molType
  if compTypeName in transDict.keys():
    compTypeName = transDict[compTypeName]
#NBNB  compKeywds['molComponents'] = compTypeName
  compKeywds['molType'] = compTypeName
  component = setupMolComponent(proj,compKeywds)
#NBNB  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.0016999999999999999, 'isotopicLabelling': 'Both [U-99% 13C; U-98% 15N] and [U-98% 15N]', 'concentrationUnit': 'M', 'details': 'Origin is VLI Research (http://www.vli-research.com/catalog.htm)'}
  sampleCompKeywds = {'concentrationError': 0.0001, 'concentration': 0.0016999999999999999, 'concentrationUnit': 'M', 'details': 'Origin is VLI Research (http://www.vli-research.com/catalog.htm)'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  compKeywds = {'name': 'Phosphate'}
  component = setupSubstance(proj,compKeywds)
  sampleCompKeywds = {'concentrationUnit': 'M'}
  samplecomp = Sample.SampleComponent(sample, refComponent = component, **sampleCompKeywds)
  print '   Creating spectrometers..'
  spectrometers = []
  ###################
  # Spectrometer[0] #
  ###################

  name = 'Varian_Unity+_500'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '500', 'model': 'Unity+', 'protonFreq': 499.83760000000001, 'details': 'Also reported for protonFreq: 499.85462'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[1] #
  ###################

  name = 'Varian_Unity+_600'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '600', 'model': 'Unity+', 'protonFreq': 599.93290000000002, 'details': 'Also reported for protonFreq: 599.93146'}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)
  ###################
  # Spectrometer[2] #
  ###################

  name = 'Varian_Inova_800'

  manufacturer = setupOrganisation(proj,'Varian')
  specKeywds = {'nominalFreq': '800', 'model': 'Inova', 'protonFreq': 800.30470000000003}
  setCurrentStore(proj,'InstrumentStore')
  spectrometer = Instrument.NmrSpectrometer(proj.currentInstrumentStore,name = name, manufacturer= manufacturer,**specKeywds)
  spectrometers.append(spectrometer)

  return proj

def doTest():
  
  start = time.time()
  project = getProject('project',True)
  
  print "Done making in %s \n\n\n"  % (time.time() - start)
  
  start = time.time()
  project.saveModified()
  fileName = project.packageLocator.repositories[0].getFileLocation('memops.Implementation') + '/%s.xml' % project.name
  print 'fileName', fileName
  
  print 'done saving in %s \n\n\n"' % (time.time() - start)
  
  
  start = time.time()
  newProject = XmlIO.load(open(fileName))
  print 'done loading in %s' % (time.time() - start)
  
  start = time.time()
  newProject.backupAll()
  print 'done backing up in %s' % (time.time() - start)
  
  start = time.time()
  newProject.checkAllValid(complete=True)
  print 'done checking up in %s' % (time.time() - start)

if __name__ == '__main__':
  doTest()
by Rasmus Fogh last modified 2007-05-10 16:05

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: