def make_plasmid(repo, constituentparts, part, authorid, datecreated): first = constituentparts[0] last = constituentparts[len(constituentparts) - 1] nsafirst = repository.get_annotations_by_family(repo, first['nucseq'], 'overhang') nsalast = repository.get_annotations_by_family(repo, last['nucseq'], 'overhang') if nsafirst[0]['startx'] < nsafirst[1]['startx']: fpo = nsafirst[0]['feature'] else: fpo = nsafirst[1]['feature'] if nsalast[0]['startx'] < nsalast[1]['startx']: tpo = nsalast[0]['feature'] else: tpo = nsalast[0]['feature'] allresistances = repository.get_features_by_family_name(repo, 'resistance') resistancesforeachpart = get_resistance_by_composite_part(repo, constituentparts) availresistances = find_satisfiable_resistance(0, resistancesforeachpart, allresistances) if availresistances: eligiblevectors = repository.find_vectors_by_overhang_resistance(repo, fpo, tpo, availresistances) if eligiblevectors: return repository.persist_plasmid(repo, 'PLASMID-' + part['name'], part, eligiblevectors[0], authorid, datecreated) return {}
def make_part(repo, p, concentration, concentration_unit, volume_unit): part = {} part['name'] = p['name'] + '-' + str(p['idpart']) part['sequence'] = p['nucseq']['sequence'].upper() part['concentration'] = concentration part['concentrationUnit'] = concentration_unit part['volumeUnit'] = volume_unit nsa = repository.get_annotations_by_family(repo, p['nucseq'], 'overhang') l = [] r = [] if nsa[0]['startx'] > nsa[1]['startx']: l.append(nsa[1]['startx']) l.append(nsa[1]['endx']) r.append(nsa[0]['startx']) r.append(nsa[0]['endx']) else: l.append(nsa[0]['startx']) l.append(nsa[0]['endx']) r.append(nsa[1]['startx']) r.append(nsa[1]['endx']) overhang = {} overhang['fivePrimeEnd'] = l[0] overhang['fivePrimeStart'] = l[1] overhang['threePrimeEnd'] = r[0] overhang['threePrimeStart'] = r[1] part['overhangs'] = overhang return part
def get_vector_overhang_annotations(repo, vectorname): vector = [v for v in repo['vectors'] if v['name'].lower() == vectorname.lower()] if len(vector) <= 0: raise ValueError('There is an invalid vector (' + vectorname + ') in the plasmids file.') vector = vector[0] nucseqannotations = repository.get_annotations_by_family(repo, vector['nucseq'], 'overhang') if len(nucseqannotations) != 2: raise ValueError('Unexpected number of overhangs found in ' + vectorname + ' num is ', len(nucseqannotations)) return nucseqannotations
def get_resistance_by_composite_part(repo, constituentparts): resistancesforeachpart = [] for pt in constituentparts: possiblevectors = repository.get_vectors_by_part(repo, pt) res = [] for vt in possiblevectors: nsa = repository.get_annotations_by_family(repo, vt['nucseq'], 'resistance') if len(nsa) > 1: print('Warning: Multi resistance vector breaks assumption.') if nsa: res.append(nsa[0]['feature']) resistancesforeachpart.append(res) return resistancesforeachpart
def compute_part_sequence(repo, constituentparts): sequence = '' prev_endoverhang = '' count = 0 for part in constituentparts: if 'moclo' in part['format']['idformat'].lower(): # Get start and end overhangs for sequence overhangs = repository.get_annotations_by_family( repo, part['nucseq'], 'overhang') startoverhang = overhangs[0] endoverhang = overhangs[1] if overhangs[0]['startx'] > overhangs[1]['startx']: startoverhang = overhangs[1] endoverhang = overhangs[0] # Make sure the start overhang matches the previous sequence's end overhang if prev_endoverhang and startoverhang['feature']['nucseq']['sequence'] != \ prev_endoverhang['feature']['nucseq']['sequence']: raise ValueError( "Consecutive composite parts don't have matching overhang values." ) prev_endoverhang = endoverhang if startoverhang['startx'] > 0: raise ValueError( 'Part ' + part['name'] + ' does not begin with an overhang feature as expected ' 'of a Modular Cloning part.') end_overhang_len = len( endoverhang['feature']['nucseq']['sequence'].strip()) # Add start overhang to sequence sequence += startoverhang['feature']['nucseq']['sequence']\ .strip() + part['nucseq']['sequence'][:-end_overhang_len].strip() count += 1 # Add end overhang to final sequence sequence += endoverhang['feature']['nucseq']['sequence'].strip() return sequence