コード例 #1
0
ファイル: align_test.py プロジェクト: UCL/cathpy
    def test_merge_aln(self):
        aln_ref = Align.from_fasta(self.fasta_aln_ref)
        self.assertEqual(aln_ref.count_sequences, 2)
        aln_merge1 = Align.from_fasta(self.fasta_aln_merge1)
        self.assertEqual(aln_merge1.count_sequences, 3)
        aln_merge2 = Align.from_fasta(self.fasta_aln_merge2)
        self.assertEqual(aln_merge2.count_sequences, 3)

        aln_ref.merge_alignment(aln_merge1, 'ref1')
        expected_aln_after_merge1 = Align.from_fasta(
            self.fasta_aln_after_merge1)
        self.assertEqual(expected_aln_after_merge1.count_sequences, 4)
        self.assertEqual([s.uid for s in aln_ref.seqs], [
            'ref1', 'ref2', 'src1.1', 'src1.2', ])

        aln_ref.merge_alignment(aln_merge2, 'ref2')
        expected_aln_after_merge2 = Align.from_fasta(
            self.fasta_aln_after_merge2)
        self.assertEqual(expected_aln_after_merge2.count_sequences, 6)
        self.assertEqual([s.uid for s in aln_ref.seqs], [
            'ref1', 'ref2', 'src1.1', 'src1.2', 'src2.1', 'src2.2', ])

        sto_tmp = tempfile.NamedTemporaryFile(
            mode='w+', delete=True, suffix='.sto')
        sto_out = sto_tmp.name

        aln_ref.add_groupsim()
        aln_ref.add_scorecons()
        aln_ref.write_sto(sto_out)
コード例 #2
0
    def test_scorecons(self):
        sc = util.ScoreconsRunner()
        aln = Align.from_fasta(self.example_fasta_file)
        sc_res = sc.run_fasta(self.example_fasta_file)
        self.assertEqual(sc_res.dops, 92.889)
        self.assertEqual(len(sc_res.scores), aln.aln_positions)
        del aln

        aln = Align.from_stockholm(self.example_sto_file)
        sc_res = sc.run_stockholm(self.example_sto_file)
        self.assertEqual(sc_res.dops, 61.529)
        self.assertEqual(len(sc_res.scores), aln.aln_positions)
コード例 #3
0
ファイル: align_test.py プロジェクト: UCL/cathpy
    def test_write_sto(self):

        sto_tmp = tempfile.NamedTemporaryFile(mode='w+', delete=True)
        sto_out = sto_tmp.name

        aln = Align.from_stockholm(self.stockholm_file)

        self.assertEqual(aln.uid, '1.10.8.10/FF/14534')

        # make sure we have parsed the meta data okay
        first_seq = aln.get_seq_at_offset(0)
        seq_meta = first_seq.meta
        self.assertEqual(seq_meta['AC'], 'Q96CS3')
        self.assertEqual(seq_meta['OS'], 'H**o sapiens')
        self.assertEqual(seq_meta['DE'], 'FAS-associated factor 2')
        LOG.info('first seq: %s', repr(vars(first_seq)))

        LOG.info('Writing out tmp STOCKHOLM file to %s', sto_out)
        aln.write_sto(sto_out)

        sto_expected = ''
        with open(self.stockholm_file, 'r') as io:
            # some lines seem to have trailing spaces
            for line in io:
                sto_expected += line.strip() + '\n'

        with open(sto_out, 'r') as io:
            sto_got = io.read()

        self.maxDiff = None
        self.assertMultiLineEqual(sto_got, sto_expected)
コード例 #4
0
    def test_meta_summary(self):
        aln = Align.from_stockholm(self.stockholm_file)
        meta_info = aln.get_meta_summary()

        self.assertEqual(meta_info.ec_term_counts, None)
        self.assertEqual(
            meta_info.go_term_counts, {
                'GO:0005515': 2,
                'GO:0005576': 2,
                'GO:0005783': 3,
                'GO:0005811': 3,
                'GO:0030433': 4,
                'GO:0030970': 3,
                'GO:0031625': 3,
                'GO:0034098': 3,
                'GO:0034389': 3,
                'GO:0035473': 3,
                'GO:0035578': 2,
                'GO:0043130': 3,
                'GO:0043312': 2,
                'GO:0055102': 3
            })
        self.assertEqual(meta_info.cath_domain_count, 1)
        self.assertEqual(meta_info.seq_count, 51)
        self.assertEqual(meta_info.dops_score, 61.529)
        self.assertEqual(
            meta_info.organism_newick,
            "((((((((((((((H**o,(Gorilla_gorilla)'Gorilla Gorilla gorilla (1)',Pan)'Homininae H**o (5)',(Pongo)'Ponginae Pongo (1)')'Hominidae Homininae (6)')'Hominoidea Hominidae (6)',(((Chlorocebus,Macaca,Papio)'Cercopithecinae Chlorocebus (3)')'Cercopithecidae Cercopithecinae (3)')'Cercopithecoidea Cercopithecidae (3)')'Catarrhini Hominoidea (9)')'Simiiformes Catarrhini (9)')'Haplorrhini Simiiformes (9)')'Primates Haplorrhini (9)',(((((Mus)'Mus Mus (1)',Rattus)'Murinae Mus (2)')'Muridae Murinae (2)')'Myomorpha Muridae (2)',((Heterocephalus,Fukomys)'Bathyergidae Heterocephalus (2)')'Hystricomorpha Bathyergidae (2)')'Rodentia Myomorpha (4)',((Oryctolagus)'Leporidae Oryctolagus (1)')'Lagomorpha Leporidae (1)')'Euarchontoglires Primates (14)',(((((Bos)'Bovinae Bos (1)')'Bovidae Bovinae (1)')'Pecora Bovidae (1)')'Ruminantia Pecora (1)',((Camelus)'Camelidae Camelus (1)')'Tylopoda Camelidae (1)',((((Pteropus)'Pteropodinae Pteropus (1)')'Pteropodidae Pteropodinae (1)')'Megachiroptera Pteropodidae (1)',((Myotis)'Vespertilionidae Myotis (1)')'Microchiroptera Vespertilionidae (1)')'Chiroptera Megachiroptera (2)',((((Felis)'Felinae Felis (1)')'Felidae Felinae (1)')'Feliformia Felidae (1)',(((Canis_lupus)'Canis Canis lupus (1)')'Canidae Canis (1)',(((Mustela_putorius)'Mustela Mustela putorius (1)')'Mustelinae Mustela (1)')'Mustelidae Mustelinae (1)')'Caniformia Canidae (2)')'Carnivora Feliformia (3)',(((Equus)'Equus Equus (2)')'Equidae Equus (2)')'Perissodactyla Equidae (2)')'Laurasiatheria Ruminantia (9)',(((Loxodonta)'Elephantidae Loxodonta (1)')'Proboscidea Elephantidae (1)')'Afrotheria Proboscidea (1)')'Mammalia Euarchontoglires (24)',(((((((Silurana)'Xenopus Silurana (4)')'Xenopodinae Xenopus (4)',(Hymenochirus)'Pipinae Hymenochirus (1)')'Pipidae Xenopodinae (5)')'Pipoidea Pipidae (5)')'Anura Pipoidea (5)')'Batrachia Anura (5)')'Amphibia Batrachia (5)',((((((Ophiophagus)'Elapinae Ophiophagus (1)')'Elapidae Elapinae (1)')'Colubroidea Elapidae (1)')'Serpentes Colubroidea (1)')'Squamata Serpentes (1)')'Lepidosauria Squamata (1)',(((((((((Poeciliopsis,Xiphophorus,Poecilia)'Poeciliinae Poeciliopsis (4)')'Poeciliidae Poeciliinae (4)',(Fundulus)'Fundulidae Fundulus (1)')'Cyprinodontoidei Poeciliidae (5)')'Cyprinodontiformes Cyprinodontoidei (5)',((((Oryzias)'Oryziinae Oryzias (1)')'Adrianichthyidae Oryziinae (1)')'Adrianichthyoidei Adrianichthyidae (1)')'Beloniformes Adrianichthyoidei (1)')'Atherinomorphae Cyprinodontiformes (6)',((((Astyanax)'Characidae Astyanax (1)')'Characoidei Characidae (1)')'Characiformes Characoidei (1)')'Characiphysae Characiformes (1)',((((Gasterosteus)'Gasterosteidae Gasterosteus (1)')'Gasterosteales Gasterosteidae (1)')'Cottioidei Gasterosteales (1)')'Perciformes Cottioidei (1)',((((Takifugu)'Tetraodontidae Takifugu (1)')'Tetradontoidea Tetraodontidae (1)')'Tetraodontoidei Tetradontoidea (1)')'Tetraodontiformes Tetraodontoidei (1)',((((Danio)'Cyprinidae Danio (2)')'Cyprinoidea Cyprinidae (2)')'Cypriniformes Cyprinoidea (2)')'Cypriniphysae Cypriniformes (2)',(((((Oreochromis)'Oreochromini Oreochromis (1)')'Pseudocrenilabrinae Oreochromini (1)')'Cichlidae Pseudocrenilabrinae (1)')'Cichliformes Cichlidae (1)')'Cichlomorphae Cichliformes (1)',(((Oncorhynchus)'Salmoninae Oncorhynchus (1)')'Salmonidae Salmoninae (1)')'Salmoniformes Salmonidae (1)')'Teleostei Atherinomorphae (13)',(((Lepisosteus)'Lepisosteidae Lepisosteus (1)')'Semionotiformes Lepisosteidae (1)')'Holostei Semionotiformes (1)')'Neopterygii Teleostei (14)')'Actinopteri Neopterygii (14)')'Actinopterygii Actinopteri (14)',(((((Gallus)'Phasianinae Gallus (1)')'Phasianidae Phasianinae (1)')'Galliformes Phasianidae (1)',((Picoides)'Picidae Picoides (1)')'Piciformes Picidae (1)',((((Taeniopygia)'Estrildinae Taeniopygia (1)')'Estrildidae Estrildinae (1)')'Passeroidea Estrildidae (1)',(Ficedula)'Muscicapidae Ficedula (1)')'Passeriformes Passeroidea (2)')'Neognathae Galliformes (4)')'Aves Neognathae (4)',((((Callorhinchus)'Callorhinchidae Callorhinchus (1)')'Chimaeriformes Callorhinchidae (1)')'Holocephali Chimaeriformes (1)')'Chondrichthyes Holocephali (1)',((Latimeria)'Coelacanthidae Latimeria (1)')'Coelacanthiformes Coelacanthidae (1)',(((Alligator)'Alligatorinae Alligator (1)')'Alligatoridae Alligatorinae (1)')'Crocodylia Alligatoridae (1)')'Craniata Mammalia (51)')'Chordata Craniata (51)')'Metazoa Chordata (51)')'Eukaryota Metazoa (51)')'ROOT (51)';"
        )
コード例 #5
0
ファイル: util.py プロジェクト: shouldsee/cathpy
    def run(self):
        """Run the alignment summary"""

        LOG.info('{}'.format(" ".join(AlignmentSummary.headers())))

        summary_entries = []

        for aln_file in self._files:
            try:
                aln = Align.from_stockholm(aln_file)
            except:
                raise Exception(
                    "Failed to parse STOCKHOLM alignment from file {}".format(
                        aln_file))

            try:
                aln_sum = AlignmentSummary(path=aln_file,
                                           dops=aln.dops_score,
                                           aln_length=aln.aln_positions,
                                           seq_count=aln.count_sequences,
                                           gap_count=aln.total_gap_positions,
                                           total_positions=aln.total_positions)
                summary_entries.extend([aln_sum])
            except:
                raise Exception(
                    "Failed to generate alignment summary from file: {}".
                    format(aln_file))

            LOG.info(aln_sum.to_string())

        return summary_entries
コード例 #6
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_remove_gaps(self):
     self.log_title('remove_gaps')
     self.fasta_file.seek(0)
     aln = Align.from_fasta(self.fasta_contents)
     self.assertEqual(aln.count_sequences, 2)
     new_aln = aln.remove_alignment_gaps()
     new_seqs = new_aln.seqs
     seqs_no_gap = "".join([s.to_fasta() for s in new_seqs])
     self.assertEqual(seqs_no_gap, self.fasta_contents_without_gaps)
コード例 #7
0
ファイル: align_test.py プロジェクト: UCL/cathpy
    def test_incorrect_fasta_headers(self):
        fasta_str = """
>seq1/100-200
TTTTL-LASAM
""".strip()
        aln = Align.from_fasta(fasta_str)
        seq = aln.get_seq_at_offset(0)
        with self.assertRaises(OutOfBoundsError):
            residues = seq.get_residues()
コード例 #8
0
    def __init__(self, *, funfam_id):

        sfam_id, cluster_type, ff_num = funfam_id.split('-')
        self.funfam_id = funfam_id
        funfam_sto_fname = '{}.reduced.sto'.format(funfam_id)
        self.funfam_sto_path = os.path.join(self.funfam_base_path, sfam_id,
                                            funfam_sto_fname)
        self.funfam_hmm_path = self.funfam_sto_path + '.hmm'

        self.funfam_align = Align.from_stockholm(self.funfam_sto_path)
コード例 #9
0
    def test_merge_aln_with_correspondence(self):
        aln_ref = Align.from_fasta(self.aln_structure)
        self.assertEqual(aln_ref.count_sequences, 2)
        aln_merge1 = Align.from_fasta(self.aln_merge1)
        self.assertEqual(aln_merge1.count_sequences, 3)
        aln_merge2 = Align.from_fasta(self.aln_merge2)
        self.assertEqual(aln_merge2.count_sequences, 3)

        gcf = Correspondence.from_gcf(self.gcf_ref1)

        aln_ref.merge_alignment(aln_merge1, 'ref1', gcf)
        aln_after_merge1 = Align.from_fasta(self.aln_after_merge1)
        self.assertIn('ref1_merge', [s.uid for s in aln_ref.seqs])
        #LOG.info("aln_after_merge1:\n%s", aln_ref.to_fasta())
        self.assertEqual(aln_ref.to_fasta(), aln_after_merge1.to_fasta())

        aln_ref.merge_alignment(aln_merge2, 'ref2')
        aln_after_merge2 = Align.from_fasta(self.aln_after_merge2)
        #LOG.info("aln_after_merge2:\n%s", aln_ref.to_fasta())
        self.assertEqual(aln_ref.to_fasta(), aln_after_merge2.to_fasta())
コード例 #10
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_aln_add_gap(self):
     self.log_title('aln_add_gap')
     aln = Align.from_fasta(self.fasta_aln_ref)
     self.assertEqual(aln.seqs[0].seq, '---AKGHP--GPKAPGPAK--')
     self.assertEqual(aln.seqs[1].seq, 'CGCAKGH-PKA--APGP--GT')
     aln.insert_gap_at_offset(4)
     self.assertEqual(aln.seqs[0].seq, '---A-KGHP--GPKAPGPAK--')
     self.assertEqual(aln.seqs[1].seq, 'CGCA-KGH-PKA--APGP--GT')
     aln.insert_gap_at_offset(-3, gap_char='.')
     self.assertEqual(aln.seqs[0].seq, '---A-KGHP--GPKAPGPA.K--')
     self.assertEqual(aln.seqs[1].seq, 'CGCA-KGH-PKA--APGP-.-GT')
コード例 #11
0
ファイル: align_test.py プロジェクト: UCL/cathpy
    def test_pir(self):
        aln_ref = Align.from_pir(self.pir_aln_ref)
        self.assertEqual(aln_ref.count_sequences, 2)
        pir_tmp = tempfile.NamedTemporaryFile(
            mode='w+', delete=True, suffix='.pir')
        aln_ref.write_pir(pir_tmp.name)

        with open(pir_tmp.name, 'r') as f:
            pir_expected = f.read()

        # self.assertMultiLineEqual(self.pir_aln_ref, pir_expected)
        self.assertEqual(self.pir_aln_ref, pir_expected)
コード例 #12
0
    def test_groupsim_runner(self):

        aln = Align.from_fasta(self.example_fasta_file)

        # need to set the cluster id on sequences
        runner = GroupsimRunner()
        with self.assertRaises(err.InvalidInputError):
            runner.run_alignment(aln)

        for seq_idx, seq in enumerate(aln.sequences):
            seq.set_cluster_id('cluster1' if seq_idx < 5 else 'cluster2')

        result = runner.run_alignment(aln)
        self.assertIsInstance(result, GroupsimResult)
コード例 #13
0
ファイル: align_test.py プロジェクト: UCL/cathpy
    def test_fasta_with_meta(self):
        fasta_str = """
>seq1 bla1 bla2
TTTTLLASAMLSASVFALTDPPVDPVDPVDPTDPPSSD
>seq2 key1=value1 key2=value2
TTTTLLASAMLSASVFALTDPPVDPVDPVDPTDPPSSD
""".strip()

        aln = Align.from_fasta(fasta_str)
        seq1 = aln.get_seq_at_offset(0)
        seq2 = aln.get_seq_at_offset(1)
        self.assertEqual(seq1.accession, 'seq1')
        self.assertEqual(seq2.accession, 'seq2')

        self.assertEqual(seq1.meta, {0: 'bla1', 1: 'bla2'})
        self.assertEqual(seq2.meta, {'key1': 'value1', 'key2': 'value2'})
コード例 #14
0
ファイル: util.py プロジェクト: shouldsee/cathpy
    def run_stockholm(self, sto_file):
        """
        Returns `scorecons` data for the provided STOCKHOLM file.
        
        Args:
            sto_file (str|file): alignment file in **Stockholm** format
            
        Returns:
            ScoreconsResult: a scorecons result object

        """

        fasta_tmp = tempfile.NamedTemporaryFile(mode='w+',
                                                delete=True,
                                                suffix=".fa")
        fasta_tmp_filename = fasta_tmp.name
        aln = Align.from_stockholm(sto_file)
        aln.write_fasta(fasta_tmp_filename)
        return self.run_fasta(fasta_tmp_filename)
コード例 #15
0
    def test_parse_pfam_stockholm(self):
        aln = Align.from_stockholm(self.pfam_sto_file)
        self.assertEqual(aln.count_sequences, 107)

        # LOG.info("aln: %s", pprint.pformat(aln.__dict__))

        self.assertEqual(aln.cath_version, None)
        self.assertEqual(aln.dops_score, None)
        self.assertEqual(aln.accession, 'PF03770.16')
        self.assertRegex(aln.author, r'^Finn')

        with self.assertRaises(AttributeError):
            # make sure this is in meta, not object level attribute
            self.assertRegex(aln.source_seed, r'^Pfam-B')  # pylint: disable=no-member

        self.assertRegex(aln.meta['source_seed'], r'^Pfam-B')
        self.assertRegex(aln.meta['search_method'], r'^hmmsearch')

        self.assertEqual(list(aln.seq_meta.keys()), ['SS_cons', 'seq_cons'])
コード例 #16
0
    def test_groupsim(self):
        gs = util.GroupsimRunner()
        aln = Align.from_fasta(self.example_fasta_file)

        seqs = aln.seqs

        for s in seqs[:2]:
            s.set_cluster_id('0001')
        for s in seqs[2:]:
            s.set_cluster_id('0002')

        gs_res = gs.run_alignment(aln)
        self.assertEqual(gs_res.count_positions, aln.aln_positions)
        LOG.info("GS: {}".format(repr(gs_res.__dict__)))

        sto_file = tempfile.NamedTemporaryFile(delete=False, suffix='.sto')
        sto_with_groupsim_file = tempfile.NamedTemporaryFile(
            delete=False, suffix='.groupsim.sto')

        LOG.info("Writing STOCKHOLM file (without groupsim): %s",
                 sto_file.name)
        aln.write_sto(sto_file.name)
        LOG.info("Adding groupsim data ... ")
        gs_res1 = aln.add_groupsim()
        self.assertIsInstance(gs_res1, GroupsimResult)
        LOG.info("Writing STOCKHOLM file (with groupsim): %s",
                 sto_with_groupsim_file.name)
        aln.write_sto(sto_with_groupsim_file.name)

        with open(sto_file.name) as f1:
            with open(sto_with_groupsim_file.name) as f2:
                lines1 = f1.readlines()
                lines2 = f2.readlines()
                ndiff = difflib.ndiff(lines1, lines2)

        difflines = [l for l in ndiff if not l.startswith(' ')]
        LOG.info("DIFF: %s", ''.join(difflines))
        expected_groupsim = '#=GC groupsim                 --------------10014101040141141031--2151411010022021221001040000---0-1-10-----\n'
        self.assertEqual(''.join(difflines), '+ ' + expected_groupsim)
コード例 #17
0
ファイル: util.py プロジェクト: shouldsee/cathpy
    def run(self):
        """Runs the alignment merge."""

        LOG.info("Running alignment merge")

        cath_release = self.cath_release

        # parse the structure-based alignment of representatives
        # eg /cath/data/v4_2_0/funfam/families/1.10.8.10/1.10.8.10__FF_SSG9__6.reps.fa
        sc_filename = os.path.basename(self.sc_file)
        sc_parts = re.match(r'(\d+\.\d+\.\d+\.\d+)__([A-Z0-9_]+)__(\d+)\b',
                            sc_filename)

        if not sc_parts:
            raise Exception(
                'failed to parse necessary meta info from sc_file name: ' +
                sc_filename)

        sfam_id, cluster_type, sc_num = sc_parts.group(1, 2, 3)

        LOG.info('Superfamily: ' + sfam_id)
        LOG.info('Cluster type: ' + cluster_type)
        LOG.info('Cluster number: ' + sc_num)

        LOG.info("Parsing structure-based alignment: ")
        sc_aln = Align.from_fasta(self.sc_file)
        LOG.info(" ... found {} representatives".format(
            sc_aln.count_sequences))

        cluster_id = '-'.join([sfam_id, cluster_type, sc_num])
        sc_aln.set_uid(cluster_id)
        sc_aln.accession = cluster_id
        sc_aln.aln_type = cluster_type
        sc_aln.description = '{}, Structural Cluster ({}) {}'.format(
            sfam_id, cluster_type, sc_num)

        merge_count = 1

        def next_merge_stage_file():
            nonlocal merge_count
            out_fasta = str(self.out_fasta)
            stage_file = re.sub(r'(\..*?)$', '.' + str(merge_count) + '\1',
                                out_fasta)
            LOG.debug(
                "stage_file: merge_count={} out_fasta={} stage_file={}".format(
                    merge_count, out_fasta, stage_file))
            merge_count += 1
            return stage_file

        # create our funfam finder
        ff_finder = FunfamFileFinder(self.ff_dir, ff_tmpl=self.ff_tmpl)

        LOG.info("Searching for funfam files in dir: " + self.ff_dir)

        # for each representative in the structure-based alignment..
        sc_aln_orig = sc_aln.copy()
        for sc_rep_in_sc in sc_aln_orig.seqs:

            LOG.info('Working on SC rep: {}'.format(sc_rep_in_sc.accession))

            sc_rep_acc = sc_rep_in_sc.accession

            # find the corresponding funfam alignment
            ff_aln_file = ff_finder.search_by_domain_id(sc_rep_acc)

            LOG.info('Reading FunFam alignment: {}'.format(ff_aln_file))

            # parse it into an alignment
            ff_aln = Align.from_stockholm(ff_aln_file)

            # we need the funfam_number for groupsim
            funfam_id = ff_finder.funfam_id_from_file(ff_aln_file)

            # find the sc_rep sequence within the funfam alignment
            sc_rep_in_ff = ff_aln.find_seq_by_accession(sc_rep_acc)
            if not sc_rep_in_ff:
                raise err.GeneralError(
                    'failed to find structural cluster representative {} in funfam {}'
                    .format(
                        sc_rep_acc,
                        ff_aln_file,
                    ))

            LOG.debug('SC REP (SC): {}'.format(sc_rep_in_sc))
            LOG.debug('SC REP (FF): {}'.format(sc_rep_in_ff))

            # get the chain correspondence file
            rep_chain_id = sc_rep_acc[:5]
            gcf_file = cath_release.get_file('chaingcf', rep_chain_id)

            chain_corr = Correspondence.from_gcf(gcf_file)

            # TODO: get a subset that only corresponds to the domain (not chain)
            seqres_segments = sc_rep_in_ff.segs
            LOG.warning(
                "TODO: this code currently assumes that the start-stop information "
                "in the FunFam STOCKHOLM alignment matches the sequence and is based on SEQRES "
                "records (which needs to be double-checked)")

            if not seqres_segments:
                raise err.MissingSegmentsError(
                    ('need to have seqres segments defined in '
                     'structural cluster rep sequence (of funfam): {}'
                     ).format(sc_rep_in_ff))

            LOG.info('applying segments to correspondence: {}'.format(
                repr(seqres_segments)))
            sc_rep_corr = chain_corr.apply_seqres_segments(seqres_segments)
            LOG.info(
                '  ...correspondence changed from {} (first:{}, last:{}) to {} (first:{}, last:{})'
                .format(
                    chain_corr.seqres_length,
                    str(chain_corr.first_residue),
                    str(chain_corr.last_residue),
                    sc_rep_corr.seqres_length,
                    str(sc_rep_corr.first_residue),
                    str(sc_rep_corr.last_residue),
                ))

            # merge the funfam into the sc alignment
            sc_aln.merge_alignment(ff_aln,
                                   sc_rep_acc,
                                   sc_rep_corr,
                                   cluster_label=funfam_id.cluster_num)

            merge_stage_file = next_merge_stage_file()
            #LOG.info("Writing tmp merge file to '{}'".format(merge_stage_file))
            #sc_aln.write_fasta(merge_stage_file, wrap_width=None)

        # add scorecons
        if self.add_scorecons:
            sc_aln.add_scorecons()

        # add groupsim
        if self.add_groupsim:
            sc_aln.add_groupsim()

        # write final merged alignment
        if self.out_fasta:
            LOG.info('Writing merged FASTA alignment: {}'.format(
                self.out_fasta))
            sc_aln.write_fasta(self.out_fasta, self.wrap_width)

        if self.out_sto:
            LOG.info('Writing merged STOCKHOLM alignment: {}'.format(
                self.out_sto))
            sc_aln.write_sto(self.out_sto)

        return sc_aln
コード例 #18
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_copy_aln(self):
     self.log_title('copy_aln')
     aln_ref = Align.from_fasta(self.fasta_aln_ref)
     aln_copy = aln_ref.copy()
     self.assertNotEqual(aln_copy, aln_ref)
     self.assertEqual(str(aln_copy), str(aln_ref))
コード例 #19
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_read_fasta_str(self):
     aln = Align.from_fasta(self.fasta_contents)
     self.assertEqual(aln.count_sequences, 2)
コード例 #20
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_read_stockholm_gzip_file(self):
     aln = Align.from_stockholm(self.stockholm_gzip_file)
     self.assertEqual(aln.count_sequences, 51)
コード例 #21
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_read_fasta_fileio(self):
     self.fasta_file.seek(0)
     aln = Align.from_fasta(self.fasta_file)
     self.assertEqual(aln.count_sequences, 2)
コード例 #22
0
ファイル: align_test.py プロジェクト: UCL/cathpy
 def test_read_fasta_filename(self):
     aln = Align.from_fasta(self.fasta_file.name)
     self.assertEqual(aln.count_sequences, 2)
     seqs = aln.seqs
     self.assertEqual(seqs[0].uid, 'id1')
     self.assertEqual(seqs[1].uid, 'id2')