예제 #1
0
    def __init__(self,
                 project=None,
                 project_path=os.getcwd(),
                 genbank=GenBank,
                 **kwargs):
        """Initialize the MultipleSequenceAlignment class.

        :param project: The project name.
        :param project_path:  The path to the project.
        :param genbank: The composer parameter which is used to configure the
                        GenBank class with the MSA class.
        :param kwargs:  The kwargs are used with the dispatcher as a way to
                        control the alignment pipeline.
        :returns: If the kwargs are utilized with YAML or other
                  configurations, then this class returns an alignment
        dictionary, which can be parsed to run specific alignment algorithms.
        """
        self.dispatcher_options = {
            "Guidance_config": ["GUIDANCE2", self.guidance2],
            "Pal2Nal_config": ["PAL2NAL", self.pal2nal],
            "ClustalO_config": ["CLUSTALO", self.clustalo]
        }
        # Set up loggers
        __log = LogIt()
        __logfile = None
        self.guidancelog = __log.default('guidance2', __logfile)
        self.pal2nallog = __log.default('pal2nal', __logfile)
        self.clustalolog = __log.default('clustalo', __logfile)

        # stop_codons = ['TAG', 'TAA', 'TGA']

        self.program = None
        self.alignment_dict = {}
        self.project = project
        self.project_path = project_path
        if project_path and project:
            self.project_path = Path(project_path) / Path(project)

        # Configuration of class attributes
        add_self = attribute_config(self,
                                    composer=genbank,
                                    checker=GenBank,
                                    project=project,
                                    project_path=project_path)
        for var, attr in add_self.__dict__.items():
            setattr(self, var, attr)

        # Determine which alignment to configure
        # And then run that alignment with the configuration.
        for config in self.dispatcher_options.keys():
            if config in kwargs.keys():
                program = self.dispatcher_options[config][0]
                aligner = self.dispatcher_options[config][1]
                aligner_configuration = kwargs[config]
                self.alignment_dict[program] = [aligner, aligner_configuration]
예제 #2
0
 def test_logit(self):
     """Test the LogIt class."""
     logit = LogIt()
     test = logit.default(logname='testlog', logfile=self.logfile)
     self.assertEqual(str(test.name), 'TESTLOG')
     self.assertTrue(os.path.isfile(self.logfile))
     logit.shutdown()
     logit.deletelog(self.logfile)