def __init__(
        self,
        name,
        folder_path,
        fasta,
        device,
        level,
        n_iterations_em,
        n_iterations_mcmc,
        is_simu,
        scrambled,
        perform_em,
        use_rippe,
        gl_size_im,
        sample_param,
        thresh_factor,
        output_folder,
    ):
        """Initialize parameters
        """

        self.device = device
        # mouse handling for transforming scene
        self.mouse_down = False
        self.size_points = 6
        self.mouse_old = Vec([0.0, 0.0])
        self.rotate = Vec([0.0, 0.0, 0.0])
        self.translate = Vec([0.0, 0.0, 0.0])
        self.initrans = Vec([0.0, 0.0, -2.0])
        self.scrambled = scrambled
        self.width = 400
        self.height = 400
        self.n_iterations_em = n_iterations_em
        self.n_iterations_mcmc = n_iterations_mcmc
        self.sample_param = sample_param
        self.dt = np.float32(0.01)
        self.white = 1
        self.gl_size_im = gl_size_im

        OpenGL.GLUT.glutInit(sys.argv)
        OpenGL.GLUT.glutInitDisplayMode(
            OpenGL.GLUT.GLUT_RGBA
            | OpenGL.GLUT.GLUT_DOUBLE
            | OpenGL.GLUT.GLUT_DEPTH
        )
        OpenGL.GLUT.glutInitWindowSize(self.width, self.height)
        OpenGL.GLUT.glutInitWindowPosition(0, 0)
        if perform_em:
            name_window = "Expectation Maximization : " + name
        else:
            name_window = "MCMC Metropolis-Hasting : " + name
        self.win = OpenGL.GLUT.glutCreateWindow(name_window)
        # manava = raw_input("do we have a deal?")

        # gets called by GLUT every frame
        OpenGL.GLUT.glutDisplayFunc(self.draw)

        # handle user input
        OpenGL.GLUT.glutKeyboardFunc(self.on_key)
        OpenGL.GLUT.glutMouseFunc(self.on_click)
        OpenGL.GLUT.glutMotionFunc(self.on_mouse_motion)

        # this will call draw every 30 ms
        OpenGL.GLUT.glutTimerFunc(30, self.timer, 30)

        # setup OpenGL scene

        self.glinit()
        # setup CUDA
        self.cuda_gl_init()
        # set up initial conditions
        self.use_rippe = use_rippe

        self.simulation = simulation(
            name,
            folder_path,
            fasta,
            level,
            n_iterations_em,
            is_simu,
            self,
            use_rippe,
            gl_size_im,
            thresh_factor,
            output_folder=output_folder,
        )
        self.gl_size_im = self.simulation.gl_size_im
        self.texid = self.simulation.texid
        self.init_n_frags = self.simulation.init_n_frags
        self.pbo_im_buffer = self.simulation.pbo_im_buffer
        self.pos_vbo = self.simulation.pos_vbo
        self.col_vbo = self.simulation.col_vbo
        self.n_frags = self.simulation.sampler.n_new_frags

        self.str_likelihood = "likelihood = " + str(0)
        self.str_n_contigs = "n contigs = " + str(0)
        self.str_curr_id_frag = "current id frag = " + str(0)
        self.str_curr_cycle = "current cycle = " + str(0)
        self.str_curr_temp = "current temperature = " + str(0)
        self.str_curr_dist = "current dist = " + str(0)
        # if perform_em:
        #     self.start_EM()
        # else:
        #     self.start_MCMC()
        self.collect_likelihood = []
        self.collect_n_contigs = []
        self.collect_mean_len = []
        self.collect_op_sampled = []
        # self.collect_id_f_sampled = []
        self.collect_id_fA_sampled = []
        self.collect_id_fB_sampled = []
        self.collect_full_likelihood = []
        self.collect_dist_from_init_genome = []
        self.collect_fact = []
        self.collect_slope = []
        self.collect_d = []
        self.collect_d_nuc = []
        self.collect_d_max = []
        self.collect_likelihood_nuisance = []
        self.collect_success = []
        self.collect_all = []
        # self.simulation.sampler.eval_likelihood()
        # h = self.simulation.sampler.gpu_full_expected_lin.get()
        # print "non zero h = ", np.nonzero(h>0)[0]
        # self.simulation.sampler.step_nuisance_parameters(0, 0, 0)
        # self.test_model(665, 600)

        self.file_mean_len = os.path.join(
            self.simulation.output_folder, "behaviour_mean_len.pdf"
        )
        self.file_n_contigs = os.path.join(
            self.simulation.output_folder, "behaviour_n_contigs.pdf"
        )

        self.file_fact = os.path.join(
            self.simulation.output_folder, "behaviour_fact.pdf"
        )
        self.file_slope = os.path.join(
            self.simulation.output_folder, "behaviour_slope.pdf"
        )
        self.file_d_nuc = os.path.join(
            self.simulation.output_folder, "behaviour_d_nuc.pdf"
        )
        self.file_d = os.path.join(
            self.simulation.output_folder, "behaviour_d.pdf"
        )
        self.file_d_max = os.path.join(
            self.simulation.output_folder, "behaviour_d_max.pdf"
        )

        self.file_dist_init_genome = os.path.join(
            self.simulation.output_folder, "behaviour_dist_init_genome.pdf"
        )

        self.txt_file_mean_len = os.path.join(
            self.simulation.output_folder, "list_mean_len.txt"
        )
        self.txt_file_n_contigs = os.path.join(
            self.simulation.output_folder, "list_n_contigs.txt"
        )
        self.txt_file_dist_init_genome = os.path.join(
            self.simulation.output_folder, "list_dist_init_genome.txt"
        )
        self.txt_file_likelihood = os.path.join(
            self.simulation.output_folder, "list_likelihood.txt"
        )

        self.txt_file_fact = os.path.join(
            self.simulation.output_folder, "list_fact.txt"
        )
        self.txt_file_slope = os.path.join(
            self.simulation.output_folder, "list_slope.txt"
        )
        self.txt_file_d_nuc = os.path.join(
            self.simulation.output_folder, "list_d_nuc.txt"
        )
        self.txt_file_d = os.path.join(
            self.simulation.output_folder, "list_d.txt"
        )
        self.txt_file_d_max = os.path.join(
            self.simulation.output_folder, "list_d_max.txt"
        )
        self.txt_file_success = os.path.join(
            self.simulation.output_folder, "list_success.txt"
        )
        self.txt_file_list_mutations = os.path.join(
            self.simulation.output_folder, "list_mutations.txt"
        )
        self.file_all_data = os.path.join(
            self.simulation.output_folder, "behaviour_all.txt"
        )
def __init__ ( self , name , folder_path , fasta , device , level , n_iterations_em , n_iterations_mcmc , is_simu , scrambled , perform_em , use_rippe , gl_size_im , sample_param , thresh_factor , output_folder , ) : self . device = device self . mouse_down = False self . size_points = 6 self . mouse_old = Vec ( [ 0.0 , 0.0 ] ) self . rotate = Vec ( [ 0.0 , 0.0 , 0.0 ] ) self . translate = Vec ( [ 0.0 , 0.0 , 0.0 ] ) self . initrans = Vec ( [ 0.0 , 0.0 , - 2.0 ] ) self . scrambled = scrambled self . width = 400 self . height = 400 self . n_iterations_em = n_iterations_em self . n_iterations_mcmc = n_iterations_mcmc self . sample_param = sample_param self . dt = np . float32 ( 0.01 ) self . white = 1 self . gl_size_im = gl_size_im OpenGL . GLUT . glutInit ( sys . argv ) OpenGL . GLUT . glutInitDisplayMode ( OpenGL . GLUT . GLUT_RGBA | OpenGL . GLUT . GLUT_DOUBLE | OpenGL . GLUT . GLUT_DEPTH ) OpenGL . GLUT . glutInitWindowSize ( self . width , self . height ) OpenGL . GLUT . glutInitWindowPosition ( 0 , 0 ) if perform_em : name_window = "Expectation Maximization : " + name else : name_window = "MCMC Metropolis-Hasting : " + name self . win = OpenGL . GLUT . glutCreateWindow ( name_window ) OpenGL . GLUT . glutDisplayFunc ( self . draw ) OpenGL . GLUT . glutKeyboardFunc ( self . on_key ) OpenGL . GLUT . glutMouseFunc ( self . on_click ) OpenGL . GLUT . glutMotionFunc ( self . on_mouse_motion ) OpenGL . GLUT . glutTimerFunc ( 30 , self . timer , 30 ) self . glinit ( ) self . cuda_gl_init ( ) self . use_rippe = use_rippe self . simulation = simulation ( name , folder_path , fasta , level , n_iterations_em , is_simu , self , use_rippe , gl_size_im , thresh_factor , output_folder = output_folder , ) self . gl_size_im = self . simulation . gl_size_im self . texid = self . simulation . texid self . init_n_frags = self . simulation . init_n_frags self . pbo_im_buffer = self . simulation . pbo_im_buffer self . pos_vbo = self . simulation . pos_vbo self . col_vbo = self . simulation . col_vbo self . n_frags = self . simulation . sampler . n_new_frags self . str_likelihood = "likelihood = " + str ( 0 ) self . str_n_contigs = "n contigs = " + str ( 0 ) self . str_curr_id_frag = "current id frag = " + str ( 0 ) self . str_curr_cycle = "current cycle = " + str ( 0 ) self . str_curr_temp = "current temperature = " + str ( 0 ) self . str_curr_dist = "current dist = " + str ( 0 ) self . collect_likelihood = [ ] self . collect_n_contigs = [ ] self . collect_mean_len = [ ] self . collect_op_sampled = [ ] self . collect_id_fA_sampled = [ ] self . collect_id_fB_sampled = [ ] self . collect_full_likelihood = [ ] self . collect_dist_from_init_genome = [ ] self . collect_fact = [ ] self . collect_slope = [ ] self . collect_d = [ ] self . collect_d_nuc = [ ] self . collect_d_max = [ ] self . collect_likelihood_nuisance = [ ] self . collect_success = [ ] self . collect_all = [ ] self . file_mean_len = os . path . join ( self . simulation . output_folder , "behaviour_mean_len.pdf" ) self . file_n_contigs = os . path . join ( self . simulation . output_folder , "behaviour_n_contigs.pdf" ) self . file_fact = os . path . join ( self . simulation . output_folder , "behaviour_fact.pdf" ) self . file_slope = os . path . join ( self . simulation . output_folder , "behaviour_slope.pdf" ) self . file_d_nuc = os . path . join ( self . simulation . output_folder , "behaviour_d_nuc.pdf" ) self . file_d = os . path . join ( self . simulation . output_folder , "behaviour_d.pdf" ) self . file_d_max = os . path . join ( self . simulation . output_folder , "behaviour_d_max.pdf" ) self . file_dist_init_genome = os . path . join ( self . simulation . output_folder , "behaviour_dist_init_genome.pdf" ) self . txt_file_mean_len = os . path . join ( self . simulation . output_folder , "list_mean_len.txt" ) self . txt_file_n_contigs = os . path . join ( self . simulation . output_folder , "list_n_contigs.txt" ) self . txt_file_dist_init_genome = os . path . join ( self . simulation . output_folder , "list_dist_init_genome.txt" ) self . txt_file_likelihood = os . path . join ( self . simulation . output_folder , "list_likelihood.txt" ) self . txt_file_fact = os . path . join ( self . simulation . output_folder , "list_fact.txt" ) self . txt_file_slope = os . path . join ( self . simulation . output_folder , "list_slope.txt" ) self . txt_file_d_nuc = os . path . join ( self . simulation . output_folder , "list_d_nuc.txt" ) self . txt_file_d = os . path . join ( self . simulation . output_folder , "list_d.txt" ) self . txt_file_d_max = os . path . join ( self . simulation . output_folder , "list_d_max.txt" ) self . txt_file_success = os . path . join ( self . simulation . output_folder , "list_success.txt" ) self . txt_file_list_mutations = os . path . join ( self . simulation . output_folder , "list_mutations.txt" ) self . file_all_data = os . path . join ( self . simulation . output_folder , "behaviour_all.txt" )
Initialize parameters