def evol_merge(*msa, **kwargs): import prody from prody import parseMSA, mergeMSA, LOGGER, writeMSA, MSAFile from prody.sequence.msafile import MSAEXTMAP from os.path import splitext if len(msa) < 2: raise ValueError('multiple msa filenames must be specified') msaobj = [] try: msaobj = [parseMSA(fn) for fn in msa] except: raise IOError('failed to parse {0}'.format(fn)) msafile = MSAFile(msa[0]) format = kwargs.get('format') or msafile.format outname = kwargs.get('outname') or (msafile.getTitle() + '_merged' + MSAEXTMAP[msafile.format]) writeMSA(outname, mergeMSA(*msaobj), **kwargs) LOGGER.info('Merged MSA is saved as: {0}'.format(outname))
def testMerge(self): merged = mergeMSA(FASTA, FASTA) length = FASTA.numResidues() self.assertEqual(merged[:, :length], merged[:, length:])