コード例 #1
0
def test_msa_join__three_msa():
    expected = MSA((
        FASTA("nc", None, "ACGTGAAAG"),
        FASTA("nm", None, "TGACTTGAG"),
        FASTA("miRNA", None, "UCAGACCAU"),
    ))
    result = MSA.join(_JOIN_MSA_1, _JOIN_MSA_2, _JOIN_MSA_3)
    assert result == expected
コード例 #2
0
def test_msa_join__two_msa():
    expected = MSA((
        FASTA("nc", None, "ACGTGA"),
        FASTA("nm", None, "TGACTT"),
        FASTA("miRNA", None, "UCAGAC"),
    ))
    result = MSA.join(_JOIN_MSA_1, _JOIN_MSA_2)
    assert result == expected
コード例 #3
0
ファイル: formats.py プロジェクト: muslih14/paleomix
    def _run(self, _config, temp):
        merged_msas = []
        for (name, files_dd) in sorted(self._infiles.iteritems()):
            partitions = files_dd["partitions"]
            msas = dict((key, []) for key in partitions)
            for filename in files_dd["filenames"]:
                msa = MSA.from_file(filename)
                if self._excluded:
                    msa = msa.exclude(self._excluded)

                for (key, msa_part) in msa.split(partitions).iteritems():
                    msas[key].append(msa_part)

            msas.pop("X", None)
            for (key, msa_parts) in sorted(msas.iteritems()):
                merged_msa = MSA.join(*msa_parts)
                if self._reduce:
                    merged_msa = merged_msa.reduce()

                if merged_msa is not None:
                    merged_msas.append(("%s_%s" % (name, key),
                                        merged_msa))

        out_fname_phy = reroot_path(temp, self._out_prefix + ".phy")
        with open(out_fname_phy, "w") as output_phy:
            final_msa = MSA.join(*(msa for (_, msa) in merged_msas))
            output_phy.write(interleaved_phy(final_msa))

        partition_end = 0
        out_fname_parts = reroot_path(temp, self._out_prefix + ".partitions")
        with open(out_fname_parts, "w") as output_part:
            for (name, msa) in merged_msas:
                length = msa.seqlen()
                output_part.write("DNA, %s = %i-%i\n"
                                  % (name,
                                     partition_end + 1,
                                     partition_end + length))
                partition_end += length
コード例 #4
0
ファイル: formats.py プロジェクト: tmancill/paleomix
    def _run(self, _config, temp):
        merged_msas = []
        for (name, files_dd) in sorted(self._infiles.items()):
            partitions = files_dd["partitions"]
            msas = dict((key, []) for key in partitions)
            for filename in files_dd["filenames"]:
                msa = MSA.from_file(filename)
                if self._excluded:
                    msa = msa.exclude(self._excluded)

                for (key, msa_part) in msa.split(partitions).items():
                    msas[key].append(msa_part)

            msas.pop("X", None)
            for (key, msa_parts) in sorted(msas.items()):
                merged_msa = MSA.join(*msa_parts)
                if self._reduce:
                    merged_msa = merged_msa.reduce()

                if merged_msa is not None:
                    merged_msas.append(("%s_%s" % (name, key), merged_msa))

        out_fname_phy = reroot_path(temp, self._out_prefix + ".phy")
        with open(out_fname_phy, "w") as output_phy:
            final_msa = MSA.join(*(msa for (_, msa) in merged_msas))
            output_phy.write(interleaved_phy(final_msa))

        partition_end = 0
        out_fname_parts = reroot_path(temp, self._out_prefix + ".partitions")
        with open(out_fname_parts, "w") as output_part:
            for (name, msa) in merged_msas:
                length = msa.seqlen()
                output_part.write(
                    "DNA, %s = %i-%i\n" %
                    (name, partition_end + 1, partition_end + length))
                partition_end += length
コード例 #5
0
ファイル: formats.py プロジェクト: muslih14/paleomix
    def _run(self, _config, temp):
        msa = MSA.join(*(MSA.from_file(filename) for filename in sorted(self.input_files)))

        with open(reroot_path(temp, self._out_phy), "w") as output:
            output.write(interleaved_phy(msa, add_flag = self._add_flag))
コード例 #6
0
ファイル: msa_test.py プロジェクト: MikkelSchubert/paleomix
def test_msa_join__missing_arguments():
    MSA.join()
コード例 #7
0
ファイル: msa_test.py プロジェクト: MikkelSchubert/paleomix
def test_msa_join__three_msa():
    expected = MSA((FASTA("nc",    None, "ACGTGAAAG"),
                    FASTA("nm",    None, "TGACTTGAG"),
                    FASTA("miRNA", None, "UCAGACCAU")))
    result = MSA.join(_JOIN_MSA_1, _JOIN_MSA_2, _JOIN_MSA_3)
    assert_equal(result, expected)
コード例 #8
0
ファイル: msa_test.py プロジェクト: MikkelSchubert/paleomix
def test_msa_join__two_msa():
    expected = MSA((FASTA("nc",    None, "ACGTGA"),
                    FASTA("nm",    None, "TGACTT"),
                    FASTA("miRNA", None, "UCAGAC")))
    result = MSA.join(_JOIN_MSA_1, _JOIN_MSA_2)
    assert_equal(result, expected)
コード例 #9
0
ファイル: msa_test.py プロジェクト: MikkelSchubert/paleomix
def test_msa_join__single_msa():
    result = MSA.join(_JOIN_MSA_1)
    assert_equal(result, _JOIN_MSA_1)
コード例 #10
0
ファイル: msa_test.py プロジェクト: jelber2/paleomix
def test_msa_join__missing_arguments():
    MSA.join()
コード例 #11
0
ファイル: msa_test.py プロジェクト: jelber2/paleomix
def test_msa_join__single_msa():
    result = MSA.join(_JOIN_MSA_1)
    assert_equal(result, _JOIN_MSA_1)
コード例 #12
0
def test_msa_join__missing_arguments():
    with pytest.raises(TypeError):
        MSA.join()
コード例 #13
0
def test_msa_join__single_msa():
    result = MSA.join(_JOIN_MSA_1)
    assert result == _JOIN_MSA_1
コード例 #14
0
    def _run(self, _config, temp):
        msa = MSA.join(*(MSA.from_file(filename)
                         for filename in sorted(self.input_files)))

        with open(reroot_path(temp, self._out_phy), "w") as output:
            output.write(interleaved_phy(msa, add_flag=self._add_flag))