コード例 #1
0
ファイル: Assemble_GUI.py プロジェクト: jostasche/assemble
            int(self.S.setgridz.GetValue())
        except:
            self.errorPopup("box z size must be an integer number!", "ERROR!")
            return
                    
        if int(self.S.setgridx.GetValue())==0 or int(self.S.setgridy.GetValue())==0 or int(self.S.setgridx.GetValue())==0:
            self.errorPopup("box information contains zero values. System generation will be skipped...", "WARNING!")     
                    
        try:
            self.makeFile(fname)
        except Exception, e:
            self.errorPopup("problem in input file!\n"%e, "ERROR!")
            return

        #try:
        A.run(fname)
        #except Exception, e:
        #    self.errorPopup("polymer generation failed!\n%s"%e, "ERROR!")
        #    return
            
        #os.remove(dbname)
        os.remove(fname)
        
        self.errorPopup("Files generation complete!", "SUCCESS!")

            
    def makeFile(self,fname):
        
        fout=open(fname,"w")
        
        fout.write("mode gromacs\n")
コード例 #2
0
    def OnMake(self, event):

        #dbname="db_tmp"
        #try:
        #    self.db.save(dbname)
        #except:
        #    self.errorPopup("could not prepare database!", "ERROR!")
        #    return

        #check that concentrations are 100%. If one element only, force 100%, else check sum
        if self.P.lc.GetItemCount() == 1:
            self.P.lc.SetStringItem(0, 4, str(100.0))

        else:
            conc = 0
            for i in range(0, self.P.lc.GetItemCount(), 1):
                c = self.P.lc.GetItem(itemIdx=i, col=4).GetText()
                try:
                    conc += float(c)
                except:
                    self.errorPopup(
                        "concentration of polymer %s must be\na number between 0 and 100!"
                        % self.P.lc.GetItem(itemIdx=i, col=0).GetText(),
                        "ERROR!")
                    return

            #if conc!=100:
            #self.errorPopup("sum of polymer concentrations is equal to %s (expected 100)\nTreating concentrations as ratios!"%conc, "WARNING!")
            ##self.errorPopup("sum of polymer concentrations\n should be equal to 100 percent!", "ERROR!")
            ##return

        #check box size information consistency
        try:
            int(self.S.setgridx.GetValue())
        except:
            self.errorPopup("box x size must be an integer number!", "ERROR!")
            return

        try:
            int(self.S.setgridy.GetValue())
        except:
            self.errorPopup("box y size must be an integer number!", "ERROR!")
            return

        try:
            int(self.S.setgridz.GetValue())
        except:
            self.errorPopup("box z size must be an integer number!", "ERROR!")
            return

        if int(self.S.setgridx.GetValue()) == 0 or int(
                self.S.setgridy.GetValue()) == 0 or int(
                    self.S.setgridx.GetValue()) == 0:
            self.errorPopup(
                "box information contains zero values. System generation will be skipped...",
                "WARNING!")

        fname_in = "input_tmp"
        dirname = os.path.dirname(os.path.realpath(__file__))
        fname = os.path.join(dirname, fname_in)

        try:
            self.makeFile(fname)
        except Exception as e:
            self.errorPopup("problem in input file!\n" % e, "ERROR!")
            #os.remove(dbname)
            os.remove(fname)
            return

        try:
            A.run(fname)
        except Exception as e:
            self.errorPopup("polymer generation failed!\n%s" % e, "ERROR!")
            #os.remove(dbname)
            os.remove(fname)
            return

        #os.remove(dbname)
        os.remove(fname)

        self.errorPopup("Files generation complete!", "SUCCESS!")