Esempio n. 1
0
    def select_size(self,size = None):

        """ Select which reagent type """

        # local namespace
        all_sizes = self.settings['all_sizes']
        default_size = self.settings['default_size']

        # determine whether default size is used
        if size == None:
            print 'Using default enzyme size ({})...'.format(default_size)
            size = default_size

        # reassign based on product selection 
        assert size in all_sizes, "selected size not found in enzyme info!"

        # find location of info
        index = all_sizes.index(size)

        # pull values
        self.settings['size'] = size
        self.settings['concentration'] = self.settings['all_concentrations'][index]
        self.settings['units_per_ml'] = self.settings['all_units_per_ml'][index]
        self.settings['cost'] = self.settings['all_costs'][index]

        # update object attributes
        obj_update(self)
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        """ Restriction enzyme input """

        self.database_folder = './database/sequences/'

        # digestion settings
        self.settings = {
            'name': None,
            'author': None,
            'description': None,
            'sequence': None,
            'codon_set': None,
            'elements': None,
            'concentration': None,
            'form': None,
            'tags': None,
            'origin': None,  # what experiments produced fragment
            'source': None,  # what website, author, etc
            'url': None,  # background information
            'break_5': None,  # 5' backbone breaks
            'break_3': None  # 3' backbone breaks
        }

        # update settings
        for arg in args:
            self.settings.update(arg)
        self.settings.update(kwargs)

        # update object attributes with internal settings
        obj_update(self)
Esempio n. 3
0
    def __init__(self,*args,**kwargs):

        """ Restriction enzyme input """

        default_name = 'XhoI'
        database_fname = './database/restriction_enzymes.xlsx'

        # digestion settings
        self.settings = {
                    'name':None,
                    'sequence':None,
                    'source':None,
                    'size':None,
                    'site_type':None,
                    'site_location':None,
                    'default_size':None,
                    # current product info
                    'concentration':None,
                    'units_per_ml':None,
                    'cost':None,
                    # available product info 
                    'all_sizes':None,
                    'all_concentrations':None,
                    'all_units_per_ml':None,
                    'all_costs':None,
                    'active_temperature':None,
                    'inactive_temperature':None,
                    'inactive_time':None,
                    'url':None
                       }

        # update settings
        for arg in args: self.settings.update(arg)
        self.settings.update(kwargs)

        # TODO: consider taking out
        # set enzyme to default if no name is passed
        if self.settings['name'] == None:
            print 'No enzyme specified, using {}...'.format(default_name)
            self.settings['name'] = default_name

        # database request, update settings
        database = request_xlsx(self.settings['name'],database_fname)
        dict_update(self.settings,database) # dicts are mutably updated

        # update object attributes
        obj_update(self)
Esempio n. 4
0
    def load(self, name=None):

        # set sequence to default if no name is passed
        if self.settings['name'] == None and name == None:
            print 'No sequence name specified, exiting...'
            return None
        elif name == None:
            print 'Using {} as sequence name...'.format(self.settings['name'])
            name = self.settings['name']

        # build fname to call
        fname = self.database_folder + name + '.txt'

        # sequence file, update settings
        database = _load_sequence_file(fname)
        dict_update(self.settings, database)  # dicts are mutably updated
        obj_update(self)
Esempio n. 5
0
    def __init__(self,*args,**kwargs):

        """ Digest input """

        # digestion settings
        settings = {
                'sequence':None,
                'enzyme':None
                   }

        # update settings
        for arg in args: settings.update(arg)
        settings.update(kwargs)

        # use defaults if input and enzymes not selected
        if settings['sequence'] == None:
            settings['sequence'] = 'XhoI-Plasmid'
        if settings['enzyme'] == None:
            settings['enzyme'] = 'XhoI'

        # check database for sequences
        if isinstance(settings['sequence'],str):
            sequence = Sequence(name=settings['sequence'])
            sequence.load()
        elif isinstance(settings['sequence'],object):
            sequence = settings['sequence']
        else:
            raise TypeError('Unknpwn sequence type passed to function <{}>!'.format(
                type(settings['sequence'])))

        # check database for enzyme
        # TODO: add compatibility for multiple enzyme reaction
        if isinstance(settings['enzyme'],str):
            enzyme = RestrictionEnzyme(name=settings['enzyme'])
        elif isinstance(settings['enzyme'],object):
            enzyme = settings['enzyme']
        else:
            raise TypeError('Unknpwn enzyme type passed to function <{}>!'.format(
                type(settings['enzyme'])))
        
        enzyme.select_size()
        enzyme_name = enzyme.name
        enzyme_volume = (1./enzyme.units_per_ml,'mL')
        enzyme_temp = (enzyme.active_temperature,'C')


        # TODO: break sequence at site

        # reagent listing
        mix_settings = {
                'reagents':
                    {
                    enzyme_name:enzyme_volume,
                    'NEBuffer':(10,'X'),
                    },
                'filler':'dH2O',
                'total':(50,'uL'),
                'temperature':(-4,'C')
                    }

        incubate_settings = {
            'preparation':'Gently mix by flicking.',
            'temperature':enzyme_temp,
            'time':(1,'hour'),
            'movement':'stationary'
            }

        # sinc
        self.protocols = [Mix(mix_settings),
                          Incubate(incubate_settings)]

        # Output cut sequence object (breaks in backbone)

        cut_sequence = deepcopy(sequence) # copies the sequence

        breaks = _cut(cut_sequence,enzyme) # add backbone breaks

        obj_update(cut_sequence,breaks) # add breaks to sequence
        cut_sequence.add_origin('digest with {}'.format(enzyme.name)) # add origin

        self.output = cut_sequence