Ejemplo n.º 1
0
 public GenesRepository(
     Neo4jDataService neo4jService,
     EbiDataService ebiDataService,
     EnsemblDataService ensemblDataService)
     : base("Gene", neo4jService)
 {
     EbiDataService     = ebiDataService;
     EnsemblDataService = ensemblDataService;
 }
Ejemplo n.º 2
0
        private void PutProteinsAndRelatedData(string geneName)
        {
            var gene = new Gene()
            {
                Name = geneName
            };

            var relatedData = EbiDataService.GetGeneRelatedData(geneName);

            foreach (var relatedItem in relatedData)
            {
                if (relatedItem["id"] == null ||
                    relatedItem["accession"] == null ||
                    relatedItem["protein"] == null)
                {
                    continue;
                }

                var protein = new Protein()
                {
                    Name     = relatedItem["id"].ToString(),
                    Code     = relatedItem["accession"].ToString(),
                    FullName = relatedItem["protein"]
                        ?["submittedName"]?.FirstOrDefault()
                        ?["fullName"]
                        ?["value"]
                               ?.ToString()
                               ?? string.Empty
                };

                _neo4jService.Client.Cypher.MergeEntity(gene)
                .MergeEntity(protein)
                .MergeRelationship(new GeneProteinRelationship())
                .ExecuteWithoutResults();

                var relatedSequences = new Sequence[]
                {
                    new Sequence()
                    {
                        Content = relatedItem["sequence"]["sequence"].ToString()
                    }
                };
                var relatedTaxons = relatedItem["organism"]["lineage"].Select(jt =>
                                                                              new Taxon()
                {
                    Name = jt.ToString()
                }
                                                                              );
                var relatedComments = relatedItem["comments"] != null ? relatedItem["comments"].Select(jt =>
                                                                                                       jt["text"] != null ? jt["text"].Select(jtt =>
                                                                                                                                              new Comment()
                {
                    Text = jtt["value"].ToString(),
                    Type = jt["type"].ToString()
                }) : new Comment[] {}
                                                                                                       ).SelectMany(c => c) : new Comment[] {};

                foreach (var sequence in relatedSequences)
                {
                    _neo4jService.Client.Cypher.MergeEntity(protein)
                    .MergeEntity(sequence)
                    .MergeRelationship(new ProteinSequenceRelationship())
                    .ExecuteWithoutResults();
                }

                foreach (var taxon in relatedTaxons)
                {
                    _neo4jService.Client.Cypher.MergeEntity(protein)
                    .MergeEntity(taxon)
                    .MergeRelationship(new ProteinTaxonRelationship())
                    .ExecuteWithoutResults();
                }

                foreach (var comment in relatedComments)
                {
                    _neo4jService.Client.Cypher.MergeEntity(protein)
                    .MergeEntity(comment)
                    .MergeRelationship(new ProteinCommentRelationship())
                    .ExecuteWithoutResults();
                }
            }
        }