Load a COBRApy Model object into the GEM-PRO project.

        Args:
            model (Model): COBRApy ``Model`` object
347548
def load_cobra_model(self, model):
        
        self.model = ModelPro(model)
        for g in self.model.genes:
            if self.genes_dir:
                g.root_dir = self.genes_dir
            g.protein.pdb_file_type = self.pdb_file_type
        self.genes = self.model.genes

        log.info('{}: loaded model'.format(model.id))
        log.info('{}: number of reactions'.format(len(self.model.reactions)))
        log.info('{}: number of reactions linked to a gene'.format(ssbio.core.modelpro.true_num_reactions(self.model)))
        log.info('{}: number of genes (excluding spontaneous)'.format(ssbio.core.modelpro.true_num_genes(self.model,
                                                                                                         custom_spont_id=self.custom_spont_id)))
        log.info('{}: number of metabolites'.format(len(self.model.metabolites)))
        log.warning('IMPORTANT: All Gene objects have been transformed into GenePro '
                    'objects, and will be for any new ones')
1357644
def _connect_model(self, model):
        

        parts = self._prop_name.split(".")
        if len(parts) > 1:
            # identifies the model
            models = parts[:-1]
            Intermediate(model, models, self)
            for name in models:
                model = getattr(model, name)
                if not isinstance(model, Model):
                    raise TypeError("Attribute '" + name +
                                    "' was expected to be a Model, but found: " +
                                    str(model))
            prop = parts[-1]
        else: prop = parts[0]

        # prop is inside model?
        if not hasattr(model, prop):
            raise ValueError("Attribute '" + prop +
                             "' not found in model " + str(model))

        # is it observable?
        if model.has_property(prop):
            # we need to create an observing method before registering
            meth = types.MethodType(self._get_observer_fun(prop), self)
            setattr(self, meth.__name__, meth)

        self._prop = getattr(model, prop)
        self._prop_name = prop

        # registration of model:
        self._model = model
        self.observe_model(model)
1102624
def jit_load(self):
        
        try:
            model = importlib.import_module('.' + self.model, 'andes.models')
            device = getattr(model, self.device)
            self.system.__dict__[self.name] = device(self.system, self.name)

            g = self.system.__dict__[self.name]._group
            self.system.group_add(g)
            self.system.__dict__[g].register_model(self.name)

            # register device after loading
            self.system.devman.register_device(self.name)
            self.loaded = 1
            logger.debug('Imported model <{:s}.{:s}>.'.format(
                self.model, self.device))
        except ImportError:
            logger.error(
                'non-JIT model <{:s}.{:s}> import error'
                .format(self.model, self.device))
        except AttributeError:
            logger.error(
                'model <{:s}.{:s}> not exist. Check models/__init__.py'
                .format(self.model, self.device))
415906
def hashmodel(model, library=None):
    ''''''
    library = library or 'python-stdnet'
    meta = model._meta
    sha = hashlib.sha1(to_bytes('{0}({1})'.format(library, meta)))
    hash = sha.hexdigest()[:8]
    meta.hash = hash
    if hash in _model_dict:
        raise KeyError('Model "{0}" already in hash table.\
 Rename your model or the module containing the model.'.format(meta))
    _model_dict[hash] = model
786899
def _loadModels(self):
        
        modelsPath = os.path.join(self.path, "model")
        if not os.path.isdir(modelsPath):
            return

        for modelFile in os.listdir(modelsPath):
            modelName = modelFile.replace(".py", "")
            modelPath = os.path.join(
                self.path, "model", modelFile
            )

            if not os.path.isfile(modelPath):
                continue

            # importing model
            modelSpec = importlib.util.spec_from_file_location(
                modelName,
                modelPath
            )
            model = importlib.util.module_from_spec(modelSpec)
            modelSpec.loader.exec_module(model)

            # initializing model
            modelInstance = model.Model(self.application)
            self.application.addModel(self.name, modelName, modelInstance)
432496
def load_object(self, kwargs):
        """"""
        self.object = None
        self.config = None
        self.model = self.get_model_class()
        kwargs.pop('app', None)
        kwargs.pop('model', None)

        if self.model and kwargs.get('pk', False):
            try:
                self.object = self.model.objects.get(pk=kwargs.pop('pk'))
            except Exception:
                raise Exception("Could not load {}".format(self.model.__name__.lower()))
            setattr(self, self.model.__name__.lower(), self.object)

        return kwargs
1005353
def load_model_class(model_path):
    
    dot = model_path.rindex('.')
    module_name = model_path[:dot]
    class_name = model_path[dot + 1:]
    try:
        _class = getattr(import_module(module_name), class_name)
        return _class
    except (ImportError, AttributeError):
        raise ImproperlyConfigured('%s cannot be imported' % model_path)
320879
def import_model(cls, ins_name):
        
        try:
            package_space = getattr(cls, 'package_space')
        except AttributeError:
            raise ValueError('package_space not exist')
        else:
            return import_object(ins_name, package_space)
649191
def get_model(model):
    
    try:
        if isinstance(model, str):
            app_label, model_name = model.split('.', 1)
            m = loading.get_model(app_label, model_name)
            if not m:  # pragma: no cover
                raise LookupError()  # Django < 1.7 just returns None
            return m
        elif issubclass(model, models.Model):
            return model
    except (LookupError, ValueError):
        pass
    raise ValueError(model)
530617
def _load_source_model(self):
		

		# If source_model exists, return it
		if hasattr(self, "source_model"):
			return self.source_model

		# Getting the source model
		module = self.get_python_module()

		# Test if module has inside the model we are looking for
		if hasattr(module, self.model):
			# Setting of source model
			self.source_model = getattr(module, self.model)
			# Setting of verbose name and its plural for later use
			self.source_model.meta__verbose_name = self.source_model._meta.verbose_name
			self.source_model.meta__verbose_name_plural = self.source_model._meta.verbose_name_plural
			return self.source_model
		
		raise ValueError(u"Model {0} does not exist in module".format(self.model, self.module))
53550
def _load_model(self, dct):
        
        classname, version, _ = _pop_metadata(dct)

        _check_version(version)
        cls = self._models[classname]

        # Use `from_json` if available
        if hasattr(cls, 'from_json'):
            return cls.from_json(dct)

        # Default to object constructor
        return cls(**dct)
1039426
def load_model(self, name=None):
        '''
        

        '''

        if self.clobber:
            return False

        if name is None:
            name = self.name
        file = os.path.join(self.dir, '%s.npz' % name)
        if os.path.exists(file):
            if not self.is_parent:
                log.info("Loading '%s.npz'..." % name)
            try:
                data = np.load(file)
                for key in data.keys():
                    try:
                        setattr(self, key, data[key][()])
                    except NotImplementedError:
                        pass

                # HACK: Backwards compatibility. Previous version stored
                # the CDPP in the `cdpp6`
                # and `cdpp6_arr` attributes. Let's move them over.
                if hasattr(self, 'cdpp6'):
                    self.cdpp = self.cdpp6
                    del self.cdpp6
                if hasattr(self, 'cdpp6_arr'):
                    self.cdpp_arr = np.array(self.cdpp6_arr)
                    del self.cdpp6_arr
                if hasattr(self, 'gppp'):
                    self.cdppg = self.gppp
                    del self.gppp

                # HACK: At one point we were saving the figure instances,
                # so loading the .npz
                # opened a plotting window. I don't think this is the case
                # any more, so this
                # next line should be removed in the future...
                pl.close()

                return True
            except:
                log.warn("Error loading '%s.npz'." % name)
                exctype, value, tb = sys.exc_info()
                for line in traceback.format_exception_only(exctype, value):
                    ln = line.replace('\n', '')
                    log.warn(ln)
                os.rename(file, file + '.bad')

        if self.is_parent:
            raise Exception(
                'Unable to load `%s` model for target %d.'
                % (self.name, self.ID))

        return False
24162
def load(fp, model=None, parser=None):
    """"""
    if not model:
        model = 'simple'
    if not parser:
        parser = 'quick'

    if model not in ['simple']:
        raise ValueError
    if parser not in ['quick']:
        raise ValueError

    if model == 'simple' and parser == 'quick':
        return ARPAParserQuick(ARPAModelSimple).parse(fp)
    else:
        raise ValueError
392091
def load_models(module):
    """"""
    modules = _import_submodules(module)
    return {m for module in modules for m in filter(
        _check_model, (getattr(module, name) for name in dir(module))
    )}
336739
def load(self, model):
        """"""
        self.perceptron.weights, self.tagdict, self.classes, self.clusters = load_model(model)
        self.perceptron.classes = self.classes
867206
def load_model_by_id(self, model_id):
        

        with open(os.path.join(self.path, str(model_id) + ".json")) as fin:
            json_str = fin.read().replace("\n", "")

        load_model = json_to_graph(json_str)
        return load_model
1175336
def model(self, *args, **kwargs):
        
        return self._client.model(*args, bucket=self.bucket.get('id'), **kwargs)