This commit is contained in:
email 2024-11-07 15:56:36 +01:00
parent 42ce34b748
commit 2550271f47
8 changed files with 68 additions and 21 deletions

33
_log Normal file
View File

@ -0,0 +1,33 @@
.
├── alg
│   ├── ampf.py
│   ├── analysis.py
│   ├── blast.py
│   ├── _log
│   ├── out
│   └── startery.py
├── cmd
│   ├── gen.py
│   └── seq2fasta.py
├── data
│   ├── 217314860.fasta
│   ├── 2187833333.fasta
│   ├── 2813891763.fasta
│   ├── 2813891767.fasta
│   ├── 599088294.fasta
│   ├── ITS1.fasta
│   ├── ITS4.fasta
│   └── sequence.fasta
├── doc
│   ├── main.pdf
│   ├── main.tex
│   └── references.bib
├── _l
├── _log
├── log
│   ├── amplification_analysis_log.txt
│   └── __log.txt
└── out
└── blast_results.xml
9 directories, 22 files

View File

@ -1,2 +0,0 @@
Amplified Regions:
No amplification regions found.

View File

@ -1,13 +1,16 @@
from Bio import SeqIO
import os import os
from Bio import SeqIO
# Ścieżki do plików FASTA w katalogu ../data # Ścieżki do katalogów i plików FASTA
data_dir = "../data" data_dir = "../data"
genome_file = os.path.join(data_dir, "genome.fasta") # Nazwa pliku FASTA dla genomu Fusarium solani output_dir = "../out"
os.makedirs(output_dir, exist_ok=True)
# Pliki primerów
primer_ITS1_file = os.path.join(data_dir, "ITS1.fasta") primer_ITS1_file = os.path.join(data_dir, "ITS1.fasta")
primer_ITS4_file = os.path.join(data_dir, "ITS4.fasta") primer_ITS4_file = os.path.join(data_dir, "ITS4.fasta")
# Wczytywanie sekwencji primerów z plików FASTA # Funkcja do wczytywania sekwencji primerów z plików FASTA
def load_primer(primer_file): def load_primer(primer_file):
record = SeqIO.read(primer_file, "fasta") record = SeqIO.read(primer_file, "fasta")
return str(record.seq) return str(record.seq)
@ -39,25 +42,33 @@ def find_amplified_regions(genome_seq, primer_its1, primer_its4):
break # Przerwij po znalezieniu pierwszego pasującego ITS4 po ITS1 break # Przerwij po znalezieniu pierwszego pasującego ITS4 po ITS1
return amplified_regions return amplified_regions
# Wczytywanie primerów # Wczytywanie primerów ITS1 i ITS4
primer_ITS1 = load_primer(primer_ITS1_file) primer_ITS1 = load_primer(primer_ITS1_file)
primer_ITS4 = load_primer(primer_ITS4_file) primer_ITS4 = load_primer(primer_ITS4_file)
# Wczytywanie genomu z pliku FASTA # Lista plików genomów do analizy
with open(genome_file) as f: genome_files = [
genome_record = SeqIO.read(f, "fasta") os.path.join(data_dir, filename)
genome_seq = str(genome_record.seq) for filename in ["217314860.fasta", "2187833333.fasta", "2813891763.fasta", "2813891767.fasta", "599088294.fasta"]
]
# Znajdowanie amplifikowanych regionów # Analiza amplifikacji dla każdego pliku genomu
amplified_regions = find_amplified_regions(genome_seq, primer_ITS1, primer_ITS4) for genome_file in genome_files:
with open(genome_file) as f:
genome_record = SeqIO.read(f, "fasta")
genome_seq = str(genome_record.seq)
# Zapis wyników # Znajdowanie amplifikowanych regionów
output_path = os.path.join(data_dir, "amplified_regions.txt") amplified_regions = find_amplified_regions(genome_seq, primer_ITS1, primer_ITS4)
with open(output_path, "w") as output_file:
output_file.write("Amplified Regions:\n")
for start, end, region in amplified_regions:
output_file.write(f"Start: {start}, End: {end}, Length: {len(region)}\n")
output_file.write(f"Region sequence: {region}\n\n")
print(f"Amplified regions saved to {output_path}") # Zapis wyników dla każdego pliku genomu do ../out
output_filename = f"amplified_regions_{os.path.basename(genome_file)}.txt"
output_path = os.path.join(output_dir, output_filename)
with open(output_path, "w") as output_file:
output_file.write(f"Amplified Regions for {os.path.basename(genome_file)}:\n")
for start, end, region in amplified_regions:
output_file.write(f"Start: {start}, End: {end}, Length: {len(region)}\n")
output_file.write(f"Region sequence: {region}\n\n")
print(f"Amplified regions for {os.path.basename(genome_file)} saved to {output_path}")

View File

@ -0,0 +1 @@
Amplified Regions for 217314860.fasta:

View File

@ -0,0 +1 @@
Amplified Regions for 2187833333.fasta:

View File

@ -0,0 +1 @@
Amplified Regions for 2813891763.fasta:

View File

@ -0,0 +1 @@
Amplified Regions for 2813891767.fasta:

View File

@ -0,0 +1 @@
Amplified Regions for 599088294.fasta: