---
# System prepended metadata

title: 三級分析 / geneyx / APIs
tags: [瑞林⽣技, 基因體/三級分析, 基因體, 三級分析, geneyx, 生物資訊]

---

三級分析 / geneyx / APIs
===
###### tags: `基因體/三級分析`
###### tags: `生物資訊`, `基因體`, `三級分析`, `geneyx`, `瑞林⽣技`

![](https://i.imgur.com/CEvnroE.png)


[TOC]

<br>

## API
> https://github.com/geneyx/geneyx.analysis.api

### response
- success
- error
    - VCF samples > annotate
        > https://www.prisma-gene.com.tw/sample/annotate
        ```
        {
            "Code": "error",
            "Info": "No pipeline was found ready to be annotated by version set v5.12",
            "NeedEval": false
        }
        ```

### Q & A
- docs/geneyx.analysis.api 沒有此檔案


<br>

<hr>

<br>

## pipeline (prod)

### Step1 - config.yaml
> [loadYamlFile(](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga_helperFunctions.py)

- [ga.config.yml](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga.config.yml)
    ```yaml=
    server: 'https://www.prisma-gene.com.tw'
    apiUserId: 'enter-your-userid'
    apiUserKey: 'enter-your-userkey'
    ```
- code
    ```python
    # add user connection fields
    data['ApiUserKey'] = config['apiUserKey']
    data['ApiUserID'] = config['apiUserId']

    # send request
    api = config['server'] + '/api/xxx'
    ```

### Step2 - CreatePatient
> - [API doc](https://github.com/geneyx/geneyx.analysis.api/wiki/CreatePatient)
> - [templates / patient.json](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/templates/patient.json)
> - [scripts / ga_createPatient.py](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga_createPatient.py)

- request URL
    [`/api/CreatePatient`](https://github.com/geneyx/geneyx.analysis.api/wiki/CreatePatient)
- payload
    ```json=
    {
      "ApiUserID": "enter-your-userid",
      "apiUserKey": "enter-your-userkey",
      "SerialNumber":"SN-TJ-0421"
    }
    ```
    - required
        - `SerialNumber` (unique)
            - SN 已經存在時，create 會有 error
                ```json
                {
                  "Code": "error",
                  "Info": "An item with that name already exists.",
                  "NeedEval": false
                }
                ```
    - full payload
        - 透過 `https://www.prisma-gene.com.tw/patient/Create`
            ```json=
            {
              "isNewPatient":true,
              "isLocked":false,
              "Gender":"",
              "UseConsentPersonal":"",
              "UseConsentClinical":"",
              "Consang":"",
              "SerialNumber":"SN-TJ-0421",
              "ID":null
            }
            ```
- response
    > based on UI
    ```json=
    {
      "SerialNumber":"SN-TJ-0421",
      "Consang":0,
      "ConsangName":"Unknown",
      "ID":"e7b5e50d-6c54-430e-ad60-a0a9b0e4e8e6",
      "CreatedByUser":"Grace Wu",
      "CreateDate":"2023-04-21T01:38:37.962179Z",
      "ModifiedByUser":"Grace Wu",
      "ModifyDate":"2023-04-21T01:38:37.962179Z"
    }
    ```
    - `/patient/getBySn` 仍是透過 `SerialNumber` ，而不用 `ID`
    - 在下一步 CreateSample 階段，SubjectId 用的是 `ID` 而不是 `SerialNumber` 


### Step3 - CreateSample
> - [API doc](https://github.com/geneyx/geneyx.analysis.api/wiki/Create-Sample)
> - [templates / sample.json](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/templates/sample.json)
> - [scripts / ga_uploadSample_json.py](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga_uploadSample_json.py)
> - [scripts / ga_uploadSamples.py](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga_uploadSamples.py)


- request URL
    `/api/createSample`
- payload
    ```json=
    {
      "ApiUserID": "enter-your-userid",
      "apiUserKey": "enter-your-userkey",
      "SampleSerialNumber": "HG002.hiseqx.pcr-free.30x-0418.vcf.gz",
      "SubjectId": 
    }
    ```
    - required
        - `SerialNumber` (unique)
- response
    > based on UI
    ```json=
    {
        "fileUrl": "HG002.hiseqx.pcr-free.30x-0418.vcf.gz"
    }
    ```

<br>

<hr>

<br>


## pipeline (study based on UI)
### Step1 - config.yaml
- 準備
    -  [ga.config.yml](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga.config.yml)

### Step3 - UploadSampleFile
- request URL
    > 透過 `https://www.prisma-gene.com.tw/File/UploadSampleFile`
- payload
- response
    > based on UI
    ```json=
    {
        "fileUrl": "HG002.hiseqx.pcr-free.30x-0418.vcf.gz"
    }
    ```

(TODO, on-going)

### Step4: 開始分析
可能有兩個地方：
- https://www.prisma-gene.com.tw/case/Create , POST
    > 開始分析?
    > 
    [![](https://i.imgur.com/fUGRCZr.png)](https://i.imgur.com/fUGRCZr.png)
    - payload
        ```json=
        {
          "ID":"6ea4143b-4ba1-4898-b137-dd11c744e883",
          "ProtocolId":"b5f89905-8585-4e77-8dd0-00b9fef22b0a",
          "Name":"Single Sample Analysis",
          "PhenAlleleFreq":0.001,
          "GeneticModels":[
            1,
            2,
            4,
            128,
            256,
            1073741824
          ],
          "Phenotypes":"",
          "IsAdvancedPhenotypes":false,
          "PatientId":"0e85fc55-6fd3-41b9-9fa7-5d205b502bdb",
          "SerialNumber":"SN-HG002-SSA",
          "MainSampleId":"3f194b42-a54c-4058-b123-5aff1bdb72a6"
        }
        ```
- https://www.prisma-gene.com.tw/case/initializeCase , POST
    > 開始分析?
    > 
    ![](https://i.imgur.com/WcrYMGK.png)
    - payload
        ```****
        {
          "caseId": "6ea4143b-4ba1-4898-b137-dd11c744e883"
        }
        ```
    - response
        ```true```
- https://www.prisma-gene.com.tw/sample/getCurrentVariantSummary , POST
    > 回傳狀態
    > 
    ![](https://i.imgur.com/19YLRGb.png)
    <br>
    ![](https://i.imgur.com/KsIWOEY.png)
    <br>
    - payload
        ```json=
        {
          "sampleId": "3f194b42-a54c-4058-b123-5aff1bdb72a6",
          "versionSetId": "8587f3bd-eba1-446e-b388-8c7bf115e090"
        }
        ```
    - response
        ```json=
        {
          "ID":"578e7b12-4d01-474f-b006-2fd519edabde",
          "VersionSetId":"8587f3bd-eba1-446e-b388-8c7bf115e090",
          "VersionSetName":"v5.12",
          "StatusName":"ExecSnpEff",
          "Status":4,
          "TimeStamp":"2023-04-18T10:34:01.24Z",
          "Notes":"started",
          "Stats":{
            "Variants":0,
            "Lines":0,
            "AaChangeCount":0,
            "DepthMedian":0
          },
          "Pipeline":1,
          "PipelineName":"Snv",
          "IsDone":false,
          "Disabled":false,
          "InArchive":false
        }
        ```

### Step5: 產生報表
`https://analysis.geneyx.com/caseReport/CreateReport`


<br>

<hr>

<br>

## files
<!-- [ChatGPT] 請說明底下程式碼每個函數的用途： -->

### [scripts/UnifiedVcf.py](https://github.com/geneyx/geneyx.analysis.api/blob/1c741ec00a5823649f8a213af2f8bff07447b25d/scripts/UnifiedVcf.py)
這個程式碼主要是將不同格式的 VCF 文件（SNV, CNV, 重複序列）合併成一個 VCF 文件。以下是每個函數的用途：
- `__get_lines__(file_path: str) -> []`:
    這個函數會讀取指定路徑的文件，並回傳文件的所有行。這個函數可以處理 gzip 格式的壓縮文件。
- `__modify_repeat_line__(repeat_line: str) -> str`:
    這個函數會修改重複序列文件中的一行，增加 SVTYPE=REP 到 INFO 欄位。
- `__is_valid_line__(line: str) -> bool`: 
    這個函數會檢查指定的 VCF 行是否合法。如果行是 header 或者是空行，就視為合法。如果行中包含 SVTYPE=，也視為合法。否則，需要檢查 GT（基因型）欄位，如果 GT 是 0 或者是 ./.，就視為不合法。
- `__write_vcf_content__(ftype: str, lines_dict: dict, output_h)`: 
    這個函數會將指定文件類型的 VCF 內容寫入到輸出文件。如果文件類型是 repeat，會先呼叫 __modify_repeat_line__ 函數來修改行中的 INFO 欄位。
- `__get_vcf_header__(vcf_file: str)`: 
    這個函數會從指定的 VCF 文件中讀取 header。
- `__get_vcf_header_from_lines__(vcf_lines: [])`: 
    這個函數會從指定的 VCF 行中讀取 header。
- `__is_empty__(lines: []) -> bool`: 
    這個函數會檢查指定的行是否都是空行或者是 header 行。
- `__create_unified_file__(files_lines: dict, output_path: str)`：
    創建一個合併的 VCF 文件。如果 sv 檔案不為空，則先寫入 sv 檔案的內容；否則，寫入 cnv 和 repeat 檔案的內容。在寫入 repeat 檔案的內容之前，需要先從檔案中讀取 VCF 標頭。對於 cnv 和 repeat 檔案，必須檢查每一行是否有效，並且必須在寫入之前修改 info 段落。
    **細節：**
    函數的目的是將 files_lines 中的 sv、cnv 和 repeat 三種 vcf 檔案合併成一個統一的 vcf 檔案，並將合併後的檔案存儲到 output_path 中。在執行此函數時，會先將 sv 檔案的內容寫入輸出檔案，接著將 cnv 檔案和 repeat 檔案的內容寫入輸出檔案。如果 sv 檔案為空，則只有 cnv 檔案和 repeat 檔案的內容會被寫入輸出檔案。如果 cnv 檔案為空，則只有 repeat 檔案的內容會被寫入輸出檔案。如果所有檔案都為空或不存在，則會輸出警告信息。
- `run(output_path: str, sv_path: str = None, cnv_path: str = None, repeat_path: str = None)`：
    運行整個程序，將三個不同類型的 VCF 檔案合併成一個 VCF 檔案。如果某個檔案不存在或是空的，則發出警告。

<br>

### [scripts/ga.config.yml](https://github.com/geneyx/geneyx.analysis.api/blob/1c741ec00a5823649f8a213af2f8bff07447b25d/scripts/ga.config.yml)
程式碼中的設定檔，其中
- server 指定了連接的伺服器位址，
- apiUserId 和 apiUserKey 是需要填入使用者的 ID 和 Key，用於授權和驗證該使用者的身份。透過這些設定，程式碼可以透過提供的使用者身份，連接到指定的伺服器，並存取該伺服器提供的資源和服務。

<br>
    
### [scripts/ga_CreateCase.py](https://github.com/geneyx/geneyx.analysis.api/blob/1c741ec00a5823649f8a213af2f8bff07447b25d/scripts/ga_CreateCase.py)
用於建立一個 Geneyx Analysis 平台上的案例。程式中包含以下功能：

- 匯入 argparse 模組，用於解析命令列參數。
- 匯入 requests 模組，用於向 Geneyx Analysis 平台發送 HTTP 請求。
- 匯入 ga_helperFunctions 模組，這是一個自定義的模組，其中包含一些用於輔助處理的函式。
- 定義 _verifyRequiredFields 函式，用於驗證必要欄位是否存在於輸入的 JSON 數據中。
- 解析命令列參數，其中包括：
    - --data：指定案例數據的 JSON 文件的路徑。
    - --config：指定配置文件的路徑，其中包含 Geneyx Analysis 平台的 API 金鑰等信息。
- 讀取配置文件。
- 讀取案例數據 JSON 文件。
- 驗證必要欄位是否存在於案例數據 JSON 中。
- 將 API 金鑰和用戶 ID 添加到案例數據中。
- 向 Geneyx Analysis 平台發送 HTTP POST 請求以創建案例。
- 在控制台中打印 HTTP 請求的結果和響應內容。

<br>
    
### [scripts/ga_uploadSample_json.py](https://github.com/geneyx/geneyx.analysis.api/blob/1c741ec00a5823649f8a213af2f8bff07447b25d/scripts/ga_uploadSample_json.py)
用來上傳一個或多個 VCF 檔案到 Geneyx Analysis 的平台，並透過一個 JSON 檔案，設定檔案相關屬性。其中，程式的核心功能涵蓋了以下幾個部分：

- 匯入 argparse、os、requests、ntpath 等 Python 標準函式庫以及自定義的 ga_helperFunctions 模組。
- 定義一些輔助函式，例如 _verifyRequiredFields 用來驗證資料是否符合規定。
- 使用 argparse 建立命令列參數解析器，以便在命令列執行時，使用者可以輸入相關參數，例如 snvVcf、svVcf、cnvVcf 等。
- 讀取配置檔案 ga.config.yml，並載入其中的設定。
- 檢查所提供的 SNV、SV、CNV 檔案是否存在，若不存在則會產生例外。
- 如果同時提供了 SV 與 CNV 檔案，則會將這兩個檔案合併成一個檔案；如果只提供了其中一個檔案，則直接使用該檔案。
- 讀取並驗證所提供的 JSON 檔案，並根據該檔案中的設定，設定檔案相關屬性。
- 上傳檔案到 Geneyx Analysis 的平台。

<br>
    
### [scripts/ga_uploadSamples.py](https://github.com/geneyx/geneyx.analysis.api/blob/1c741ec00a5823649f8a213af2f8bff07447b25d/scripts/ga_uploadSamples.py)
上傳一組 VCF 檔案作為樣本到 Geneyx Analysis。使用 argparse 套件解析命令列參數，程式能夠處理多種不同格式的 VCF 檔案，並能自動合併 SV 與 CNV 檔案。

程式還提供了多種選項，例如可以指定樣本的生物標本 ID、取樣日期、樣本類型、樣本來源、樣本的父母親等資訊，也可以附加樣本的 BAM 檔案 URL 或甲基化資料的 URL。

除了必填參數外，也提供了許多可選參數，如跳過上傳後的注釋、指定配置檔等。

- 相關資料
    - sample data 樣本資料
    - sample external files 樣本外部檔案
        - BAM 檔案 URL 
        - 甲基化資料的 URL
    - patient data 病患資料

<br>

<hr>

<br>

## [Geneyx Analysis API Collection](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json)
- 全都是
    - **method**: POST
    - **protocol**: https
    - **host**: analysis.geneyx.com
    - **body.options.raw.language**: json (raw 內容都是 json 格式)
    - **body.raw**: 都要攜帶底下兩個參數 
        - `ApiUserId: "enter_apiId"`
        - `ApiUserKey: "enter_apiKey"`
- info
    - "_postman_id": "dc8b1c84-ceeb-4ca2-938b-c5c27a3f38b9",
	- "name": "Geneyx Analysis  API Collection",
	- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
	- "_exporter_id": "18131911"
        <br>
- Overview

| API name | Usage|
|----------|-------|
| [AddClinicalRecord](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L10) | `/api/AddClinicalRecord`<br>- SubjectId: "Enter_SubjectID",<br>- RecordDate: "yyyy-mm-dd",<br>- Description: "recorded something new",<br>- PhenotypeCodes: [ "HP:0001903", "HP:0000005" ] |
| [BatchReportList](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L40) | `/api/BatchReportList`<br>- batchName: "Enter_Batch_File_Name" |
| [BatchSeqSamples](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L70) | `/api/BatchSeqSamples`<br>- batchName: "string"|
| [BatchVcfSamples](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L100) | `/api/BatchVcfSamples`<br>- batchName: "string" |
| [Cases](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L130) | `/api/Cases` |
| [CaseAssignment](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L160) | `/api/CaseAssignment`<br>- SerialNumber: "string",<br>- AssignedToUserId: "00000000-0000-0000-0000-000000000000",<br>- AssignedToFullName: "string" |
| [CaseReports](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L190) | `/api/CaseReports`<br>- caseSn: "enter_caseSn" |
| [CreateCase](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L220) | `/api/CreateCase`<br>- SerialNumber: "string",<br>- Name: "string",<br>- Description: "string",<br>- PhenAlleleFreq: 0,<br>- Phenotypes: "string",<br>- Owner: "string",<br>- OwnerDepartment: "string",<br>- GeneList: "string",<br>- ProtocolId: "string",<br>- SubjectId: "string",<br>- ProbandSampleId: "string",<br>- AssociatedSamples: [ { Relation: 0, SampleId: "string", Affected: 0 } ],<br>- AssignedToUserId: "00000000-0000-0000-0000-000000000000",<br>- AssignedToFullName: "string",<br>- AssignedToUser: "string" |
| CreatePatient | `/api/CreatePatient` (推測), [[empty doc]](https://github.com/geneyx/geneyx.analysis.api/wiki/CreatePatient)<br>`/api/Patient` ([來源](https://github.com/geneyx/geneyx.analysis.api/blob/main/scripts/ga_createPatient.py#L37)) |
| CreateSample | `/api/CreateSample` (推測), [[doc]](https://github.com/geneyx/geneyx.analysis.api/wiki/Create-Sample) |
| [DataEntryBatches](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L250) | `/api/DataEntryBatches` |
| [enrichmentKits](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L280) | `/api/enrichmentKits` |
| [GetVcfSampleQcData](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L310) | `/api/GetVcfSampleQcData`<br>- sampleSn: "string" |
| [GetVcfSampleCoverage](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L340) | `/api/GetVcfSampleCoverage`<br>- sampleSn: "string" |
| [GetVcfSampleFile](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L370) | `/api/GetVcfSampleFile`<br>- sampleSn: "string" |
| [GetVcfSampleArtifact](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L400) | `/api/GetVcfSampleArtifact`<br>- sampleSn: "string",<br>- pipelineType: "string" |
| [Patient](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L430) | `/api/patient`<br>- SerialNumber: "123456789",<br>- Name: "Patient-Name",<br>- DateOfBirth: "2001-06-25", <br>- Gender: "M",<br>- Consang: "NonConsang",<br>- PopulationType: "general population",<br>- PaternalAncestry: "string",<br>- MaternalAncestry: "string",<br>- PaternalGrandfather: "string",<br>- PaternalGrandmother: "string",<br>- MaternalGrandfather: "string",<br>- MaternalGrandmother: "string",<br>- FamilyHistory: "long long history of nothing",<br>- UseConsentPersonal: "true",<br>- UseConsentClinical: "false",<br>- HasBioSample: "true",<br>- GenerallyHealthy: "false",<br>- ClinicalRecords: [<br>{ RecordDate: "2005-06-25", Description: "recorded something", PhenotypeCodes: [ "HP:0002000" ] }<br>] |
| [Patients](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L460) | `/api/patients` |
| [Protocols](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L490) | `/api/Protocols` |
| [ReportUrl](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L520) | `/api/ReportUrl`<br>- fileName: "string" |
| [ReportList](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L550) | `/api/ReportList`<br>- startTime: "string" |
| [Samples](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L580) | `/api/Samples` |
| [SampleAssignment](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L610) | `/api/SampleAssignment`<br>- SerialNumber: "string",<br>- GroupAssignment: [ { Code: "string", Name: "string" } ],<br>- AssignedToUserId: "00000000-0000-0000-0000-000000000000",<br>- AssignedToFullName: "string" |
| [SequenceMachines](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L640) | `/api/SequenceMachines` |
| [UpdateSampleQc](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L670) | `/api/UpdateSampleQc`<br>- SampleSerialNumber: "string",<br>- SampleTakenDate: "2022-12-27T18:56:48.329Z",<br>- SampleSequenceDate: "2022-12-27T18:56:48.329Z",<br>- SampleReceivedDate: "2022-12-27T18:56:48.329Z",<br>- SampleType: "string",<br>- SampleTarget: "string",<br>- SampleSource: "string",<br>- SampleSequenceMachineId: "string",<br>- SampleEnrichmentKitId: "string",<br>- SampleNotes: "string",<br>- SampleRelation: "string",<br>- SampleGenomeBuild: "string",<br>- BamUrl: "string",<br>- SnvFile: "string",<br>- StructFile: "string",<br>- SampleQcData: "string",<br>- SubjectId: "string",<br>- SubjectName: "string",<br>- SubjectGender: "string",<br>- SubjectDateOfBirth: "2022-12-27T18:56:48.329Z",<br>- SubjectConsanguinity: "string",<br>- SubjectPopulationType: "string",<br>- SubjectPaternalAncestry: "string",<br>- SubjectMaternalAncestry: "string",<br>- SubjectFamilyHistory: "string",<br>- SubjectHasBioSample: true,<br>- SubjectUseConsentPersonal: true,<br>- SubjectUseConsentClinical: true,<br>- GroupAssignment: [ { Code: "string", Name: "string" } ],<br>- AssignedToUserId: "00000000-0000-0000-0000-000000000000",<br>- AssignedToFullName: "string",<br>- SkipAnnotation: true |

<br>

<hr>

<br>

## API Responses
### [Cases](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L130)
> `/api/Cases`

[![](https://i.imgur.com/nUZdmHa.png)](https://i.imgur.com/nUZdmHa.png)
```json
{
  "Items":[
    ...,
    {
      "PatientId":"7bd15904-b14c-4a0d-9818-e202ab1c8dfc",
      "Patient":"HG002",
      "SerialNumber":"SN-HG002",
      "Name":"Single Sample Analysis",
      "VersionSetId":"6232d942-435a-4fe3-9075-e1ea1caf7ec4",
      "VersionSetName":"v5.12",
      "VersionSetNumber":41,
      "VersionSetArchived":false,
      "VersionSetLatest":true,
      "Status":0,
      "StatusName":"Open",
      "MainSampleId":"5e00cad6-5c52-4fea-945b-f8ef476ce755",
      "MainSampleSerialNumber":"HG002.hiseqx.pcr-free.30x.vcf.gz",
      "PhenAlleleFreq":0.001,
      "Phenotypes":"",
      "IsAdvancedPhenotypes":false,
      "GeneticModels":[1, 2, 4, 256],
      "GeneticModelNames":["Recessive HOM", "Recessive Compound HET", "Dominant HET", "Secondary Findings"],
      "ProtocolId":"73b911c9-2d81-46aa-b917-a87ed92d3676",
      "ProtocolName":"Single Sample Analysis",
      "ProtocolTypeName":"RareGenetics",
      "ProtocolSerialNumber":"RG_SINGLE",
      "AutoAnalyze":false,
      "AutoReport":false,
      "SortAsc":false,
      "ExpandColumns":{"COSMIC":true, "MitoEvidence":true, "Civic":true},
      "CalcLocalFreq":false,
      "UnfilterEvidence":false,
      "ReadyForAnalysis":true,
      "SamplesReady":true,
      "HasAnalysis":true,
      "HasReport":true,
      "GenomeBuild":1,
      "AcmgCalcDate":"2023-03-27T07:12:40.767Z",
      "IbdParentsCalcStatus":"None",
      "IsTrio":false,
      "ID":"62beb88f-8eae-414c-83ff-f0c2fd4bf2d5",
      "CreatedByUser":"Grace Wu",
      "CreateDate":"2023-03-27T07:01:52.607Z",
      "ModifiedByUser":"Grace Wu",
      "ModifyDate":"2023-03-30T06:15:16.13Z"
    },
    ...
  ],
  "Total":7
}
```

<br>

### [Patients](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L460)
> `/api/patients`

[![](https://i.imgur.com/AkuTk3M.png)](https://i.imgur.com/AkuTk3M.png)

```json=
{
  "Items":[
    ...,
    {
      "SerialNumber": "HG002",
      "Gender": "M",
      "Consang": 0,
      "ConsangName": "Unknown",
      "PopulationType": "White / Ashkenazim Jewish",
      "UseConsentPersonal": true,
      "ID": "7bd15904-b14c-4a0d-9818-e202ab1c8dfc",
      "CreatedByUser": "Grace Wu",
      "CreateDate": "2023-03-27T02:30:56.303Z",
      "ModifiedByUser": "Grace Wu",
      "ModifyDate": "2023-03-30T09:14:41.38Z"
    },
    ...
  ],
  "Total":3
}

```

<br>

### [Protocols](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L490)
> `/api/Protocols`

[![](https://i.imgur.com/B9viaqd.png)](https://i.imgur.com/B9viaqd.png)

```json=
{
  "Items":[
    {
      "Name": "Single Sample Analysis",
      "SerialNumber": "RG_SINGLE",
      "Description": "Only the affected sample is available",
      "GeneticModelNames": [ "Recessive HOM", "Recessive Compound HET", "Dominant HET", "Secondary Findings" ],
      "GeneticModels": [ 1, 2, 4, 256 ],
      "PhenAlleleFreq": 0.001,
      "Ordinal": 1,
      "MainSampleSource": 1,
      "MainSampleSourceName": "GermLine",
      "IsAdvancedPhenotypes": false,
      "ReportTemplateId": "8fa4512d-78c1-4c3c-9728-da0ad4580800",
      "ReportTemplateName": "Rare Genetics Default",
      "SortAsc": false,
      "CalcLocalFreq": false,
      "Type": 2,
      "TypeName": "RareGenetics",
      "ExpandColumns": [ "COSMIC", "MitoEvidence", "Civic" ],
      "AutoAnalyze": false,
      "AutoReport": false,
      "AutoAnnotateBasedOnPrev": false,
      "AlwaysShowPatVars": false,
      "ID": "73b911c9-2d81-46aa-b917-a87ed92d3676",
      "CreatedByUser": "Grace Wu",
      "CreateDate": "2023-02-06T08:44:23.713Z",
      "ModifiedByUser": "Grace Wu",
      "ModifyDate": "2023-02-06T08:44:23.713Z"
    },
    {"Name":"Trio Analysis",...},
    {"Name":"Tumor Only Analysis",...},
    {"Name":"Tumor / Normal Analysis",...},
    {"Name":"Carrier Screening",...},
    {"Name":"Cancer Screening",...},
    {"Name":"Mitochondria Analysis",...},
    {"Name":"Germline - SV",...}
  ],
  "Total":8
}
```

<br>

### [Samples](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L580)
> 列出樣本清單
> - from backend API
>   `/api/Samples`
>   - [docs/Samples.md](https://github.com/geneyx/geneyx.analysis.api/blob/main/docs/Samples.md)
>     used to retrieve the list of samples in the account.
> - from UI portal
>   `https://www.prisma-gene.com.tw/sample/getItems` (列出樣本清單)
>   `https://www.prisma-gene.com.tw/sample/GetFormOptions` (取得編輯 sample 的表單選項清單)
>   `https://www.prisma-gene.com.tw/sample/Update` (更新某個 samlpe)

[![](https://i.imgur.com/sbhU0f1.png)](https://i.imgur.com/sbhU0f1.png)

- `https://www.prisma-gene.com.tw/sample/getItems`
    ```json=
    {
      "Items":[
        ...,
        {
          "PatientId":"7bd15904-b14c-4a0d-9818-e202ab1c8dfc",
          "Patient":"HG002",
          "SerialNumber":"HG002.hiseqx.pcr-free.30x.vcf.gz",
          "EnrichmentKitId":"cd52c5cd-5b13-4add-915b-18c80d8a45a1",
          "EnrichmentKit":"Twist Human Core Exome",
          "EnrichmentKitDescription":"Twist Human Core Exome",
          "Target":1,
          "TargetName":"WholeGenome",
          "Source":1,
          "SourceName":"GermLine",
          "BamUrl":"",
          "BamFileExists":false,
          "MethylationFileExists":false,
          "Relation":0,
          "RelationName":"Self",
          "GenomeBuild":1,
          "GenomeBuildName":"hg38",
          "Assignment":{
            "AssignDate":"0001-01-01T00:00:00Z",
            "GroupCodes":[ ],
            "Groups":[ ]
          },
          "Files":[
            {
              "ID":"a4a5423d-e6c2-4009-8a7c-b225975639a0",
              "FileTypeName":"SNV",
              "FileType":1,
              "FileName":"HG002.hiseqx.pcr-free.30x.vcf.gz",
              "CreateDate":"2023-03-27T06:38:20.073Z"
            }
          ],
          "ExcludeFromLAF":false,
          "ID":"5e00cad6-5c52-4fea-945b-f8ef476ce755",
          "CreatedByUser":"Grace Wu",
          "CreateDate":"2023-03-27T06:38:20.077Z",
          "ModifiedByUser":"Grace Wu",
          "ModifyDate":"2023-03-27T06:59:49.037Z"
        },
        ...
      ],
      "Total":3
    }
    ```
- `https://www.prisma-gene.com.tw/sample/GetFormOptions`
    - UI
        [![](https://i.imgur.com/6Z9gBVz.png)](https://i.imgur.com/6Z9gBVz.png)
    - request payload
        ```json
        {
          "patientId":"7bd15904-b14c-4a0d-9818-e202ab1c8dfc",
          "sampleId":"5e00cad6-5c52-4fea-945b-f8ef476ce755"
        }
        ```
    - response
        ```json
        {
          "EnrichmentKits":[
            {
              "Text":"Twist Human Core Exome",
              "Value":"cd52c5cd-5b13-4add-915b-18c80d8a45a1"
            }
          ],
          "SequenceMachines":[
            {
              "Text":"HiSeq 2500",
              "Value":"758aeef1-71d2-4366-9900-d0f2b6f04684"
            },
            {
              "Text":"HiSeq 4000",
              "Value":"d0c7cadb-b2cb-45a9-b97f-3afa04da77fc"
            },
            {
              "Text":"MiSeq",
              "Value":"651c1397-2893-44f3-8db1-c4ac41d87437"
            },
            {
              "Text":"NextSeq 500",
              "Value":"586d71f5-814e-4a13-9209-7ec6f4b946b8"
            },
            {
              "Text":"NovaSeq 6000",
              "Value":"c82ecff9-fb53-440f-bbe7-19e91c32e56f"
            }
          ],
          "DataFiles":[
            {
              "Text":"demo-germline-sample.vcf.gz",
              "Value":"demo-germline-sample.vcf.gz"
            },
            {
              "Text":"HG002.hiseqx.pcr-free.30x.R_.vcf.gz",
              "Value":"HG002.hiseqx.pcr-free.30x.R_.vcf.gz"
            },
            {
              "Text":"HG002.hiseqx.pcr-free.30x.vcf.gz",
              "Value":"HG002.hiseqx.pcr-free.30x.vcf.gz"
            },
            {
              "Text":"output (1).vcf.gz",
              "Value":"output (1).vcf.gz"
            },
            {
              "Text":"output (2).vcf.gz",
              "Value":"output (2).vcf.gz"
            },
            {
              "Text":"output.vcf.gz",
              "Value":"output.vcf.gz"
            },
            {
              "Text":"SRR7890824.vcf.gz",
              "Value":"SRR7890824.vcf.gz"
            }
          ],
          "IsSnvAnnotated":true,
          "IsSvAnnotated":false,
          "AllowChangeGenomeBuild":false
        }
        ```

<br>

### [SampleAssignment](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L610)
> `/api/SampleAssignment`

- request payload
    - SerialNumber: "string"
    - GroupAssignment: [ { Code: "string", Name: "string" } ]
    - AssignedToUserId: "00000000-0000-0000-0000-000000000000"
    - AssignedToFullName: "string"
- 用途
    > "assigned to user ID"（指派給用戶ID）通常是指將某個任務、工作或資源指派給特定的用戶。這個用戶負責完成這個任務、工作或資源，並承擔責任。在軟件開發、項目管理和工作流程中，指派給用戶ID通常用於追蹤和管理任務的分配和進度。
    - 將 sample 指派到其他 group ? (分享 sample?)
    - 指派到某個 user (id & name) ?
    

<br>

### [SequenceMachines](https://github.com/geneyx/geneyx.analysis.api/blob/main/Geneyx%20Analysis%20%20API%20Collection.postman_collection.json#L640) 
> 列出定序儀清單
> - from backend API
>   `/api/SequenceMachines`
>   - [docs/SequencingMachines.md](https://github.com/geneyx/geneyx.analysis.api/blob/main/docs/SequencingMachines.md)
>     used to retrieve the list of sequence machines in the account.
> - from UI portal
>   `https://www.prisma-gene.com.tw/SequenceMachine/Create`
>   `https://www.prisma-gene.com.tw/SequenceMachine/Search`
>   `https://www.prisma-gene.com.tw/SequenceMachine/Update`
>   `https://www.prisma-gene.com.tw/SequenceMachine/Delete`

[![](https://i.imgur.com/ZhHplEP.png)](https://i.imgur.com/ZhHplEP.png)

- `https://www.prisma-gene.com.tw/SequenceMachine/Create`
    - request payload
        ```json=
        {
          "SerialNumber":"NovaSeq 6000",
          "Description":"Illumina NovaSeq 6000 System"
        }
        ```
    - response
        ```json=
        {
          "SerialNumber":"NovaSeq 6000",
          "Description":"Illumina NovaSeq 6000 System",
          "ID":"c82ecff9-fb53-440f-bbe7-19e91c32e56f",
          "CreatedByUser":"Grace Wu",
          "CreateDate":"2023-02-06T08:44:23.103Z",
          "ModifiedByUser":"Grace Wu",
          "ModifyDate":"2023-02-06T08:44:23.103Z"
        }
        ```
- `https://www.prisma-gene.com.tw/SequenceMachine/Search`
    ```json=
    {
      "Items":[
        ...,
        {
          "SerialNumber":"NovaSeq 6000",
          "Description":"Illumina NovaSeq 6000 System",
          "ID":"c82ecff9-fb53-440f-bbe7-19e91c32e56f",
          "CreatedByUser":"Grace Wu",
          "CreateDate":"2023-02-06T08:44:23.103Z",
          "ModifiedByUser":"Grace Wu",
          "ModifyDate":"2023-02-06T08:44:23.103Z"
        },
        ...
      ],
      "Total":5
    }
    ```
- `https://www.prisma-gene.com.tw/SequenceMachine/Update`
    - request payload
        ```json=
         {
          "SerialNumber":"NovaSeq 6000",
          "Description":"Illumina NovaSeq 6000 System",
          "ID":"c82ecff9-fb53-440f-bbe7-19e91c32e56f",
          "CreatedByUser":"Grace Wu",
          "CreateDate":"2023-02-06T08:44:23.103Z",
          "ModifiedByUser":"Grace Wu",
          "ModifyDate":"2023-02-06T08:44:23.103Z"
        }
        ```
    - response
        - 同 request payload
- `https://www.prisma-gene.com.tw/SequenceMachine/Delete`
    - request payload
        ```json=
        {
          "id": "47c3245d-4736-48eb-889f-2f7221c50ff4"
        }
        ```
    - response
        ```json=
        {
          "SerialNumber":"NovaSeq 6000",
          "Description":"Illumina NovaSeq 6000 System",
          "ID":"c82ecff9-fb53-440f-bbe7-19e91c32e56f",
          "CreatedByUser":"Grace Wu",
          "CreateDate":"2023-02-06T08:44:23.103Z",
          "ModifiedByUser":"Grace Wu",
          "ModifyDate":"2023-02-06T08:44:23.103Z"
        }
        ```