Skip to content

Commit 9aa4267

Browse files
Add ncbi_blast_search.py for remote BLAST queries
1 parent a188a88 commit 9aa4267

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

ncbi_blast_search.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cat << 'EOF' > ncbi_blast_search.py
2+
from Bio.Blast import NCBIWWW
3+
from Bio.Blast import NCBIXML
4+
import sys
5+
6+
def execute_remote_blast(sequence_data):
7+
print("🚀 Initializing High-Velocity Remote BLAST Query on NCBI Cloud...")
8+
# Performs a blastn search against the standard nucleotide database (nt)
9+
try:
10+
result_handle = NCBIWWW.qblast("blastn", "nt", sequence_data)
11+
print("✅ Data stream retrieved. Parsing XML alignment matrix...")
12+
13+
blast_records = NCBIXML.parse(result_handle)
14+
for record in blast_records:
15+
for alignment in record.alignments[:3]: # Isolate top 3 target matches
16+
print(f"\n🎯 Target Match Alignment: {alignment.title}")
17+
print(f"🧬 Sequence Length: {alignment.length} Base Pairs")
18+
for hsp in alignment.hsps:
19+
print(f"📈 Expectation Value (E-value): {hsp.expect}")
20+
print(f"📊 Query Alignment Sequence: {hsp.query[:50]}...")
21+
print(f"🔬 Subject Alignment Sequence: {hsp.sbjct[:50]}...")
22+
except Exception as e:
23+
print(f"❌ Structural Connection Failure: {str(e)}")
24+
25+
if __name__ == "__main__":
26+
# Test dataset sequence (Sample DNA Strand segment)
27+
sample_dna = "TGGATTACCAAGTCAATTGGAGAGGCTATTGTTGCTAGC"
28+
execute_remote_blast(sample_dna)
29+
EOF
30+

0 commit comments

Comments
 (0)