---
# System prepended metadata

title: FHIR observation JSON (NCBI)

---

# FHIR observation JSON (NCBI)

NCBI

NCBI擁有一系列與生物技術和生物醫學相關的資料庫，是生物資訊學工具和服務的重要資源。

主要資料庫包括DNA序列的GenBank和生物醫學文獻的書目資料庫PubMed。其他資料庫包括NCBI表觀基因組學資料庫。

所有這些資料庫都可以通過Entrez搜尋引擎在線獲得。


NCBI Virus

NCBI Virus (nih.gov)    取檔CSV轉成使用格式

![image](https://hackmd.io/_uploads/rkHxqySd6.png)


用python將CSV轉成FHIR Observation JSON 

寫一個python轉檔程式，將以下CSV檔
Gene, Mutation_Type, Mutation_Position, Pathogenicity
EGFR, Missense, p.L747_T751delinsS, Pathogenic
轉成以下 FHIR Observation JSON 格式描述:

import csv
import json

def convert_to_observation_json(gene, mutation_type, mutation_position, pathogenicity):
    observation_json = {
        "resourceType": "Observation",
        "status": "final",
        "category": [
            {
                "coding": [
                    {
                        "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                        "code": "laboratory",
                        "display": "Laboratory"
                    }
                ],
                "text": "Laboratory"
            }
        ],
        "code": {
            "coding": [
                {
                    "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                    "code": "48018-6",
                    "display": "Genetic variant assessment"
                }
            ],
            "text": "Genetic variant assessment"
        },
        "subject": {
            "reference": "Patient/example"
        },
        "valueCodeableConcept": {
            "coding": [
                {
                    "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                    "code": gene,
                    "display": gene
                }
            ],
            "text": gene
        },
        "component": [
            {
                "code": {
                    "coding": [
                        {
                            "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                            "code": "id",
                            "display": "HGVS identifier"
                        }
                    ],
                    "text": "HGVS identifier"
                },
                "valueString": mutation_position
            },
            {
                "code": {
                    "coding": [
                        {
                            "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                            "code": "interpretation",
                            "display": "Observation interpretation"
                        }
                    ],
                    "text": "Observation interpretation"
                },
                "valueCodeableConcept": {
                    "coding": [
                        {
                            "system": "https://www.ncbi.nlm.nih.gov/labs/virus/vssi/#/virus?SeqType_s=Genome&utm_source=data-hub&VirusLineage_ss=Bacteriophage,%20all%20taxids",
                            "code": "P",
                            "display": "Pathogenic"
                        }
                    ],
                    "text": pathogenicity
                }
            }
        ]
    }

    return observation_json

def csv_to_json(csv_file):
    with open(csv_file, newline='') as csvfile:
        reader = csv.DictReader(csvfile)
        for row in reader:
            gene = row["Gene"]
            mutation_type = row["Mutation_Type"]
            mutation_position = row["Mutation_Position"]
            pathogenicity = row["Pathogenicity"]

            observation_json = convert_to_observation_json(gene, mutation_type, mutation_position, pathogenicity)
            print(json.dumps(observation_json, indent=2))

if __name__ == "__main__":
    csv_to_json("input.csv")
    
    
    在NCBI Virus的資料庫連結 改成從資料庫取出的C檔 執行才不會出問題。
    
    
    
    
BLAST
    
BLAST是一種強大的工具，用於查找與同一生物體或不同生物體中的查詢序列相似的序列。它在NCBI資料庫和伺服器上搜索查詢序列，並以所選格式將結果發佈回人員的瀏覽器。

BLAST的輸入序列大多是FASTA或GenBank格式，而輸出可以以各種格式提供，如HTML，XML格式和純文本。
HTML是NCBI網頁的預設輸出格式。

NCBI-BLAST的結果以圖形格式顯示，其中包含找到的所有命中，一個表格，其中包含具有評分相關數據的命中的序列標識符，以及感興趣序列的對齊和收到的命中與這些命中類似的BLAST分數。


BLAST: Basic Local Alignment Search Tool (nih.gov)
![image](https://hackmd.io/_uploads/HkJ-sJS_a.png)
