コード例 #1
0
ファイル: Assemble_GUI.py プロジェクト: jostasche/assemble
 def OnGenerate(self,e):
     
     try:
         editlength_f=int(self.editlength.GetValue())
     except ValueError:
         self.parent.parent.errorPopup("length should be an integer number\n greater than 0!","ERROR!")
         return -1
     
     if editlength_f<=0:
         self.parent.parent.errorPopup("length should be an integer number\n greater than 0!","ERROR!")
         return -1
 
     perc=[]
     test=0.0
     for index in xrange(0,self.lc.GetItemCount(),1):
         percentage=float(self.lc.GetItem(index,1).GetText())
         test+=percentage
         perc.append([self.lc.GetItem(index,0).GetText(),percentage])
                                 
     if test!=100.0:
         self.parent.parent.errorPopup("Sum of percentages equal to %s (100 is expected)!\nTreating given values as ratios..."%test,"WARNING!")
         for i in xrange(0,len(perc),1):
             perc[i][1]/=float(test)
             perc[i][1]*=100.0
         #self.parent.parent.errorPopup("Sum of percentages is equal to %s! 100 is expected!"%test,"ERROR!")
         #return -1
     
     try:
         chain=A.make_chain(editlength_f, perc)
     except:
         print "ERROR: something unexpected happened during chain generation, how weird..."
         return -1
     
     self.editchain.SetValue(chain)
コード例 #2
0
    def test_example_works(self):
        """ Tests that small example works"""

        # Small given test case
        dbg_assembler = Assemble.Assembler(
            fragments_fasta=file("Data/coding_challenge_data_set_example.txt"))
        assembled_sequence = dbg_assembler.assemble()
        self.assertEqual(assembled_sequence, "ATTAGACCTGCCGGAATAC")
コード例 #3
0
    def test_fail_on_euler_impossible(self):
        """ If it's impossible to make the graph Eulerian, output an understandable error"""

        non_eulerian_assembler = \
            Assemble.Assembler(fragments_fasta=file("Data/coding_challenge_data_set_example_made_non_eulerian.txt"))

        # Gives a reasonable error
        with self.assertRaises(AssertionError):
            non_eulerian_assembler.assemble()
コード例 #4
0
    def OnGenerate(self, e):

        try:
            editlength_f = int(self.editlength.GetValue())
        except ValueError:
            self.parent.parent.errorPopup(
                "length should be an integer number\n greater than 0!",
                "ERROR!")
            return -1

        if editlength_f <= 0:
            self.parent.parent.errorPopup(
                "length should be an integer number\n greater than 0!",
                "ERROR!")
            return -1

        perc = []
        test = 0.0
        for index in range(0, self.lc.GetItemCount(), 1):
            percentage = float(self.lc.GetItem(index, 1).GetText())
            test += percentage
            perc.append([self.lc.GetItem(index, 0).GetText(), percentage])

        if test != 100.0:
            self.parent.parent.errorPopup(
                "Sum of percentages equal to %s (100 is expected)!\nTreating given values as ratios..."
                % test, "WARNING!")
            for i in range(0, len(perc), 1):
                perc[i][1] /= float(test)
                perc[i][1] *= 100.0
            #self.parent.parent.errorPopup("Sum of percentages is equal to %s! 100 is expected!"%test,"ERROR!")
            #return -1

        try:
            chain = A.make_chain(editlength_f, perc)
        except:
            print(
                "ERROR: something unexpected happened during chain generation, how weird..."
            )
            return -1

        self.editchain.SetValue(chain)
コード例 #5
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")
コード例 #6
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!")