def get_organization(self, pattern):
     organization = None
     if pattern is not None:
         if "HBP-SP" in pattern:
             address = Address(locality='HBP', country='Europe')
             organization = Organization(pattern, address, None)
         elif pattern == "Blue Brain Project":
             address = Address(locality='Geneva', country='Switzerland')
             organization = Organization("Blue Brain Project", address,
                                         None)
         elif pattern == "Allen Institute":
             address = Address(locality='Seattle', country='United States')
             organization = Organization("Allen Institute", address, None)
         elif pattern in ("KTH-UNIC", "KOKI-UNIC"):
             address = Address(locality='HBP', country='Europe')
             organization = Organization("HBP-SP6", address, None)
         elif pattern == "Destexhe Lab":
             address = Address(locality='Gif-sur-Yvette', country='France')
             organization = Organization("CNRS", address, None)
         elif pattern in ("<<empty>>", "Other"):
             organization = None
         else:
             raise ValueError(
                 "Can't handle this pattern: {}".format(pattern))
     return organization
Пример #2
0
 def test_round_trip(self, kg_client):
     obj1 = Organization(name="NeuroPSI",
                         address=Address(locality="Saclay", country="France"),
                         parent=KGProxy(Organization, "http://fake_uuid_00481be7a1"))
     instance = Instance(Organization.path, obj1._build_data(kg_client), Instance.path)
     instance.data["@id"] = "http://fake_uuid_7bb3c1e78b"
     instance.data["@type"] = Organization.type
     obj2 = Organization.from_kg_instance(instance, kg_client)
     for field in ("name", "address", "parent"):
         assert getattr(obj1, field) == getattr(obj2, field)
Пример #3
0
 def test_build_data(self, kg_client):
     obj1 = Organization(name="NeuroPSI",
                         address=Address(locality="Saclay", country="France"),
                         parent=KGProxy(Organization, "http://fake_uuid_00481be7a1"))
     expected = {
         "name": "NeuroPSI",
         "address": {
             "@type": "schema:PostalAddress",
             "addressLocality": "Saclay",
             "addressCountry": "France"
         },
         "parentOrganization": {
             "@type": "nsg:Organization",
             "@id": "http://fake_uuid_00481be7a1"
         }
     }
     assert obj1._build_data(kg_client) == expected
    def add_organizations_in_KG_database(self):
        address = Address(locality='HBP', country='Europe')
        for sp_num in range(1, 13):
            org = Organization("HBP-SP{}".format(sp_num), address, None)
            org.save(NAR_client)
        addressBBP = Address(locality='Geneva', country='Switzerland')
        BBP = Organization("Blue Brain Project", addressBBP, None)
        BBP.save(NAR_client)

        addressAllen = Address(locality='Seattle', country='United States')
        spAllen = Organization("Allen Institute", addressAllen, None)
        spAllen.save(NAR_client)

        return ''
    def save(self, allow_update=True):
        if self.obj is None:  # create
            for key in ("author", "owner"):
                if isinstance(self.data[key], dict):
                    self.data[key] = [self.data[key]]
            self.obj = ModelProject(
                self.data["name"],
                [
                    Person(p["family_name"], p["given_name"],
                           p.get("email", None))
                    for p in as_list(self.data["owner"])
                ],
                [
                    Person(p["family_name"], p["given_name"],
                           p.get("email", None))
                    for p in as_list(self.data["author"])
                ],  # need to update person representation in clients,
                self.data.get("description"),
                datetime.now(),
                self.data.get("private", True),
                self.context["collab_id"],
                self.data.get("alias"),
                Organization(self.data["organization"]) if self.data.get(
                    "organization", False) else None,
                pla_components=None,
                brain_region=self._get_ontology_obj(BrainRegion,
                                                    "brain_region"),
                species=self._get_ontology_obj(Species, "species"),
                celltype=self._get_ontology_obj(CellType, "cell_type"),
                abstraction_level=self._get_ontology_obj(
                    AbstractionLevel, "abstraction_level"),
                model_of=self._get_ontology_obj(ModelScope, "model_scope"),
                old_uuid=self.data.get("old_uuid"),
                images=self.data.get("images"))
        else:  # update
            if "name" in self.data:
                self.obj.name = self.data["name"]
            if "alias" in self.data:
                self.obj.alias = self.data["alias"]
            if "author" in self.data:
                self.obj.authors = [
                    Person(p["family_name"], p["given_name"],
                           p.get("email", None))
                    for p in as_list(self.data["author"])
                ]  # need to update person representation in clients
            if "owner" in self.data:
                self.obj.owners = [
                    Person(p["family_name"], p["given_name"],
                           p.get("email", None))
                    for p in as_list(self.data["owner"])
                ]  # need to update person representation in clients
            if "app" in self.data:
                self.obj.collab_id = self.data["app"]["collab_id"]
            if "organization" in self.data and self.data[
                    "organization"] is not None:
                self.obj.organization = Organization(self.data["organization"])
            if "private" in self.data:
                self.obj.private = self.data["private"]
            if "cell_type" in self.data:
                self.obj.celltype = self._get_ontology_obj(
                    CellType, "cell_type")
            if "model_scope" in self.data:
                self.obj.model_of = self._get_ontology_obj(
                    ModelScope, "model_scope")
            if "abstraction_level" in self.data:
                self.obj.abstraction_level = self._get_ontology_obj(
                    AbstractionLevel, "abstraction_level")
            if "brain_region" in self.data:
                self.obj.brain_region = self._get_ontology_obj(
                    BrainRegion, "brain_region")
            if "species" in self.data:
                self.obj.species = self._get_ontology_obj(Species, "species")
            if "description" in self.data:
                self.obj.description = self.data["description"]
            if "old_uuid" in self.data:
                self.obj.old_uuid = self.data["old_uuid"]
            if "images" in self.data:
                self.obj.images = self.data["images"]

        # now save people, organization, model. No easy way to make this atomic, I don't think.
        for person in chain(as_list(self.obj.authors),
                            as_list(self.obj.owners)):
            if not isinstance(person, KGProxy):
                # no need to save if we have a proxy object, as
                # that means the person hasn't been updated
                person.save(self.client)
        if self.obj.organization and not isinstance(self.obj.organization,
                                                    KGProxy):
            self.obj.organization.save(self.client)
        self.obj.save(self.client)
        return self.obj
Пример #6
0
    def test__build_data(self):

        input_data = dict(
            name="PyNN v0.9.4",
            version="0.9.4",
            summary=
            "A Python package for simulator-independent specification of neuronal network models",
            description=
            "PyNN (pronounced 'pine') is a simulator-independent language for building neuronal network models.",
            #identifier=Identifier("RRID:SCR_002715"),
            citation=
            ("Davison AP, Brüderle D, Eppler JM, Kremkow J, Muller E, Pecevski DA, Perrinet L and Yger P (2009) "
             "PyNN: a common interface for neuronal network simulators. "
             "Front. Neuroinform. 2:11 doi:10.3389/neuro.11.011.2008"),
            license=License("CeCILL v2"),
            release_date=date(2019, 3, 22),
            previous_version=None,
            contributors=[
                Person("Davison", "Andrew", "*****@*****.**")
            ],
            project=None,
            image="https://neuralensemble.org/static/photos/pynn_logo.png",
            download_url=
            "https://files.pythonhosted.org/packages/a2/1c/78b5d476900254c2c638a29a343ea12985ea16b12c7aed8cec252215c848/PyNN-0.9.4.tar.gz",
            access_url="https://pypi.org/project/PyNN/0.9.4/",
            categories=None,
            subcategories=None,
            operating_system=[
                OperatingSystem("Linux"),
                OperatingSystem("MacOS"),
                OperatingSystem("Windows")
            ],
            release_notes=
            "http://neuralensemble.org/docs/PyNN/releases/0.9.4.html",
            requirements="neo, lazyarray",
            copyright=Organization("The PyNN community"),
            components=None,
            part_of=None,
            funding=[
                Organization("CNRS"),
                Organization("Human Brain Project")
            ],
            languages=ProgrammingLanguage("Python"),
            features=None,
            #keywords="simulation, neuroscience",
            is_free=True,
            homepage="https://neuralensemble.org/PyNN/",
            documentation="http://neuralensemble.org/docs/PyNN/",
            help="https://groups.google.com/forum/#!forum/neuralensemble")
        software_release = Software(**input_data)
        kg_data = software_release._build_data(client=None)
        assert kg_data == {
            'name':
            input_data["name"],
            'version':
            input_data["version"],
            'headline':
            input_data["summary"],
            'description':
            input_data["description"],
            'citation':
            input_data["citation"],
            'license': {
                '@id': input_data["license"].iri,
                'label': input_data["license"].label
            },
            'dateCreated':
            '2019-03-22',
            #'copyrightYear': input_data["release_date"].year,
            'author': {
                '@id': None,
                '@type': ['nsg:Person', 'prov:Agent']
            },
            #'image': {'@id': input_data["image"]},
            #'distribution': {
            #    'downloadURL': {"@id": input_data["download_url"]},
            #    'accessURL': {"@id": input_data["access_url"]}
            #},
            'operatingSystem': [{
                '@id': os.iri,
                'label': os.label
            } for os in input_data["operating_system"]],
            'releaseNotes': {
                '@id': input_data["release_notes"]
            },
            'softwareRequirements':
            input_data["requirements"],
            'copyrightHolder': {
                '@id': None,
                '@type': ['nsg:Organization']
            },
            'funder': [{
                '@id': None,
                '@type': ['nsg:Organization']
            }, {
                '@id': None,
                '@type': ['nsg:Organization']
            }],
            #'programmingLanguage': [{'@id': input_data["languages"].iri, 'label': input_data["languages"].label}],
            #'keywords': input_data["keywords"],
            'isAccessibleForFree':
            input_data["is_free"],
            'url': {
                '@id': input_data["homepage"]
            },
            'documentation': {
                '@id': input_data["documentation"]
            },
            'softwareHelp': {
                '@id': input_data["help"]
            }
        }