Example #1
0
    def setUp(self):
        
        self.buf = open('data/ProtDNA.psl').read()
        self.buf = self.buf.replace("\r\n","\n")

        thisdir = os.path.abspath(os.path.dirname(__file__))
        def thisfile(name):
            return os.path.join(thisdir, name)
        
        
        self.srcDB = seqdb.SequenceFileDB(thisfile('data/test_prot.fa'))
        self.destDB = seqdb.SequenceFileDB(thisfile('data/test_dna.fa'))
        self.db = seqdb.SequenceFileDB(thisfile('data/translatedDB.fa'))
        
        self.aln_type = 1 #protein-dna alignmet = 1, else - 0 
        
        self.matches, genome_names = blat_NLMSA.parse_blat(self.buf, 
                                                           self.aln_type)

        self.db = translationDB.get_translation_db(self.destDB)

        alignment = cnestedlist.NLMSA('test', mode='memory', pairwiseMode=True,
                                      bidirectional=False)

        self.temp_nlmsa = blat_NLMSA.create_NLMSA_blat(self.buf, alignment,
                                                       aln_type = self.aln_type,        
                                                       srcDB = self.srcDB, 
                                                       destDB = self.db)
Example #2
0
 def test_parse_blat(self) :
     matches, genome_names = blat_NLMSA.parse_blat(self.buf, self.aln_type)
     names_set = set(['gi|171854975|dbj|AB364477.1|',
                                             'hbb1_mouse_RC',
                                             'hbb1_mouse_RC_2',
                                             'hbb1_mouse_RC_3',
                                              'HBB0_PAGBO','HBB1_ANAMI',
                                              'HBB1_CYGMA','HBB1_IGUIG',
                                              'HBB1_MOUSE','HBB1_ONCMY',
                                              'HBB1_PAGBO','HBB1_RAT',
                                              'HBB1_SPHPU','HBB1_TAPTE',
                                              'HBB1_TORMA','HBB1_TRICR',
                                              'HBB1_UROHA','HBB1_VAREX',
                                              'HBB1_XENBO','HBB1_XENLA',
                                              'HBB1_XENTR','MYG_DIDMA',
                                              'MYG_ELEMA','MYG_ERIEU',
                                              'MYG_ESCGI','MYG_GALCR',
                                              'PRCA_ANASP','PRCA_ANAVA'])
     
     self.assertEqual(set(genome_names).difference(names_set),set())
     
     blat_aln = matches[0] # Extracting the first alignment 
     
     qStart = getattr(blat_aln, "qStart")
     tStart = getattr(blat_aln, "tStart")
     qEnd = getattr(blat_aln, "qEnd")
     tEnd = getattr(blat_aln, "tEnd")
     qName = getattr(blat_aln, "qSeqName")
     tName = getattr(blat_aln, "tSeqName")
     orient = getattr(blat_aln, "orient")
     blocks = getattr(blat_aln, "blocks")
             
     last_ungapped = blocks[-1] # Extracting the last ungapped block
     last_ungapped_qStart = getattr(last_ungapped, "qStart")
     last_ungapped_tStart = getattr(last_ungapped, "tStart")
     last_ungapped_qEnd = getattr(last_ungapped, "qEnd")
     last_ungapped_tEnd = getattr(last_ungapped, "tEnd")
     
     self.assertEqual(qStart, 20)
     self.assertEqual(tStart, 63)
     self.assertEqual(qEnd, 106)
     self.assertEqual(tEnd, 321)
     self.assertEqual(qName, 'HBB0_PAGBO')
     self.assertEqual(tName, 'gi|171854975|dbj|AB364477.1|')
     self.assertEqual(orient, '++')
     self.assertEqual(len(blocks), 2)
     
     self.assertEqual(last_ungapped_qStart, 81)
     self.assertEqual(last_ungapped_tStart, 246)
     self.assertEqual(last_ungapped_qEnd, 81+25)
     self.assertEqual(last_ungapped_tEnd, 246+3*25)
Example #3
0
    def setUp(self):
        self.buf = open('data/output.psl').read()
        self.buf = self.buf.replace("\r\n","\n")
        
        thisdir = os.path.abspath(os.path.dirname(__file__))
        self.db = seqdb.SequenceFileDB(os.path.join(thisdir,
                                                    'data/test_genomes.fna'))
        self.aln_type = 0 #if protein-dna-1,else-0      
        matches, genome_names = blat_NLMSA.parse_blat(self.buf, self.aln_type)
        
        alignment = cnestedlist.NLMSA('test', mode='memory', seqDict=self.db,
                                      use_virtual_lpo=True)

        self.temp_nlmsa = blat_NLMSA.create_NLMSA_blat(self.buf, alignment,
                                                       seqDB=self.db)
Example #4
0
    def setUp(self):
        self.buf = open('data/output.psl').read()
        self.buf = self.buf.replace("\r\n","\n")
        
        thisdir = os.path.abspath(os.path.dirname(__file__))
        
        def thisfile(name):
            return os.path.join(thisdir, name)

        self.srcDB = seqdb.SequenceFileDB(thisfile('data/test_genomes.fna'))
        self.destDB = seqdb.SequenceFileDB(thisfile('data/test_genomes.fna'))
        
        self.protDNAaln = False #if protein-dna alignment - True,else- False      
       
        matches, genome_names = blat_NLMSA.parse_blat(self.buf, self.protDNAaln)
        
        alignment = cnestedlist.NLMSA('test', mode='memory', seqDict=self.srcDB,
                                     use_virtual_lpo=True)
        #alignment = cnestedlist.NLMSA('test', mode='memory', pairwiseMode=True,
                                      #bidirectional=False)????????

        self.temp_nlmsa = blat_NLMSA.create_NLMSA_blat(self.buf, alignment,
                                                       self.srcDB, self.destDB,
                                                       self.protDNAaln)
Example #5
0
    def test_parse_blat(self) :
        matches, genome_names = blat_NLMSA.parse_blat(self.buf, self.protDNAaln)
        self.assertEqual(set(genome_names), set(['testgenome1', 'testgenome2',
                                                 'testgenome3', 'testgenome4']))
        
        blat_aln = matches[-1]
        
        qStart = getattr(blat_aln, "qStart")
        tStart = getattr(blat_aln, "tStart")
        qEnd = getattr(blat_aln, "qEnd")
        tEnd = getattr(blat_aln, "tEnd")
        
        qName = getattr(blat_aln, "qSeqName")
        tName = getattr(blat_aln, "tSeqName")
        orient = getattr(blat_aln, "orient")
        blocks = getattr(blat_aln, "blocks")
        
        last_ungapped = blocks[-1]
        last_ungapped_qStart = getattr(last_ungapped, "qStart")
        last_ungapped_tStart = getattr(last_ungapped, "tStart")
        last_ungapped_qEnd = getattr(last_ungapped, "qEnd")
        last_ungapped_tEnd = getattr(last_ungapped, "tEnd")
 
        self.assertEqual(qStart, 64)
        self.assertEqual(tStart, 64)
        self.assertEqual(qEnd, 420)
        self.assertEqual(tEnd, 350)
        self.assertEqual(qName, 'testgenome4')
        self.assertEqual(tName, 'testgenome1')
        self.assertEqual(orient, '++')
        self.assertEqual(len(blocks), 2)
        
        self.assertEqual(last_ungapped_qStart, 351)
        self.assertEqual(last_ungapped_tStart, 281)
        self.assertEqual(last_ungapped_qEnd, 351+69)
        self.assertEqual(last_ungapped_tEnd, 281+69)