Python

共 6 篇文章

NT FASTA近億等級數量索引

2 分鐘閱讀

情境說明,自己玩的專案中需要建立NT資料庫
並且需要經過資料清洗,像是將資料庫分成human和non human的fasta 並將無taxon分類的sequences排除
可怕的是目前的NT的序列數已達到9400萬條

策略是先遊歷一遍整個檔案 並記錄每個sequence的taxid及file offset (f.tell())儲存到dictionary

透過記錄的offset,使用f.seek()快速到達指定的sequence位置,並依據taxid判斷是屬於human或non human的sequence分別寫入到兩個fasta

因此本篇測試有哪些key-value類型的資料結構可以快速索引fasta中seqid於檔案中位置
且符合時間成本、硬體資源等效益

Ubuntu 22.04 setup after installation

2 分鐘閱讀

The following setup is my customization while ubuntu initialization

Operating System

Input method

fcitx5-rime

sudo apt install fctix5-*
im-config  

勉強適合Ubuntu22.04的中文輸入法

nfs-common

sudo apt install nfs-common
sudo mount -t nfs $remote_host:/remote/path /local/path

GNOME

window minimize

gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

circle windows

gsettings set org.gnome.shell.extensions.dash-to-dock scroll-action 'cycle-windows'

If the commands are not working, you can install dconf-editor to set.

Switching between windows with scroll wheel on Ubuntu Dock
Essential Guide: How to Enable ‘Minimize on Click’ on Ubuntu Quickly

打包python套件上傳PyPI

2 分鐘閱讀

依賴套件管理

專案中的python package我是用poetry管理
好處是可以分開開發時才使用的套件跟程式執行時依賴的套件
移除不用的套件時還可以確認依賴套件的依賴套件也全部被移除了
這點是pip做不到的,他只會移除你指定的套件

這文章寫的很詳細如何使用poetry

再見了 pip!最佳 Python 套件管理器——Poetry 完全入門指南

雖然其他如virtualenv和pyvenv也可以建立python虛擬環境
但也是無法完全地管理依賴套件版本

專案結構

以我這次寫的專案Juno為例,這個專案目錄下的結構如下

.
├── Dockerfile
├── juno
│   ├── cli.py
│   ├── config.py
│   ├── data
│   ├── data.py
│   ├── __init__.py
│   ├── simulator.py
│   ├── tools
│   └── web.py
├── LICENSE
├── pyproject.toml
├── README.md
└── setup.py