Exemplo n.º 1
0
    def __init__(self, trackGroup, ringModel, posScale, colorIndices):
        NodePath.__init__(self)
        self.assign(hidden.attachNewNode(\
            base.localAvatar.uniqueName('ring-group')))

        self.__period = trackGroup.period
        self.__reverseFlag = trackGroup.reverseFlag
        self.__tOffset = trackGroup.tOffset
        self.__numRings = len(trackGroup.tracks)

        self.__rings = []
        self.__ringModels = []
        for i in range(0,self.__numRings):
            track = trackGroup.tracks[i]
            tOffset = trackGroup.trackTOffsets[i]
            ring = Ring.Ring(track,
                             tOffset,
                             posScale)
            ring.reparentTo(self)

            model = ringModel.copyTo(ring)
            model.setColor(RingGameGlobals.ringColors[colorIndices[i]][1])

            self.__rings.append(ring)
            self.__ringModels.append(model)
Exemplo n.º 2
0
    def assign_ring_positions(self):
        for ring in self.rings:
            c1 = c2 = c3 = c4 = c5 = o5 = False
            for atom in ring:
                if not self.isO5(atom):
                    self.atoms[atom].set_axial(self.is_axial(atom))

                if not c1 and self.isC1(atom):
                    self.atoms[atom].set_sugar_position("C1")
                    c1 = self.atoms[atom]
                elif not c2 and self.isC2(atom):
                    self.atoms[atom].set_sugar_position("C2")
                    c2 = self.atoms[atom]
                elif not c3 and self.isC3(atom):
                    self.atoms[atom].set_sugar_position("C3")
                    c3 = self.atoms[atom]
                elif not c4 and self.isC4(atom):
                    self.atoms[atom].set_sugar_position("C4")
                    c4 = self.atoms[atom]
                elif not c5 and self.isC5(atom):
                    self.atoms[atom].set_sugar_position("C5")
                    c5 = self.atoms[atom]
                elif not o5 and self.isO5(atom):
                    self.atoms[atom].set_sugar_position("O5")
                    o5 = self.atoms[atom]

            if c1 and c2 and c3 and c4 and c5 and o5:
                self.Rings[self.ringHash(ring)] = Ring(c1, c2, c3, c4, c5, o5,
                                                       self.atoms)
            else:
                raise Exception
Exemplo n.º 3
0
def test():
    try:
        dis = distance.distance()
        print('Distance: %.2f cm' % dis)
        if dis < LIMIT:
            Ring.Ring()
            time.sleep(0.2)
    except KeyboardInterrupt:
        print('User press CTRL+C, exit')
        sys.exit()
Exemplo n.º 4
0
def main():
    message = "salut"
    message2 = "toast"
    message3 = "salut"
    message4 = "bidon"
    issue = "2"
    userNumber = 3
    id = 1
    id2 = 2
    G, g = buildG()
    ring, userArray = Ring.myCreateRing(userNumber, g, G, q)
    signature = Sign(message, issue, ring.pKeys, userArray[id], G, g,
                     userArray)
    signature2 = Sign(message2, issue, ring.pKeys, userArray[id2], G, g,
                      userArray)
    signature3 = Sign(message3, issue, ring.pKeys, userArray[id], G, g,
                      userArray)
    signature4 = Sign(message4, issue, ring.pKeys, userArray[id], G, g,
                      userArray)

    #TESTS

    print("Verif of message and his signature : ")
    print(Verify(issue, ring.pKeys, message, signature, G, g, userArray))

    print("\nVerif of message2 and another signature : ")
    print(Verify(issue, ring.pKeys, message2, signature, G, g, userArray))

    print("\nVerif of message2 and his signature : ")
    print(Verify(issue, ring.pKeys, message2, signature2, G, g, userArray))

    print("\nTrace of different message by different people :")
    print(
        Trace(issue, ring.pKeys, g, G, message, signature, message2,
              signature2))

    print("\nTrace of same message by the same person :")
    print(
        Trace(issue, ring.pKeys, g, G, message, signature, message3,
              signature3))

    print("\nTrace of different message by the same person :")
    print(
        Trace(issue, ring.pKeys, g, G, message, signature, message4,
              signature4))
Exemplo n.º 5
0
import Ring
from itertools import permutations, combinations

n = 5
carrier = list(range(0, n))
print('carrier: ', carrier)
list_of_permutations = list(permutations(range(0, n)))
# all possible rows of the multiplication table (without the zero and one columns)
list_of_permutations1 = list(permutations(range(0, n), n - 2))
# choose n-1 distinct rows (it doesnt harm to order them with combinations instead of permutations)
for table_plus in combinations(list_of_permutations, n):

    def plus(x, y):
        return table_plus[x][y]

    Ring.__init__(carrier, 0, 1, plus,
                  plus)  # the 2nd plus is redundant for now
    # any structure generated so far satisfies Ring.has_minus() because we use permutations
    if Ring.has_zero() and Ring.plus_is_associative():
        # choose n-2 distinct rows (the first two rows are determined by the properties of zero and one)
        for table_mult in permutations(list_of_permutations1, n - 2):

            def mult(x, y):
                if x == 0:
                    return 0
                elif y == 0:
                    return 0
                elif x == 1:
                    return y
                elif y == 1:
                    return x
                else:
Exemplo n.º 6
0
    def Set_Up_FF(self, run_orca=True, local=True):
        if run_orca:
            print "Setting up Orca input script"
            # Write Orca Input File
            File_Name = self.Name + ".inp"
            File = open(File_Name, 'w')
            File.write(
                '! RKS B3LYP 6-31+G** NormalSCF Opt NOSOSCF CHELPG PAL8\n\n')
            File.write('*xyz 0 1\n')
            for Atom_Obj in self.Atom_List:
                File.write('%s %.5f %.5f %.5f\n' %
                           (Atom_Obj.Element, Atom_Obj.Position[0],
                            Atom_Obj.Position[1], Atom_Obj.Position[2]))
            File.write('*')
            File.close()
            Finished = False

            File_Out = self.Name + ".out"
            if local:
                #Run subprocess on local machine

                os.system('mkdir Orca')
                os.system('mv %s ./Orca' % File_Name)
                os.chdir('./Orca')
                File_Out = self.Name + ".out"
                try:
                    File = open(File_Out, 'r')
                except:
                    os.system(
                        '/usr/local/share/orca_3_0_0_macosx_openmpi165/orca %s > %s'
                        % (File_Name, File_Out))  # Run Orca Job

            else:
                print "Running Orca Geometry Optimization on Comet"
                cmd = "mkdir " + Configure.Comet_Path % self.Name
                subprocess.call(["ssh", Configure.Comet_Login, cmd])
                subtemp = Configure.Template_Path + "sub_orca_temp"
                submit = "submit_orca"
                Path = Configure.Comet_Path % self.Name
                # Write submit script
                with open(subtemp) as f:
                    template = f.read()
                s = template.format(Comet_Path=Path,
                                    Orca_Path=Configure.Orca_Path,
                                    name=self.Name)
                with open(submit, "w") as f:
                    f.write(s)

                # Copy Files over  to Comet
                os.system(Configure.c2c % (submit, self.Name))
                os.system(Configure.c2c % (File_Name, self.Name))
                # Run job
                os.system(Configure.c2l % (self.Name, File_Out))
                try:
                    File = open(File_Out, 'r')
                except:
                    subprocess.call([
                        "ssh", Configure.Comet_Login,
                        Configure.SBATCH % (self.Name, submit)
                    ])

                i = 0
                while not Finished:
                    os.system(Configure.c2l % (self.Name, File_Out))
                    try:
                        File = open(File_Out, 'r')
                        File_Lines = File.readlines()
                        print File_Lines[-1]
                        if File_Lines[-1].split(
                                ' ')[0] == "TOTAL" or self.UnConverged:
                            Finished = True
                        else:
                            print "Not Finished"
                            i += 10
                            print "Sleeping process", i, "Minutes"
                            time.sleep(600)
                    except:
                        print "Sleeping process", i, "miniutes"
                        time.sleep(600)
                        i += 10

        else:
            os.chdir('./Orca')

        File_Out = self.Name + ".out"

        # Extract info from Orca output file
        Orca_File = open(File_Out, 'r')
        File_Lines = Orca_File.readlines()
        print "Extracting Redundant Coordinates..."
        for i in range(len(File_Lines)):
            Line = File_Lines[i].strip('\n').split()
            #print Line
            Found = False
            try:
                if Line[0] == "Redundant" and self.UnConverged:
                    Redundant = True
                    j = i + 6
                    k = 0
                    while Redundant:
                        R_Line = File_Lines[j]
                        R_Line = R_Line.split()
                        print R_Line
                        try:
                            if int(R_Line[0].strip('.')) >= 1:
                                j = j + 1
                                Type = R_Line[1].split('(')[0]
                                k += 1
                                # Extract Bonds
                                if Type == "B":
                                    Master_ID = int(R_Line[2].split(',')[0])
                                    Slave_ID = int(R_Line[3].split(')')[0])
                                    req = float(R_Line[-1])
                                    self.Atom_List[Master_ID].Bond_List.append(
                                        self.Atom_List[Slave_ID])
                                    self.Atom_List[Slave_ID].Bond_List.append(
                                        self.Atom_List[Master_ID])
                                    self.Bond_List.append(
                                        Bond.Bond(self.Atom_List[Master_ID],
                                                  self.Atom_List[Slave_ID],
                                                  req))
                                # Extract Angles
                                if Type == "A":
                                    Master_ID = int(R_Line[3].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[4].split(')')[0])
                                    Angle_Eq = float(R_Line[-1])
                                    self.Angle_List.append(
                                        Angle.Angle(self.Atom_List[Master_ID],
                                                    self.Atom_List[Slave1_ID],
                                                    self.Atom_List[Slave2_ID],
                                                    Angle_Eq))
                                if Type == "D":
                                    Master1_ID = int(R_Line[3].split(',')[0])
                                    Master2_ID = int(R_Line[4].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[5].split(')')[0])
                                    Dihedral_Eq = float(R_Line[-1])
                                    self.Dihedral_List.append(
                                        Dihedral.Dihedral(
                                            self.Atom_List[Master1_ID],
                                            self.Atom_List[Master2_ID],
                                            self.Atom_List[Slave1_ID],
                                            self.Atom_List[Slave2_ID],
                                            Dihedral_Eq))
                        except:
                            Redundant = False
                            Found = True
                            print k

                if Found:
                    break

                elif Line[0] == "Redundant" and (
                        File_Lines[i + 2].strip('\n').split()[1]
                        == "Optimized"):
                    print "Found redundant internal coordinates"
                    Redundant = True
                    j = i + 7
                    while Redundant:
                        R_Line = File_Lines[j]
                        R_Line = R_Line.split()
                        try:
                            if int(R_Line[0].strip('.')) >= 1:
                                j = j + 1
                                Type = R_Line[1].split('(')[0]
                                # Extract Bonds
                                if Type == "B":
                                    Master_ID = int(R_Line[2].split(',')[0])
                                    Slave_ID = int(R_Line[3].split(')')[0])
                                    req = float(R_Line[-1])
                                    self.Atom_List[Master_ID].Bond_List.append(
                                        self.Atom_List[Slave_ID])
                                    self.Atom_List[Slave_ID].Bond_List.append(
                                        self.Atom_List[Master_ID])
                                    self.Bond_List.append(
                                        Bond.Bond(self.Atom_List[Master_ID],
                                                  self.Atom_List[Slave_ID],
                                                  req))
                                # Extract Angles
                                if Type == "A":
                                    Master_ID = int(R_Line[3].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[4].split(')')[0])
                                    Angle_Eq = float(R_Line[-1])
                                    self.Angle_List.append(
                                        Angle.Angle(self.Atom_List[Master_ID],
                                                    self.Atom_List[Slave1_ID],
                                                    self.Atom_List[Slave2_ID],
                                                    Angle_Eq))
                                if Type == "D":
                                    Master1_ID = int(R_Line[3].split(',')[0])
                                    Master2_ID = int(R_Line[4].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[5].split(')')[0])
                                    Dihedral_Eq = float(R_Line[-1])
                                    self.Dihedral_List.append(
                                        Dihedral.Dihedral(
                                            self.Atom_List[Master1_ID],
                                            self.Atom_List[Master2_ID],
                                            self.Atom_List[Slave1_ID],
                                            self.Atom_List[Slave2_ID],
                                            Dihedral_Eq))
                        except:
                            Redundant = False

                if Line[0] == "CHELPG" and len(
                        Line) == 2 and not self.UnConverged:
                    for j in range(self.N):
                        Chelp_Line = File_Lines[i + 2 + j].split()
                        index = int(Chelp_Line[0])
                        charge = float(Chelp_Line[3])
                        self.Atom_List[index].Charge = charge

                if Line[0] == "CARTESIAN" and Line[2] == "(ANGSTROEM)":
                    for j in range(self.N):
                        XYZ_Line = File_Lines[i + 2 + j].split()
                        Position_Temp = np.array([
                            float(XYZ_Line[1]),
                            float(XYZ_Line[2]),
                            float(XYZ_Line[3])
                        ],
                                                 dtype=float)
                        self.Atom_List[j].Position = Position_Temp
            except:
                continue
        print "Redundant Internal Coordinates and ChelpG partial charges Extracted"
        print "Bond_List = ", len(self.Bond_List)

        if not run_orca:
            os.chdir('..')

        if local:
            os.chdir('..')

        print "Optimized XYZ Coordinates:\n"
        for Atom_Obj in self.Atom_List:
            # Finds OPLS Types and Classes
            print Atom_Obj.Atom_ID, Atom_Obj.Element, Atom_Obj.Position, sorted(
                [Atomobj.Element for Atomobj in Atom_Obj.Bond_List])
        print "----------------------------------"
        # Find all the ring units in the molecule and add them to the ring list
        self.Ring_List = Ring.create_rings(self.Atom_List)

        return
Exemplo n.º 7
0
    def __init__(self, master, ser=""):
        
            
        #create base path for storing files, temperature curves, etc:
        if not os.path.exists(self.basePath):
            #os.chdir('/home/pi/Desktop/')
            os.mkdir(self.basePath)
            os.chown(self.basePath, 1000, 1000)

        #create dictionary to store all classes that will be used
        usedClasses = dict() 

        ##create the mainframe
        frame = tk.Frame()
        frame.grid(row=0, column=0, rowspan=1, columnspan=1)
        
        row1Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row2Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row3Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row4Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        
        if serialAvail == True:
            # for Arduino Uno from RPi
            #self.ser = serial.Serial('/dev/ttyACM0', 115200)
            # for Arduino Nano from RPi
            self.ser = serial.Serial('/dev/ttyUSB0', 9600)
#            ser = serial.Serial('/dev/ttyUSB0', 4800,timeout=0.05)
        ##show the pieces of the GUI
        ##depending on which flags are on (see above):
        

        
        ###CAMERA###
        if self.cameraFlag == 1:
            
            
            import Camera
            self.frameCam = tk.Frame(master=row2Frame, bd=3)
            self.frameCam.pack(side="top")
            self.Camera = Camera.Camera(parent=self.frameCam,
                                        label="CAMERA",
                                        basePath=self.basePath)

            usedClasses["camera"] = self.Camera
        else:
            usedClasses["camera"] = 0
        ###LED1###
        if self.led1Flag == 1:
            import LED
            
            self.frameLed1 = tk.Frame(row1Frame, bd=3)
            self.frameLed1.grid(row=0, column=0, sticky="NW")

            self.LED1 = LED.LED(parent=self.frameLed1, label="LED 1",
                          onAdd=self.led1OnAdd, offAdd=self.led1OffAdd,
                          zapDurAdd=self.led1ZapDurAdd, ser=self.ser,
                          #prot=self.prot,
                          #protFrame=self.frameProt,
                          )
            led1Off = self.led1OffAdd
            self.ser.write(led1Off.encode('utf-8'))

#            usedClasses["led1"] = self.LED1
            usedClasses["led1"] = 1
            #print (self.LED1)
        else:
            usedClasses["led1"] = 0
        ###LED2###
        if self.led2Flag == 1:
            import LED
            self.frameLed2 = tk.Frame(row1Frame, bd=3)
            self.frameLed2.grid(row=0, column=1, sticky="NW")
            self.LED2 = LED.LED(parent=self.frameLed2, label="LED 2",
                          onAdd=self.led2OnAdd, offAdd=self.led2OffAdd,
                          zapDurAdd=self.led2ZapDurAdd, ser=self.ser,
                          
                          #prot=self.prot, protFrame=self.frameProt,
                          )
            led2Off = self.led2OffAdd
            self.ser.write(led2Off.encode('utf-8'))
#            usedClasses["led2"] = self.LED2
            usedClasses["led2"] = 1
        else:   
            usedClasses["led2"] = 0


        ###MATRIX###
        if self.matrixFlag == 1:
            import Matrix
            self.frameMatrix = tk.Frame(row1Frame, bd=3)
            self.frameMatrix.grid(row=0, column=2, sticky="W",)
            self.Matrix = Matrix.Matrix(parent=self.frameMatrix, label="MATRIX",
                               pat3Add=self.matPat3Add,pat4Add=self.matPat4Add, offAdd=self.matOffAdd,
                               pat1Add=self.matPat1Add, pat2Add=self.matPat2Add,
                               brightAdd=self.matBrightAdd,
                
                               ser=self.ser
                               )
            matOff = self.matOffAdd
            self.ser.write(matOff.encode('utf-8'))
            usedClasses["matrix"] = 1#self.Matrix
        else:   
            usedClasses["matrix"] = 0

        ###RING###
        if self.ringFlag == 1:
            import Ring
            self.frameRing = tk.Frame(row1Frame, bd=3)
            self.frameRing.grid(row=1, column=0, sticky="NW",
                                columnspan=3, rowspan=1)

            self.Ring = Ring.Ring(parent=self.frameRing, label="RING",
                             ringOnAdd=self.ringOnAdd,
                             ringOffAdd=self.ringOffAdd,
                             ringZapAdd=self.ringZapAdd,
                             redAdd=self.ringRedAdd,
                             greenAdd=self.ringGreenAdd,
                             blueAdd=self.ringBlueAdd,
                             allAdd=self.ringAllAdd,
                             rotAdd=self.ringRotAdd,
                             ser=self.ser)

            ringOff=self.ringOffAdd
            self.ser.write(ringOff.encode('utf-8'))
            usedClasses["ring"] = 1#self.Ring
        else:   
            usedClasses["ring"] = 0
            
        ###PELTIER###
        if self.peltierFlag == 1:
            import Peltier
            self.framePelt = tk.Frame(row4Frame, bd=3)
            self.framePelt.pack(side="left")
            self.Peltier = Peltier.Peltier(parent=self.framePelt,
                                           label="PELTIER",
                                           onAdd=self.peltOnAdd,
                                           offAdd=self.peltOffAdd,
                                           tempAdd=self.peltTempAdd,
                                           basePath=self.basePath,
                                           ser=self.ser)
            peltOff = self.peltOffAdd
            self.ser.write(peltOff.encode('utf-8'))
            usedClasses["peltier"] = 1#self.Peltier
            
        else:   
            usedClasses["peltier"] = 0


        ###Auto Focus###
        if self.autofocusFlag == 1:
            import AutoFocus
            self.frameAuto = tk.Frame(row4Frame, bd=3)
            self.frameAuto.pack(side="left")
            self.AutoFocus = AutoFocus.AutoFocus(parent=self.frameAuto,
                                           label="Focus",
                                           velAdd=self.autoFocusAdd,
                                           ser=self.ser)
            servoOff=str(self.autoFocusAdd)+"*"+ str(0)+"*"
            self.ser.write(servoOff.encode('utf-8'))

        ###Protocol###
        if self.protocolFlag == 1:
            import Protocol
            
            self.frameProt = tk.Frame(master=row3Frame,
                                      bd=3,
                                      relief="ridge")
            self.frameProt.pack(side="top")
            self.Protocol = Protocol.Protocol(parent = self.frameProt,
                                              usedClasses=usedClasses,
                                              basePath = self.basePath+"/protocol/",
                                              label="Protocols",ser=self.ser,
                                              timingAdd=self.timeAdd)
#            print(self.timeAdd)
            #self.prot = True
            #self.protocol = Protocol(parent=self.frameProt, ser=self.ser)

        else:
            self.frameProt = ""
            self.prot = False
	##mock up###
        if self.mockupFlag == 1:
            import Mock_up
            self.frameMock = tk.Frame(row4Frame, bd=3)
            self.frameMock.pack(side="left")
            self.Mockup= Mock_up.Mock_up(parent=self.frameMock,
                                           label="mock_up",
                                           ser=self.ser)

        ###QUIT###
        if self.quitFlag == 1:
            self.frameQuit = tk.Frame(master=row4Frame)
            self.frameQuit.pack(side="right")
            #self.frameQuit.grid(row=5, column=2, sticky="NW")
            self.quitAPP(parent=self.frameQuit)

        #draw all frames on screen
        row4Frame.grid(row=5, column=0, sticky="NWE", columnspan=1)
        row1Frame.grid(row=1, column=0, sticky="NWE", columnspan=1)
        row3Frame.grid(row=1, column=2, sticky="NWE")
        row2Frame.grid(row=0, column=0, sticky="NWE", columnspan=1)
# Max length genome for any individual in intial population
maxInitGenomeLen = 50
# Max length gemone for any individual at any time.
maxLenGenome = 50
# Maximum number of generation to evolve the population over
maxGenerations = 1000
# Print Genomes?
debugGenomes = True
numDebugGenomes = 5

# Initialize the population...
print "Initializing the population"
population = []
for i in range(popSize):
    # Add the individual to the population and their starting fitness of zero.  Form of [fitness, genome]
    population.append([0, Ring.Ring([random.choice(['C','D'])] + \
        [RandomBase() for i in range(random.randint(0,maxInitGenomeLen))])]) # Sets the rest of the player.

print "Beginning Evolution!"

# Evolve until the halt criteria is met.
for j in range(maxGenerations):
        
    # Reset fitness scores for this round
    for individual in population:
        individual[0] = 0.0
        
    # Mutate some survivors
    for individual in population:
        for base in range(len(individual[1])):
            if random.random() < mutationChance:
                individual[1][base] = RandomBase()
Exemplo n.º 9
0
    def Set_Up_FF(self, run_orca=True, local= True):
        if run_orca:
            print "Setting up Orca input script"
            # Write Orca Input File
            File_Name = self.Name + ".inp"
            File = open(File_Name, 'w')
            File.write('! RKS B3LYP 6-31+G** NormalSCF Opt NOSOSCF CHELPG PAL8\n\n')
            File.write('*xyz 0 1\n')
            for Atom_Obj in self.Atom_List:
                File.write('%s %.5f %.5f %.5f\n' % ( Atom_Obj.Element, Atom_Obj.Position[0], Atom_Obj.Position[1],Atom_Obj.Position[2]))
            File.write('*')
            File.close()
            Finished = False
            
            File_Out = self.Name + ".out"
            if local:
                #Run subprocess on local machine
                
                
                os.system('mkdir Orca')
                os.system('mv %s ./Orca' % File_Name)
                os.chdir('./Orca')
                File_Out = self.Name + ".out"
                try:
                    File = open(File_Out,'r')
                except:
                    os.system('/usr/local/share/orca_3_0_0_macosx_openmpi165/orca %s > %s' %(File_Name, File_Out)) # Run Orca Job
            
            
            else:
                print "Running Orca Geometry Optimization on Comet"
                cmd = "mkdir " + Configure.Comet_Path % self.Name
                subprocess.call(["ssh", Configure.Comet_Login, cmd])
                subtemp = Configure.Template_Path + "sub_orca_temp"
                submit = "submit_orca"
                Path = Configure.Comet_Path % self.Name
                # Write submit script
                with open(subtemp) as f:
                    template = f.read()
                s = template.format(Comet_Path=Path, Orca_Path = Configure.Orca_Path, name = self.Name )
                with open(submit ,"w") as f:
                    f.write(s)
            
                # Copy Files over  to Comet
                os.system( Configure.c2c % (submit, self.Name))
                os.system( Configure.c2c % (File_Name, self.Name))
                # Run job
                os.system( Configure.c2l % (self.Name, File_Out))
                try:
                    File = open(File_Out,'r')
                except:
                    subprocess.call(["ssh",Configure.Comet_Login, Configure.SBATCH % (self.Name, submit)])


                i = 0
                while not Finished:
                    os.system( Configure.c2l % (self.Name, File_Out))
                    try:
                        File = open(File_Out,'r')
                        File_Lines = File.readlines()
                        print File_Lines[-1]
                        if File_Lines[-1].split(' ')[0] == "TOTAL" or self.UnConverged:
                            Finished = True
                        else:
                            print "Not Finished"
                            i += 10
                            print "Sleeping process", i, "Minutes"
                            time.sleep(600)
                    except:
                        print "Sleeping process", i, "miniutes"
                        time.sleep(600)
                        i += 10
    
    
            
    
    
        else:
            os.chdir('./Orca')
        
        File_Out = self.Name + ".out"
        
        # Extract info from Orca output file
        Orca_File = open(File_Out, 'r')
        File_Lines = Orca_File.readlines()
        print "Extracting Redundant Coordinates..."
        for i in range(len(File_Lines)):
            Line = File_Lines[i].strip('\n').split()
            #print Line
            Found = False
            try:
                if Line[0] == "Redundant" and self.UnConverged:
                    Redundant = True
                    j = i + 6
                    k = 0
                    while Redundant:
                        R_Line = File_Lines[j]
                        R_Line = R_Line.split()
                        print R_Line
                        try:
                            if int(R_Line[0].strip('.')) >= 1:
                                j = j + 1
                                Type = R_Line[1].split('(')[0]
                                k += 1
                                # Extract Bonds
                                if Type == "B":
                                    Master_ID = int(R_Line[2].split(',')[0])
                                    Slave_ID = int(R_Line[3].split(')')[0])
                                    req = float(R_Line[-1])
                                    self.Atom_List[Master_ID].Bond_List.append(self.Atom_List[Slave_ID])
                                    self.Atom_List[Slave_ID].Bond_List.append(self.Atom_List[Master_ID])
                                    self.Bond_List.append( Bond.Bond(self.Atom_List[Master_ID], self.Atom_List[Slave_ID], req))
                                # Extract Angles
                                if Type == "A":
                                    Master_ID = int(R_Line[3].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[4].split(')')[0])
                                    Angle_Eq = float(R_Line[-1])
                                    self.Angle_List.append( Angle.Angle(self.Atom_List[Master_ID], self.Atom_List[Slave1_ID], self.Atom_List[Slave2_ID], Angle_Eq))
                                if Type == "D":
                                    Master1_ID = int(R_Line[3].split(',')[0])
                                    Master2_ID = int(R_Line[4].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[5].split(')')[0])
                                    Dihedral_Eq = float(R_Line[-1])
                                    self.Dihedral_List.append(Dihedral.Dihedral(self.Atom_List[Master1_ID],self.Atom_List[Master2_ID], self.Atom_List[Slave1_ID], self.Atom_List[Slave2_ID], Dihedral_Eq))
                        except:
                            Redundant = False
                            Found = True
                            print k
            
                if Found:
                    break
                
                elif Line[0] == "Redundant" and (File_Lines[i+2].strip('\n').split()[1] == "Optimized"):
                    print "Found redundant internal coordinates"
                    Redundant = True
                    j = i + 7
                    while Redundant:
                        R_Line = File_Lines[j]
                        R_Line = R_Line.split()
                        try:
                            if int(R_Line[0].strip('.')) >= 1:
                                j = j + 1
                                Type = R_Line[1].split('(')[0]
                                # Extract Bonds
                                if Type == "B":
                                    Master_ID = int(R_Line[2].split(',')[0])
                                    Slave_ID = int(R_Line[3].split(')')[0])
                                    req = float(R_Line[-1])
                                    self.Atom_List[Master_ID].Bond_List.append(self.Atom_List[Slave_ID])
                                    self.Atom_List[Slave_ID].Bond_List.append(self.Atom_List[Master_ID])
                                    self.Bond_List.append( Bond.Bond(self.Atom_List[Master_ID], self.Atom_List[Slave_ID], req))
                                # Extract Angles
                                if Type == "A":
                                    Master_ID = int(R_Line[3].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[4].split(')')[0])
                                    Angle_Eq = float(R_Line[-1])
                                    self.Angle_List.append( Angle.Angle(self.Atom_List[Master_ID], self.Atom_List[Slave1_ID], self.Atom_List[Slave2_ID], Angle_Eq))
                                if Type == "D":
                                    Master1_ID = int(R_Line[3].split(',')[0])
                                    Master2_ID = int(R_Line[4].split(',')[0])
                                    Slave1_ID = int(R_Line[2].split(',')[0])
                                    Slave2_ID = int(R_Line[5].split(')')[0])
                                    Dihedral_Eq = float(R_Line[-1])
                                    self.Dihedral_List.append(Dihedral.Dihedral(self.Atom_List[Master1_ID],self.Atom_List[Master2_ID], self.Atom_List[Slave1_ID], self.Atom_List[Slave2_ID], Dihedral_Eq))
                        except:
                            Redundant = False
    
                if Line[0] == "CHELPG" and len(Line) == 2 and not self.UnConverged:
                    for j in range(self.N):
                        Chelp_Line = File_Lines[i+2+j].split()
                        index = int(Chelp_Line[0])
                        charge = float(Chelp_Line[3])
                        self.Atom_List[index].Charge = charge
                
                if Line[0] == "CARTESIAN" and Line[2] == "(ANGSTROEM)":
                    for j in range(self.N):
                        XYZ_Line = File_Lines[i+2+j].split()
                        Position_Temp = np.array( [float(XYZ_Line[1]) ,float(XYZ_Line[2]) ,float(XYZ_Line[3])], dtype = float)
                        self.Atom_List[j].Position = Position_Temp
            except:
                continue
        print "Redundant Internal Coordinates and ChelpG partial charges Extracted"
        print "Bond_List = ", len(self.Bond_List)
        
        if not run_orca:
            os.chdir('..')
        
        if local:
            os.chdir('..')
        
        print "Optimized XYZ Coordinates:\n"
        for Atom_Obj in self.Atom_List:
            # Finds OPLS Types and Classes
            print Atom_Obj.Atom_ID, Atom_Obj.Element, Atom_Obj.Position, sorted([ Atomobj.Element for Atomobj in Atom_Obj.Bond_List ])
        print "----------------------------------"

        
        # Find all the ring units in the molecule and add them to the ring list
        self.Ring_List = Ring.create_rings(self.Atom_List)
        
        return
                        color="b",
                        linestyle='None',
                        ms=10.0)

    ContourPlt.plot(KD1,
                    KD2,
                    marker="o",
                    color="cyan",
                    linestyle='None',
                    ms=10.0)
    plt.draw()


if ShowRingCurve:
    import Ring as RingData
    Ring = RingData.Ring3()

PlotA0 = "MaxFrac"


def UpdateAxes():
    global KD1, KD2

    if ShowRingCurve:
        global Ring
        RingKD = np.sqrt(KD1 * KD2)
        Ring.SetKD(RingKD)
        Ring.SetDeg(Deg)
        RingConc = A0Range[A0Target]
        Ring.SetConc0(RingConc)