示例#1
0
 def s2s_blast_batch(self, queries, subjects, subject_locs=None, evalue=0.001, command='blastn', **kwargs):
     results = self._s2s_blast_batch(queries, subjects, subject_locs, evalue, command, **kwargs)
     if not results: return None
     with ProgressCounter('Parsing results...', len(results)) as prg:
         for qi in xrange(len(results)):
             for si in xrange(len(results[qi])):
                 results_name = results[qi][si]
                 if not results_name: continue
                 with roDict(results_name) as db:
                     results[qi][si] = db['result']
             prg.count()
     return results
示例#2
0
 def s2s_blast_batch(self, queries, subjects, subject_locs=None, evalue=0.001, command='blastn', **kwargs):
     results = self._s2s_blast_batch(queries, subjects, subject_locs, evalue, command, **kwargs)
     if not results: return None
     with ProgressCounter('Parsing results...', len(results)) as prg:
         for qi in xrange(len(results)):
             for si in xrange(len(results[qi])):
                 results_name = results[qi][si]
                 if not results_name: continue
                 with roDict(results_name) as db:
                     results[qi][si] = db['result']
             prg.count()
     return results
示例#3
0
 def _find_features_by_hsps(qs, translations, blast_results):
     results_name = blast_results[qs[0]][qs[1]]
     if not results_name: return None
     with roDict(results_name) as db:
         hsps = BlastCLI.all_hsps(db['result'])
     if not hsps:
         print 'no blast results in %s: %s' % (results_name, hsps)  
         return None
     hsp = min(hsps, key=lambda h: h.expect)
     for f in translations[qs[1]].features:
         if hsp.sbjct_start-1 in f and hsp.sbjct_end-1 in f:
             aln_len = abs(hsp.sbjct_start-hsp.sbjct_end)+1
             return f, aln_len, float(hsp.identities)/hsp.align_length, hsp.expect
     return None
示例#4
0
 def _find_features_by_hsps(qs, translations, blast_results):
     results_name = blast_results[qs[0]][qs[1]]
     if not results_name: return None
     with roDict(results_name) as db:
         hsps = BlastCLI.all_hsps(db['result'])
     if not hsps:
         print 'no blast results in %s: %s' % (results_name, hsps)  
         return None
     hsp = min(hsps, key=lambda h: h.expect)
     for f in translations[qs[1]].features:
         if hsp.sbjct_start-1 in f and hsp.sbjct_end-1 in f:
             aln_len = abs(hsp.sbjct_start-hsp.sbjct_end)+1
             return f, aln_len, float(hsp.identities)/hsp.align_length, hsp.expect
     return None
示例#5
0
 def __init__(self, fpath):
     self._d = roDict(fpath)
     self.reaction_id  = self._d['reaction_id']
     self.templates    = [[],[]]
     self.templates[1] = self._d['fwd_templates']
     self.templates[0] = self._d['rev_templates']
     self.products     = dict()
     annealing_keys    = []
     for k in self._d.iterkeys():
         if k.startswith('p'):
             self.products[int(k.strip('p'))] = self._d[k]
         elif k.startswith('a'):
             annealing_keys.append(k)
     self.annealings   = tupleView(annealing_keys, self._d)
示例#6
0
 def __init__(self, fpath):
     self._d = roDict(fpath)
     self.reaction_id = self._d['reaction_id']
     self.templates = [[], []]
     self.templates[1] = self._d['fwd_templates']
     self.templates[0] = self._d['rev_templates']
     self.products = dict()
     annealing_keys = []
     for k in self._d.iterkeys():
         if k.startswith('p'):
             self.products[int(k.strip('p'))] = self._d[k]
         elif k.startswith('a'):
             annealing_keys.append(k)
     self.annealings = tupleView(annealing_keys, self._d)
示例#7
0
        def g2g2shelf():
            return lb.g2g_blastp(ref,
                                 subj,
                                 11,
                                 features_of_interest=[{
                                     'ugene_name': 'FC-full'
                                 }, {
                                     'ugene_name': 'COC-full'
                                 }])

        g2g_res = '/tmp/DP-PCR-N_KAEs'
        if not os.path.isfile(g2g_res):
            g2g_res = g2g2shelf()
            print g2g_res
        if g2g_res:
            with roDict(g2g_res) as db:
                results = db['result']
            if results:
                lb.g2g_to_csv('g2g_test.csv', ref, subj, results)
        print 'Done.'

    import numpy as np
    import pandas
    import matplotlib.pyplot as plt
    from matplotlib import cm, rc

    df = pandas.read_csv('g2g_test.csv')
    df = df.dropna(subset=('Thermococcus_onnurineus_NA1_percent',
                           'Thermococcus_sp._ES1_percent'))
    ratio = 15 / 18.0
    rc('text', usetex=True)
示例#8
0
                         'Thermococcus-DS1-preliminary.gb'] 
         genomes = load_files(abort_event, [os.path.join(genomes_dir, f) for f in genome_names], 'gb') 
     
     ref = genomes[0]
     subj = genomes[1:]
     
     @shelf_result
     def g2g2shelf():
         return lb.g2g_blastp(ref, subj, 11, features_of_interest=[{'ugene_name': 'FC-full'}, {'ugene_name': 'COC-full'}])
         
     g2g_res = '/tmp/DP-PCR-N_KAEs'
     if not os.path.isfile(g2g_res):
         g2g_res = g2g2shelf()
         print g2g_res
     if g2g_res:
         with roDict(g2g_res) as db:
             results = db['result'] 
         if results:
             lb.g2g_to_csv('g2g_test.csv', ref, subj, results)
     print 'Done.'
         
 import numpy as np
 import pandas
 import matplotlib.pyplot as plt
 from matplotlib import cm, rc
 
 df = pandas.read_csv('g2g_test.csv')
 df = df.dropna(subset=('Thermococcus_onnurineus_NA1_percent', 'Thermococcus_sp._ES1_percent'))
 ratio = 15/18.0
 rc('text', usetex=True)
 rc('font', size=14)