39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from Bio import Entrez, SeqIO
|
|
import os
|
|
|
|
# Konfiguracja email dla Entrez (wymagane przez NCBI)
|
|
Entrez.email = "baiobelfer@gmail.com"
|
|
|
|
# Identyfikatory GenBank dla wybranych izolatów Fusarium solani
|
|
genbank_ids = [
|
|
"217314860", # Fusarium solani isolate T03
|
|
"2813891763", # Fusarium solani isolate Fso2
|
|
"599088294", # Uncultured Fusarium clone TTRK-10
|
|
"2813891767", # Fusarium solani isolate Fso6
|
|
"2187833333" # Fusarium solani isolate CBG103
|
|
]
|
|
|
|
# Katalog do zapisu plików FASTA
|
|
data_dir = "../data"
|
|
os.makedirs(data_dir, exist_ok=True)
|
|
|
|
# Funkcja do pobierania genomów i zapisywania ich w plikach FASTA
|
|
def download_genome(genbank_id):
|
|
try:
|
|
# Pobieranie rekordu z NCBI w formacie FASTA
|
|
with Entrez.efetch(db="nucleotide", id=genbank_id, rettype="fasta", retmode="text") as handle:
|
|
record = SeqIO.read(handle, "fasta")
|
|
# Zapis rekordu do pliku FASTA w katalogu ../data
|
|
fasta_path = os.path.join(data_dir, f"{genbank_id}.fasta")
|
|
SeqIO.write(record, fasta_path, "fasta")
|
|
print(f"Pobrano i zapisano {genbank_id} do {fasta_path}")
|
|
except Exception as e:
|
|
print(f"Nie udało się pobrać {genbank_id}: {e}")
|
|
|
|
# Pobieranie i zapisywanie genomów dla każdego ID
|
|
for genbank_id in genbank_ids:
|
|
download_genome(genbank_id)
|
|
|
|
print("Pobieranie zakończone.")
|
|
|