Example #1
0
 def test_blastn(self):
     p = self.plus['locus']
     # If indel in the sequence, retrieves corrected sequence
     indel = p.seq[:90] + p.seq[100:]
     seqloc = locus.Locus(dna.Dna(indel))
     self.assertEquals(seqloc.name, self.plus['coord'])
     self.assertEquals(seqloc.seq.lower(), self.plus['seq_file'].lower())
     with self.assertRaises(ValueError):
         # Nonsense
         locus.Locus(dna.Dna('tact' * 1000))
     with self.assertRaises(ValueError):
         # Paste together in wrong order
         locus.Locus(dna.Dna(p.down + p.seq + p.up))
Example #2
0
 def test_search_by_seq(self):
     #  Ensure that searching by sequence using blastn gives same results"""
     for d in self.dicts:
         seqloc = locus.Locus(dna.Dna(d['locus'].seq), context=self.context)
         self.assertEquals(seqloc.name, d['coord'])
         self.assertEquals(seqloc.seq.lower(), d['seq_file'].lower())
         full = d['locus'].up + d['locus'].seq + d['locus'].down
         self.assertEquals(full.lower(), d['context_file'].lower())
Example #3
0
 def setUp(self):
     # short genes on each strand. Seqs from Ensembl in static/testdata/
     self.context = 100
     self.plus = {}
     self.plus['id'] = 'PAS_chr2-1_0751'
     self.plus['coord'] = '2:1427323-1427517(+)'
     self.minus = {}
     self.minus['id'] = 'PAS_chr1-4_0504'
     self.minus['coord'] = '1:2322810-2322980(-)'
     self.dicts = (self.plus, self.minus)
     for d in self.dicts:
         d['locus'] = locus.Locus(dna.Dna('', name=d['id']),
                                  context=self.context)
         with open(paths.TESTDATA_PATH + d['id'] + '.seq', 'r') as f:
             d['seq_file'] = f.read().strip()
         with open(paths.TESTDATA_PATH + d['id'] + '_context100.seq',
                   'r') as f:
             d['context_file'] = f.read().strip()
Example #4
0
 def __init__(self, target, common_frags, in_frame=False):
     """Args:
         target (Dna): 
         common_frags (list of Dna): Dna fragments shared by Batch.
         in_frame (bool): True if tag should create a protein fusion
                         (maintain START or STOP codon)"""
     # super() required to call next __init__() method in the
     # multiple resolution order. (object.__init__() is no-op)
     super(Design, self).__init__()
     self.in_frame = in_frame
     self.target = target
     # Single retrieval of outermost sequences
     self.locus = locus.Locus(target,
                              context=self.opt_arm + 2 * self.search)
     self.M, self.T, self.V = common_frags
     # T overhangs are unique to the design, though Pcr common to batch.
     self.T = copy.deepcopy(self.T)
     self.U = self.D = self.colony = None
def LoadLoci(locfile, datafiles, minsamples, maxsamples, \
                 locuspriors, locusfeatures, use_features, \
                 stderrs, jackknife_blocksize, isvcf, eststutter, usestutter, uselikelihoods, \
                 use_sample_pairs, use_locus_means, usesmm, \
                 debug=False):
    sys.stderr.write("Loading priors\n")
    priors = LoadPriors(locuspriors, use_locus_means, locfile)
    sys.stderr.write("Loading features\n")
    features = LoadLocusFeatures(locusfeatures,
                                 locfile,
                                 use_features=use_features)
    sys.stderr.write("Loading stutter\n")
    stutter = LoadStutter(usestutter)
    loci = []
    with open(locfile, "r") as f:
        for line in f:
            chrom, start, end = line.strip().split()[0:3]
            chrom = str(chrom)
            start = int(start)
            end = int(end)
            loc = locus.Locus(chrom, start, end, datafiles, minsamples, maxsamples, \
                                  stderrs, isvcf, eststutter, uselikelihoods, _debug=debug)
            loc.jkblocksize = jackknife_blocksize
            loc.usesmm = usesmm
            key = (chrom, start, end)
            if priors is not None and key not in priors: continue
            if features is not None and key not in features: continue
            if stutter is not None and key not in stutter: continue
            if priors is not None and key in priors:
                loc.LoadPriors(*priors[key])
            if features is not None and key in features:
                loc.LoadFeatures(features[key])
                sys.stderr.write("%s,%s\n" % (str(key), str(features[key])))
            if use_sample_pairs is not None:
                loc.use_sample_pairs = True
                loc.pair_file = use_sample_pairs
            if stutter is not None and key in stutter:
                loc.LoadStutter(*stutter[key])
            loci.append(loc)
    return loci