Ejemplo n.º 1
0
 def test_one_and_four(self):
     """Tests combining two non-zero lists"""
     one_seq_file = os.path.join(data_dir, 'Hsap_AP1G_OneSeq.fa')
     four_seqs_file = os.path.join(data_dir, 'Hsap_AP1G_FourSeqs.fa')
     one_record = sequence_file._get_sequences(one_seq_file)
     four_records = sequence_file._get_sequences(four_seqs_file)
     self.assertEqual(
         len(sequence_file._cat_sequence_lists(one_record, four_records)),
         5)
Ejemplo n.º 2
0
 def setUp(self):
     """Makes a temporary directory in 'tests/fixtures'"""
     self.tmpdir = os.path.join(data_dir, 'tmp')
     try:
         os.makedirs(self.tmpdir)
     except FileExistsError:
         pass  # already made
     self.one_seq_file = os.path.join(data_dir, 'Hsap_AP1G_OneSeq.fa')
     self.four_seqs_file = os.path.join(data_dir, 'Hsap_AP1G_FourSeqs.fa')
     self.one_record = sequence_file._get_sequences(self.one_seq_file)
     self.four_records = sequence_file._get_sequences(self.four_seqs_file)
     self.cat_list = sequence_file._cat_sequence_lists(
         self.one_record, self.four_records)
Ejemplo n.º 3
0
    def _parse_infiles(self):
        """Reads infiles to create ScrollSeq objects.

        Assumes that the input files have already been checked and are
        appropriate (no duplicates/empty/non-existent files).

        Args:
            (self.infiles)

        Returns:
            modifies internal _seq_dict and _groups variables
        """
        for file_path in self.infiles:
            group = os.path.basename(file_path).split('.', 1)[0]
            if not len(group) > 0:  # This should never happen in reality
                group = str(self._group_counter)
                self._group_counter += 1
            assert isinstance(group, str)
            # Files are unique, but need to check groups; two different
            # filepaths could lead to the same group name
            group = self._unique_group_name(group)
            # Now get SeqRecords using BioPython
            records = sf._get_sequences(
                file_path,
                self._file_format,
            )
            scroll_seqs = self._make_scroll_seqs(
                file_path,
                group,
                records,
            )
            # Update internal objects
            self._groups.append(group)
            self._seq_dict[group] = scroll_seqs
Ejemplo n.º 4
0
    def setUp(self):
        """Creates a new ScrollCollection Object"""
        # Populate ARGS values of config file
        load_config_file()
        try:
            config.add_section('ARGS')
        except DuplicateSectionError:
            pass
        # Now provide sufficient arg defaults
        config['ARGS']['filter'] = 'False'
        config['ARGS']['filter_method'] = 'zscore'
        config['ARGS']['dist_matrix'] = 'LG'
        config['ARGS']['no_clobber'] = 'True'

        ids = (1, 2, 3, 4)
        infile = os.path.join(data_dir, 'Hsap_AP1G_FourSeqs.fa')
        records = sf._get_sequences(infile)
        self.seq_list = []
        for id_num, seq_record in zip(ids, records):
            self.seq_list.append(
                ScrollSeq(
                    id_num,  # ID
                    infile,  # infile
                    id_num,  # Group; not important here
                    SeqRecord=seq_record))
        self.tmpdir = os.path.join(data_dir, 'tmp')
        try:
            os.makedirs(self.tmpdir)
        except FileExistsError:
            pass  # tmpdir still present
        self.collection = ScrollCollection(
            self.tmpdir,  # outdir
            self.seq_list,  # sequence list
            'one',  # group
            'Mafft',  # align_method
            'RAxML',  # dist_method
        )
Ejemplo n.º 5
0
 def test_four_sequences(self):
     """Tests that parsing four sequences works fine."""
     four_seqs_file = os.path.join(data_dir, 'Hsap_AP1G_FourSeqs.fa')
     records = sequence_file._get_sequences(four_seqs_file)
     self.assertEqual(len(records), 4)
Ejemplo n.º 6
0
 def test_one_sequence(self):
     """Tests that parsing one sequence works fine."""
     one_seq_file = os.path.join(data_dir, 'Hsap_AP1G_OneSeq.fa')
     records = sequence_file._get_sequences(one_seq_file)
     self.assertEqual(len(records), 1)