-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed defusedxml * refactor: Add temporary file handling to blast_remote function move `parse_xml` * add test_blast * add golden data * Add pytest-mock to dev dependencies --------- Co-authored-by: Rodrigo V Honorato <[email protected]> Co-authored-by: Rodrigo Vargas Honorato <[email protected]>
- Loading branch information
1 parent
570baf1
commit 36b122c
Showing
5 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
>1CRN_1|Chain A|CRAMBIN|Crambe hispanica subsp. abyssinica (3721) | ||
TTCCPSIVARSNFNVCRLPGTPEAICATYTGCIIIPGATCPGDYAN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd"> | ||
<BlastOutput> | ||
<BlastOutput_program>blastp</BlastOutput_program> | ||
<BlastOutput_version>BLASTP 2.15.0+</BlastOutput_version> | ||
<BlastOutput_reference>Stephen F. Altschul, Thomas L. Madden, Alejandro A. Sch&auml;ffer, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a new generation of protein database search programs", Nucleic Acids Res. 25:3389-3402.</BlastOutput_reference> | ||
<BlastOutput_db>swissprot</BlastOutput_db> | ||
<BlastOutput_query-ID>Query_544091</BlastOutput_query-ID> | ||
<BlastOutput_query-def>1CRN_1|Chain A|CRAMBIN|Crambe hispanica subsp. abyssinica (3721)</BlastOutput_query-def> | ||
<BlastOutput_query-len>46</BlastOutput_query-len> | ||
<BlastOutput_param> | ||
<Parameters> | ||
<Parameters_matrix>BLOSUM62</Parameters_matrix> | ||
<Parameters_expect>0.05</Parameters_expect> | ||
<Parameters_gap-open>11</Parameters_gap-open> | ||
<Parameters_gap-extend>1</Parameters_gap-extend> | ||
<Parameters_filter>F</Parameters_filter> | ||
</Parameters> | ||
</BlastOutput_param> | ||
<BlastOutput_iterations> | ||
<Iteration> | ||
<Iteration_iter-num>1</Iteration_iter-num> | ||
<Iteration_query-ID>Query_544091</Iteration_query-ID> | ||
<Iteration_query-def>1CRN_1|Chain A|CRAMBIN|Crambe hispanica subsp. abyssinica (3721)</Iteration_query-def> | ||
<Iteration_query-len>46</Iteration_query-len> | ||
<Iteration_hits> | ||
<Hit> | ||
<Hit_num>1</Hit_num> | ||
<Hit_id>sp|P01542.2|</Hit_id> | ||
<Hit_def>RecName: Full=Crambin [Crambe hispanica subsp. abyssinica]</Hit_def> | ||
<Hit_accession>P01542</Hit_accession> | ||
<Hit_len>46</Hit_len> | ||
<Hit_hsps> | ||
<Hsp> | ||
<Hsp_num>1</Hsp_num> | ||
<Hsp_bit-score>92.4337</Hsp_bit-score> | ||
<Hsp_score>228</Hsp_score> | ||
<Hsp_evalue>2.38732e-26</Hsp_evalue> | ||
<Hsp_query-from>1</Hsp_query-from> | ||
<Hsp_query-to>46</Hsp_query-to> | ||
<Hsp_hit-from>1</Hsp_hit-from> | ||
<Hsp_hit-to>46</Hsp_hit-to> | ||
<Hsp_query-frame>0</Hsp_query-frame> | ||
<Hsp_hit-frame>0</Hsp_hit-frame> | ||
<Hsp_identity>45</Hsp_identity> | ||
<Hsp_positive>46</Hsp_positive> | ||
<Hsp_gaps>0</Hsp_gaps> | ||
<Hsp_align-len>46</Hsp_align-len> | ||
<Hsp_qseq>TTCCPSIVARSNFNVCRLPGTPEAICATYTGCIIIPGATCPGDYAN</Hsp_qseq> | ||
<Hsp_hseq>TTCCPSIVARSNFNVCRLPGTPEALCATYTGCIIIPGATCPGDYAN</Hsp_hseq> | ||
<Hsp_midline>TTCCPSIVARSNFNVCRLPGTPEA+CATYTGCIIIPGATCPGDYAN</Hsp_midline> | ||
</Hsp> | ||
</Hit_hsps> | ||
</Hit> | ||
<Hit> | ||
<Hit_num>2</Hit_num> | ||
<Hit_id>sp|P01541.1|</Hit_id> | ||
<Hit_def>RecName: Full=Denclatoxin-B [Dendrophthora clavata]</Hit_def> | ||
<Hit_accession>P01541</Hit_accession> | ||
<Hit_len>46</Hit_len> | ||
<Hit_hsps> | ||
<Hsp> | ||
<Hsp_num>1</Hsp_num> | ||
<Hsp_bit-score>53.9138</Hsp_bit-score> | ||
<Hsp_score>128</Hsp_score> | ||
<Hsp_evalue>3.34186e-11</Hsp_evalue> | ||
<Hsp_query-from>2</Hsp_query-from> | ||
<Hsp_query-to>46</Hsp_query-to> | ||
<Hsp_hit-from>2</Hsp_hit-from> | ||
<Hsp_hit-to>46</Hsp_hit-to> | ||
<Hsp_query-frame>0</Hsp_query-frame> | ||
<Hsp_hit-frame>0</Hsp_hit-frame> | ||
<Hsp_identity>23</Hsp_identity> | ||
<Hsp_positive>31</Hsp_positive> | ||
<Hsp_gaps>0</Hsp_gaps> | ||
<Hsp_align-len>45</Hsp_align-len> | ||
<Hsp_qseq>TCCPSIVARSNFNVCRLPGTPEAICATYTGCIIIPGATCPGDYAN</Hsp_qseq> | ||
<Hsp_hseq>SCCPTTAARNQYNICRLPGTPRPVCAALSGCKIISGTGCPPGYRH</Hsp_hseq> | ||
<Hsp_midline>+CCP+ AR+ +N+CRLPGTP +CA +GC II G CP Y +</Hsp_midline> | ||
</Hsp> | ||
</Hit_hsps> | ||
</Hit> | ||
</Iteration_hits> | ||
<Iteration_stat> | ||
<Statistics> | ||
<Statistics_db-num>483204</Statistics_db-num> | ||
<Statistics_db-len>183688421</Statistics_db-len> | ||
<Statistics_hsp-len>0</Statistics_hsp-len> | ||
<Statistics_eff-space>0</Statistics_eff-space> | ||
<Statistics_kappa>0.041</Statistics_kappa> | ||
<Statistics_lambda>0.267</Statistics_lambda> | ||
<Statistics_entropy>0.14</Statistics_entropy> | ||
</Statistics> | ||
</Iteration_stat> | ||
</Iteration> | ||
</BlastOutput_iterations> | ||
</BlastOutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from io import StringIO | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from arctic3d.modules.blast import blast_remote, parse_xml | ||
|
||
from . import golden_data | ||
|
||
|
||
@pytest.fixture | ||
def fasta_file(): | ||
return Path(golden_data, "1crn.fasta") | ||
|
||
|
||
@pytest.fixture | ||
def xml_file(): | ||
return Path(golden_data, "blast.xml") | ||
|
||
|
||
def test_blast_remote(mocker, fasta_file, xml_file): | ||
|
||
# Mock the remote blast call by passing the xml file as stringIo as return value | ||
with open(xml_file, "r") as f: | ||
xml = f.read() | ||
xml_string_io = StringIO(xml) | ||
|
||
mock_qbplast = mocker.patch("Bio.Blast.NCBIWWW.qblast") | ||
mock_qbplast.return_value = xml_string_io | ||
|
||
accession_id = blast_remote(fasta_file) | ||
|
||
assert accession_id == "P01541" | ||
|
||
|
||
@pytest.mark.skip(reason="Not implemented") | ||
def test_blast_local(): | ||
pass | ||
|
||
|
||
def test_parse_xml(xml_file): | ||
accession_id = parse_xml(xml_file) | ||
assert accession_id == "P01541" |