>>>#The code reads a GenBank file record-by-record to efficiently handle large sequence files without exhausting memory. It converts each sequence record into FASTA format and writes it to a new output file.
>>>from Bio import SeqIO
>>># Reading sequences from a GenBank file and writing to a FASTA file >>>input_file = "sequence_1.gb" >>>output_file = "converted_sequences.fasta"
>>># Using iterator to read large file without loading all into memory >>>with open(output_file, "w") as out_handle: ... for record in SeqIO.parse(input_file, "genbank"): ... # Each record is a SeqRecord populated with metadata ... print(f"Processing record: {record.id} - {record.description}") ... SeqIO.write(record, out_handle, "fasta") # Convert and write to FASTA
Sekwencje Kluczową koncepcją w Biopythonie jest sekwencja biologiczna, reprezentowana przez klasę Seq. Obiekt Seq w Biopythonie jest pod wieloma względami podobny do ciągu znaków w Pythonie: obsługuje notację wycinka Pythona, można go łączyć z innymi sekwencjami i jest niezmienny. Obiekt ten zawiera zarówno ogólne metody oparte na ciągach znaków, jak i metody specyficzne dla sekwencji biologicznych.