Ejemplo n.º 1
0
 def parse(self, files = None):
   if files is None:
     if len(self.files) <= 0:
       # Error("Attempted to parse without files available", type="Fatal")
       files = dircache.listdir("data")
       print "Using all files found in data/ directory"
       print "%s" % (", ".join(files))
     else:
       files = self.files
   badfiles = []
   for file in files:
     try:
       _f = open("data/%s" % (file), "r")
       _chain = Chain(file)
       _nodes = []
       for line in _f:
         if line.strip():
           try:
             name, x, y, z = line.split()
           except: 
             print "Error in line: '%s'" % (line)
             globals.shutdown()
           x = float(x)
           y = float(y)
           z = float(z)
           _nodes.append(Node(name, x, y, z))
           if len(_nodes) == 2:
             _bond = Bond(_nodes[0], _nodes[1])
             _chain.add_bond(_bond)
             _nodes = []
       globals.chains.append(_chain)
     except IOError as (no, err): 
       badfiles.append("data/%s" % (file))
Ejemplo n.º 2
0
 def parse(self, files=None):
     if files is None:
         if len(self.files) <= 0:
             # Error("Attempted to parse without files available", type="Fatal")
             files = dircache.listdir("data")
             print "Using all files found in data/ directory"
             print "%s" % (", ".join(files))
         else:
             files = self.files
     badfiles = []
     for file in files:
         try:
             _f = open("data/%s" % (file), "r")
             _chain = Chain(file)
             _nodes = []
             for line in _f:
                 if line.strip():
                     try:
                         name, x, y, z = line.split()
                     except:
                         print "Error in line: '%s'" % (line)
                         globals.shutdown()
                     x = float(x)
                     y = float(y)
                     z = float(z)
                     _nodes.append(Node(name, x, y, z))
                     if len(_nodes) == 2:
                         _bond = Bond(_nodes[0], _nodes[1])
                         _chain.add_bond(_bond)
                         _nodes = []
             globals.chains.append(_chain)
         except IOError as (no, err):
             badfiles.append("data/%s" % (file))
Ejemplo n.º 3
0
def start():
	# The tasks for this function are as follows
	# @TODO: This is being updated regularly and is not in a final form
	# 
	# - setup and manage the process pool for the head-node that has
	# 	the following responsibilities
	# 	- user-interface activity (responsiveness and display real-time data)
        #	- receive MPI messages passed from the child-nodes
	#	- send MPI messages to the child-nodes
	#	- manage appropriate actions through the logic controller
	#	- manage the database interface (as a sub-process)
	# @TODO: tbc...

        # start the dispatcher process
        # it is accessible from here on out in globals manager and can be accessed by name
        globals.manager.new_process(run=com.dispatcher, name="dispatcher")

        # start the service that will be listening for the reports from the child nodes
        globals.manager.new_process(run=com.publisher, name="publisher")
        
        # Error("The size of the graph of nodes is %d" % (globals.comm.size))

        # need to set the chains object in the global namespace (head-only)
        globals.chains = []
        
        # need to set the parser object
        globals.parser = parser()

        # Need to start the GUI
        # TEMPORARY !--------------------------------
        
        # READ FILENAMES ONE AT A TIME UNTIL BLANK
        print "Please enter filenames space-delimited then press enter,"
        print "or press enter to use all available chains in the data/ directory"
        files = raw_input("\r: ")
        if files == "":
          globals.parser.parse()
        else:
          globals.parser.set_files(files, True)
        #--------------------------------------------
        print "Done parsing"
        
        print "Printing chains:"
        for chain in globals.chains:
          print ""
          print "Name: %s" % (chain.name)
          for bond in chain.bonds:
            print bond
          print ""

        # globals.manager.close()
        # exit

        globals.shutdown()
Ejemplo n.º 4
0
def Error(message, type = "Debug"):
  stack = traceback.extract_stack(limit=2)
  caller = stack[0][2]
  file = stack[0][0]
  line = stack[0][1]
  print "Caught : %s => %s" % (type, message)
  print "\t["
  print "\t  node    => %s" % globals.name
  print "\t  process => %s" % globals.rank
  print "\t  pid     => %d" % os.getpid()
  print "\t  caller  => %s" % caller
  print "\t  file    => %s" % file
  print "\t  line    => %s" % line
  print "\t]"
  if type == "Fatal":
    globals.shutdown()