FatihMSA — Çoklu Dizi Hizalaması
MUSCLE (Multiple Sequence Comparison by Log-Expectation) algoritmasının Python ile yazılmış eğitim amaçlı implementasyonu. K-mer tabanlı mesafe hesaplama, UPGMA rehber ağaç ve Needleman-Wunsch dinamik programlaması kullanarak N diziyi hizalar.
Kurulum
pip install FatihMSA-221201001
Ya da geliştirici modunda (kaynak koddan):
git clone <repo-url>
cd FatihMSA
pip install -e .
Hızlı Kullanım
Python API
from fatihmsa import run_muscle, read_fasta, write_fasta, sequences_to_list
# Ham string listesiyle
sequences = ["ATCGATCG", "ATCGTTCG", "GCTAGCTA", "GCTAACTA"]
aligned = run_muscle(sequences)
for i, seq in enumerate(aligned):
print(f"Dizi {i}: {seq}")
# FASTA dosyasından
fasta = read_fasta("input.fasta")
ids, seqs = sequences_to_list(fasta)
aligned = run_muscle(seqs)
# Sonucu FASTA olarak kaydet
write_fasta(dict(zip(ids, aligned)), "output.fasta")
Komut Satırı (CLI)
# Sonucu ekrana yaz
fatihmsa input.fasta
# Dosyaya yaz
fatihmsa input.fasta -o output.fasta
# Adım adım ilerlemeyi göster
fatihmsa input.fasta -o output.fasta -v
Yardım:
fatihmsa --help
Algoritma
FatihMSA, MUSCLE algoritmasının üç aşamalı yapısını takip eder:
Aşama 1 — Taslak Hizalama
-
K-mer mesafesi: Her dizi çifti için 3-mer kümeleri çıkarılır, Jaccard uzaklığı hesaplanır:
dist(i, j) = 1 - |kmers(i) ∩ kmers(j)| / |kmers(i) ∪ kmers(j)| -
UPGMA rehber ağaç: Mesafe matrisinden hiyerarşik kümeleme yapılır. Her adımda en yakın iki küme average-linkage formülüyle birleştirilir:
dist(new, k) = (dist(i,k) × size_i + dist(j,k) × size_j) / (size_i + size_j)Çıktı Newick formatında bir ağaç stringidir, örneğin:
((0:0.357,1:0.357):0.500,(2:0.357,3:0.357):0.500); -
Progresif hizalama: UPGMA'nın belirlediği merge sırasına göre diziler sırayla hizalanır:
- Dizi + Dizi → Needleman-Wunsch global hizalama
- Dizi + Profil → Profil-dizi hizalama
- Profil + Profil → Profil-profil hizalama
Aşama 2 — İyileştirme
Taslak hizalamadan elde edilen profiller üzerinden mesafe matrisi yeniden hesaplanır, rehber ağaç güncellenir ve hizalama tekrarlanır. Bu aşama, ilk taslaktaki hataları düzeltmeye yöneliktir.
Not: Bu implementasyonda aşama 2 basitleştirilmiş biçimde uygulanmıştır.
Aşama 3 — Rafine Etme
Profil-profil hizalama kullanılarak hizalanmış sütunlar yeniden değerlendirilir. Her sütun, karakter frekanslarından oluşan bir vektördür:
# Örnek profil sütunu
{'A': 0.5, 'G': 0.25, '-': 0.25}
İki profil sütunu arasındaki skor ağırlıklı ortalama ile hesaplanır:
match_score(col1, col2) = Σ freq1[c1] × freq2[c2] × score(c1, c2)
Puanlama Parametreleri
| Durum | Skor |
|---|---|
| Eşleşme | +1 |
| Uyumsuzluk | −1 |
| Boşluk (gap) | −2 |
Parametreler needleman_wunsch() fonksiyonu üzerinden özelleştirilebilir:
from fatihmsa.align import needleman_wunsch
a1, a2 = needleman_wunsch("ATCG", "ATTG", match=2, mismatch=-1, gap=-3)
Desteklenen Formatlar
Ham String Listesi
sequences = ["ATCGATCG", "GCTAGCTA"]
aligned = run_muscle(sequences)
- Büyük/küçük harf fark etmez (otomatik büyük harfe çevrilir)
- Geçerli karakterler:
A,T,C,G,N
FASTA Formatı
>seq1
ATCGATCG
>seq2
ATCGTTCG
>seq3
GCTAGCTA
Dosyadan veya doğrudan string olarak okunabilir:
from fatihmsa import read_fasta
# Dosyadan
fasta = read_fasta("input.fasta")
# Doğrudan string
fasta = read_fasta(">seq1\nATCGATCG\n>seq2\nATCGTTCG\n")
Proje Yapısı
FatihMSA/
├── fatihmsa/
│ ├── __init__.py # Dışa aktarılan fonksiyonlar
│ ├── align.py # Needleman-Wunsch global hizalama
│ ├── cli.py # Komut satırı arayüzü (argparse)
│ ├── distance.py # K-mer mesafesi + UPGMA rehber ağaç
│ ├── io.py # FASTA okuma/yazma
│ └── main.py # Progresif MSA orkestratörü
├── tests/
│ ├── test_align.py # Hizalama testleri
│ ├── test_distance.py # Mesafe ve UPGMA testleri
│ └── test_main.py # Uçtan uca MSA testleri
├── pyproject.toml
├── setup.py
└── README.md
Testleri çalıştırmak için:
pytest tests/ -v
Geliştirici
| Alan | Bilgi |
|---|---|
| Ad Soyad | Fatih Yilmazer |
| Öğrenci No | 221201001 |
| Ders | Biyoinformatik |
| Paket Adı | FatihMSA-221201001 |
| Versiyon | 1.0.0 |
Metadata
Release files for FatihMSA-221201001 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fatihmsa_221201001-1.1.0.tar.gz | 12.8 kB | Without provenance | Details for fatihmsa_221201001-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fatihmsa_221201001-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for fatihmsa_221201001-1.1.0-py3-none-any.whl |
Total release size: 27.7 kB
Release files / fatihmsa_221201001-1.1.0.tar.gz
| Download URL | fatihmsa_221201001-1.1.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a13125aa780f0ed2ee8fd1e60a3cc00353fb5ec62004c98f0d67376ffd9a1cc4
|
|
BLAKE2b-256 checksum How to use checksums |
84f25ddd219adc9d557a0fcc663dc46947cb8ec0278297f655af8310643da9a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / fatihmsa_221201001-1.1.0-py3-none-any.whl
| Download URL | fatihmsa_221201001-1.1.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0edf1c46d35fc31bc4f0dbe83331a607a25e7d23155c1a3a30b6e4eb5f70c3e4
|
|
BLAKE2b-256 checksum How to use checksums |
594530d672a332818860486f4e78f79263cf9da85febbb2b5bf8050cf86e9504
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for FatihMSA-221201001 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.