Пример #1
0
    def test_file_invalid(self, invalid_table_alignment):
        """Tests that the invalid alignment files fail properly.

        Args:
            invalid_table_alignment (pytest.fixture): A parameterized pytest
                fixture providing invalid table alignment filenames.
        """
        with open(invalid_table_alignment) as in_table:
            with pytest.raises(dr.AlignmentIOError):
                dr.read_table_alignment_flo(in_table)
Пример #2
0
    def test_stringio_valid(self, valid_table_alignment):
        """Tests that valid table alignment files are loaded correctly.

        Tests that the valid alignment files do not fail when loaded into
        StringIO objects.

        Args:
            valid_table_alignment (pytest.fixture): A parameterized pytest
                fixture providing valid table alignment filenames.

        Raises:
            AssertionError: Raised if an exception is thrown when reading.
        """
        with open(valid_table_alignment) as in_table:
            table_stringio = StringIO()
            table_stringio.write(in_table.read())
            table_stringio.seek(0)
            try:
                sequence_list = dr.read_table_alignment_flo(table_stringio)
                assert len(sequence_list) > 0
                for i in sequence_list:
                    assert isinstance(i, Sequence)
                    assert isinstance(i.name, str)
                    assert len(i.cont_values) > 0
            except Exception as e:
                print('Raised exception: {}'.format(str(e)))
                raise AssertionError(e)
Пример #3
0
    def test_stringio_invalid(self, invalid_table_alignment):
        """Tests that invalid table alignment files cause a failure.

        Tests that the invalid alignment files fail properly when loaded into
        StringIO objects.

        Args:
            invalid_table_alignment (pytest.fixture): A parameterized pytest
                fixture providing invalid table alignment filenames.
        """
        with open(invalid_table_alignment) as in_table:
            table_stringio = StringIO()
            table_stringio.write(in_table.read())
            table_stringio.seek(0)
            with pytest.raises(dr.AlignmentIOError):
                dr.read_table_alignment_flo(table_stringio)
Пример #4
0
    def test_file_valid(self, valid_table_alignment):
        """Tests that the valid alignment files do not fail.

        Args:
            valid_table_alignment (pytest.fixture): A parameterized pytest
                fixture providing valid table alignment filenames.
        """
        with open(valid_table_alignment) as in_table:
            try:
                sequence_list = dr.read_table_alignment_flo(in_table)
                assert len(sequence_list) > 0
                for i in sequence_list:
                    assert isinstance(i, Sequence)
                    assert isinstance(i.name, string_formats)
                    assert len(i.cont_values) > 0
            except Exception as e:
                print('Raised exception: {}'.format(str(e)))
                assert False
Пример #5
0
            args.pam_filename))

    # Read data
    if args.data_format == 'csv':
        with open(args.pam_filename) as in_file:
            sequences, headers = data_readers.read_csv_alignment_flo(in_file)
    elif args.data_format == 'json':
        with open(args.pam_filename) as in_file:
            sequences, headers = data_readers.read_json_alignment_flo(in_file)
    elif args.data_format == 'phylip':
        with open(args.pam_filename) as in_file:
            sequences = data_readers.read_phylip_alignment_flo(in_file)
        headers = None
    elif args.data_format == 'table':
        with open(args.pam_filename) as in_file:
            sequences = data_readers.read_table_alignment_flo(in_file)
        headers = None
    else:
        raise Exception('Unknown data format: {}'.format(args.data_format))

    # Get the label annotation column, or None
    # label_column = None
    # if args.annotate_labels is not None:
    #     try:
    #         # Try looking for the string
    #         label_column = headers.index(args.annotate_labels)
    #     except:
    #         try:
    #             # Treat it as an integer
    #             label_column = int(args.annotate_labels)
    #         except: