o
    Rŀg                     @   s|   d dl Z d dlZd dlmZ d dlmZ d dlmZ dd Ze de G dd	 d	eZ	G d
d de	Z
G dd de	ZdS )    N)ABC)abstractmethod)UndefinedSequenceErrorc                 C   s>   | j }| j}| j|| }t|}dtjj|  d}||fS )Nz&amp;;)startendobjectordhtmlentitiescodepoint2name)errorr   r   	character	codepointentity r   F/var/www/html/myenv/lib/python3.10/site-packages/Bio/Blast/_writers.py_html_entity_replace	   s   r   htmlentityreplacec                   @   s  e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zedd Zedd Zedd Zedd Zedd Zed d! Zed"d# Zed$d% Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Zd4d5 Zed6d7 Zed8d9 Z ed:d; Z!ed<d= Z"ed>d? Z#ed@dA Z$edBdC Z%edDdE Z&edFdG Z'edHdI Z(edJdK Z)edLdM Z*edNdO Z+edPdQ Z,dRdS Z-dTdU Z.dVdW Z/dXdY Z0edZd[ Z1ed\d] Z2ed^d_ Z3ed`da Z4edbdc Z5eddde Z6edfdg Z7edhdi Z8edjdk Z9edldm Z:edndo Z;edpdq Z<edrds Z=dtdu Z>dvdw Z?edxdy Z@edzd{ ZAed|d} ZBed~d ZCedd ZDedd ZEedd ZFedd ZGedd ZHedd ZIedd ZJedd ZKedd ZLedd ZMedd ZNedd ZOedd ZPedd ZQedd ZRedd ZSedd ZTedd ZUedd ZVedd ZWedd ZXdS )BaseXMLWriterz XML Writer, abstract base class.c                 C   s
   || _ dS )zInit the stuff.N)stream)selfr   r   r   r   __init__   s   
zBaseXMLWriter.__init__c           	      C   sH  | j }|j}|| _|   |   |   | |  | |j	  t
|jdd}| | | |j  z|j}W n	 tyI   Y n.w | |j  | |j  | t| zt|j}W n	 tyq   Y nw | | | |j | |}z|j}W n	 ty   Y nw |    | !| | "  | #  |S )zWrite the records.ASCIIr   )$r   program_program_write_xml_declaration_write_definition_start_blastoutput_write_programencode_write_versionversionr
   escape	reference_write_reference	_write_dbdbqueryAttributeError_write_query_idid_write_query_defdescription_write_query_lenlenbytesseqr   _write_query_seq_write_paramsparam_write_recordsmbstat_start_mbstat_write_statistics_end_mbstat_end_blastoutput)	r   recordsr   r   r$   r(   	query_seqcountr6   r   r   r   write   sJ   





zBaseXMLWriter.writec                 C      | j d d S )Ns   <?xml version="1.0"?>
r   r>   r   r   r   r   r   D      z$BaseXMLWriter._write_xml_declarationc                 C   s  |    | jd |d}|d ur| |  | |d  |d}|d ur/| | |d}|d ur=| | |d}|d urK| 	| |d}|d urY| 
| |d}|d urg| | |d	}|d urw| |  |d
}|d ur| |  |d}|d ur| |  |d}|d ur| | |d}|d ur| | |d}|d ur| | |d}|d ur| |  | jd |   d S )Ns       <Parameters>
matrixexpectincludezsc-matchzsc-mismatchzgap-openz
gap-extendfilterpatternzentrez-querycbszquery-gencodez
db-gencodezbl2seq-modes       </Parameters>
)_start_paramr   r>   get_write_parameters_matrixr    _write_parameters_expect_write_parameters_include_write_parameters_sc_match_write_parameters_sc_mismatch_write_parameters_gap_open_write_parameters_gap_extend_write_parameters_filter_write_parameters_pattern_write_parameters_entrez_query_write_parameters_cbs_write_parameters_query_gencode_write_parameters_db_gencode_write_parameters_bl2seq_mode
_end_param)r   r4   valuer   r   r   r3   G   sX   




















zBaseXMLWriter._write_paramsc                 C   s4   d}|    |D ]}| | |d7 }q|   |S )Nr      )_start_iterations_write_record_end_iterations)r   r;   r=   recordr   r   r   r5   u   s   

zBaseXMLWriter._write_recordsc           	      C   s
  | j }|   z|j}W n	 ty   Y nw | | |j}|d u r%d }n+t|j}| |j	
  | |j
  | | |jD ]}|jdkrO| |j qB|   |D ]}| || qV|   z|j}W n	 tyq   Y nw |   | | |   |   d S )Nmasking)r   _start_iterationnumr)   _write_iteration_numr(   r/   r1   _write_iteration_query_idr+   r    _write_iteration_query_defr-   _write_iteration_query_lenfeaturestype_write_iteration_query_maskinglocation_start_iteration_hits
_write_hit_end_iteration_hitsstat_start_iteration_statr8   _end_iteration_stat_end_iteration)	r   r_   r   rb   r(   query_lengthfeaturehitrn   r   r   r   r]   ~   s@   







zBaseXMLWriter._write_recordc                 C   sV  | j }| j}|j}t|j}|   | |j z|j}W n! t	y>   | 
|j  | |j  | |j  Y nNw |   |D ]B}|   | 
|j  | |j  | |j  |jd}|d urr| | |jd}	|	d ur| |	  |   qE|   | | |   |D ]	}
| |
|| q|   |   d S )Ntaxidsciname)r   r   targetr/   r1   _start_iteration_hit_write_hit_numrb   targetsr)   _write_hit_idr+   r    _write_hit_defr-   _write_hit_accessionname_start_hit_targets_start_hitdescrannotationsrJ   _write_hit_taxid_write_hit_sciname_end_hitdescr_end_hit_targets_write_hit_len_start_hit_hsps
_write_hsp_end_hit_hsps_end_iteration_hit)r   rt   rr   r   r   rw   target_lengthrz   ru   rv   hspr   r   r   rl      sB   




zBaseXMLWriter._write_hitc           $      C   sb  | j }| j}|j}|j}|j}|d d df \}	}
|d d df \}}|dv r9|	|kr2d}|	d7 }	nfd}|d7 }n_|dv rD|	d7 }	d}nT|dv r|jd }|jd }|drg|d	s^J |d
d }d}nd}|	d\}}|	d\}	}t
|	}	t
|}|	d }|}|dkr|d d }n|| d d }|dv r|
|kr|
d7 }
d}nh|d7 }d}na|dv r|
d7 }
d}nV|dv r|jd }|jd }|dr|d	sJ |d
d }d}nd}|	d\}}|	d\}
}t
|
}
t
|}|
d }|}|dkr|d d }n|| d d }|d }|d }t|}|j}|d }|d }|d } |d}!|d}"|d }#|   | |j | t|  | |j | t|  | |
 | | | |	 | | | | | | | |  |!d ur| |! |"d ur| |" |  | | !|  | "|  | #|#  | $  d S )Nr   )blastn	megablastr[   )blastpblastxrpsblast)tblastntblastxcoded_byzcomplement()   :z..   )r   r   r   )r   r   z	bit scoreevalueidentitypositivegapsmidline)%r   r   r(   rw   coordinatesrg   
qualifiers
startswithendswithsplitintr/   r   rJ   
_start_hsp_write_hsp_numrb   _write_hsp_bit_scorestrr    _write_hsp_scorescore_write_hsp_evalue_write_hsp_query_from_write_hsp_query_to_write_hsp_hit_from_write_hsp_hit_to_write_hsp_query_frame_write_hsp_hit_frame_write_hsp_identity_write_hsp_positive_write_hsp_gaps_write_hsp_align_len_write_hsp_qseq_write_hsp_hseq_write_hsp_midline_end_hsp)$r   r   rr   r   r   r   r(   rw   r   hit_from
query_fromhit_toquery_to	hit_framers   r   strandhit_idhit_from_to	hit_starthit_endquery_framequery_idquery_from_toquery_start	query_endhseqqseq	align_lenr   	bit_scorer   r   r   r   r   r   r   r   r      s   























zBaseXMLWriter._write_hspc                 C   s   | j d | |d  | |d  | |d  | t|d   | |d  | 	|d  | 
|d  | j d	 d S )
Ns       <Statistics>
zdb-numzdb-lenzhsp-lenz	eff-spacekappalambdaentropys       </Statistics>
)r   r>   _write_statistics_db_num_write_statistics_db_len_write_statistics_hsp_len_write_statistics_eff_spacer   r    _write_statistics_kappa_write_statistics_lambda_write_statistics_entropy)r   rn   r   r   r   r8   %  s   zBaseXMLWriter._write_statisticsc                 C      d S Nr   rA   r   r   r   r   0     zBaseXMLWriter._write_definitionc                 C   r   r   r   rA   r   r   r   r   3     z BaseXMLWriter._start_blastoutputc                 C   r   r   r   rA   r   r   r   r:   7  r   zBaseXMLWriter._end_blastoutputc                 C   r   r   r   r   r   r   r   r   r   ;  r   zBaseXMLWriter._write_programc                 C   r   r   r   r   r"   r   r   r   r!   ?  r   zBaseXMLWriter._write_versionc                 C   r   r   r   r   r$   r   r   r   r%   C  r   zBaseXMLWriter._write_referencec                 C   r   r   r   r   r'   r   r   r   r&   G  r   zBaseXMLWriter._write_dbc                 C   r   r   r   rA   r   r   r   rI   K  r   zBaseXMLWriter._start_paramc                 C   r   r   r   rA   r   r   r   rY   O  r   zBaseXMLWriter._end_paramc                 C   r   r   r   rA   r   r   r   r\   S  r   zBaseXMLWriter._start_iterationsc                 C   r   r   r   rA   r   r   r   r^   W  r   zBaseXMLWriter._end_iterationsc                 C   r   r   r   rA   r   r   r   ra   [  r   zBaseXMLWriter._start_iterationc                 C   r   r   r   rA   r   r   r   rq   _  r   zBaseXMLWriter._end_iterationc                 C   r   r   r   r   r   r   r   r   rd   c  r   z'BaseXMLWriter._write_iteration_query_idc                 C   r   r   r   r   	query_defr   r   r   re   g  r   z(BaseXMLWriter._write_iteration_query_defc                 C   r   r   r   r   	query_lenr   r   r   rf   k  r   z(BaseXMLWriter._write_iteration_query_lenc                 C   r   r   r   r   rj   r   r   r   ri   o  r   z,BaseXMLWriter._write_iteration_query_maskingc                 C   r   r   r   rA   r   r   r   rk   r  r   z#BaseXMLWriter._start_iteration_hitsc                 C   r   r   r   rA   r   r   r   rm   v  r   z!BaseXMLWriter._end_iteration_hitsc                 C   r   r   r   rA   r   r   r   ro   z  r   z#BaseXMLWriter._start_iteration_statc                 C   r   r   r   rA   r   r   r   rp   ~  r   z!BaseXMLWriter._end_iteration_statc                 C   r   r   r   r   rZ   r   r   r   rK     r   z&BaseXMLWriter._write_parameters_matrixc                 C   r   r   r   r   r   r   r   rL     r   z&BaseXMLWriter._write_parameters_expectc                 C   r   r   r   r   r   r   r   rM     r   z'BaseXMLWriter._write_parameters_includec                 C   r   r   r   r   r   r   r   rN     r   z(BaseXMLWriter._write_parameters_sc_matchc                 C   r   r   r   r   r   r   r   rO     r   z+BaseXMLWriter._write_parameters_sc_mismatchc                 C   r   r   r   r   r   r   r   rP     r   z(BaseXMLWriter._write_parameters_gap_openc                 C   r   r   r   r   r   r   r   rQ     r   z*BaseXMLWriter._write_parameters_gap_extendc                 C   r   r   r   r   r   r   r   rR     r   z&BaseXMLWriter._write_parameters_filterc                 C   r   r   r   r   r   r   r   rS     r   z'BaseXMLWriter._write_parameters_patternc                 C   r   r   r   r   r   r   r   rT     r   z,BaseXMLWriter._write_parameters_entrez_queryc                 C   r   r   r   r   r   r   r   rU     r   z#BaseXMLWriter._write_parameters_cbsc                 C   r   r   r   r   r   r   r   rV     r   z-BaseXMLWriter._write_parameters_query_gencodec                 C   r   r   r   r   r   r   r   rW     r   z*BaseXMLWriter._write_parameters_db_gencodec                 C   r   r   r   r   r   r   r   rX     r   z+BaseXMLWriter._write_parameters_bl2seq_modec                 C   r   r   r   r   db_numr   r   r   r     r   z&BaseXMLWriter._write_statistics_db_numc                 C   r   r   r   r   db_lenr   r   r   r     r   z&BaseXMLWriter._write_statistics_db_lenc                 C   r   r   r   r   hsp_lenr   r   r   r     r   z'BaseXMLWriter._write_statistics_hsp_lenc                 C   r   r   r   r   r   r   r   r     r   z)BaseXMLWriter._write_statistics_eff_spacec                 C   r   r   r   r   r   r   r   r     r   z%BaseXMLWriter._write_statistics_kappac                 C   r   r   r   r   r   r   r   r     r   z&BaseXMLWriter._write_statistics_lambdac                 C   r   r   r   r   r   r   r   r     r   z'BaseXMLWriter._write_statistics_entropyc                 C   r   r   r   rA   r   r   r   rx     r   z"BaseXMLWriter._start_iteration_hitc                 C   r   r   r   rA   r   r   r   r     r   z BaseXMLWriter._end_iteration_hitc                 C   r   r   r   r   rb   r   r   r   ry     r   zBaseXMLWriter._write_hit_numc                 C   r   r   r   r   r   r   r   r   r{     r   zBaseXMLWriter._write_hit_idc                 C   r   r   r   r   hit_defr   r   r   r|     r   zBaseXMLWriter._write_hit_defc                 C   r   r   r   r   hit_accessionr   r   r   r}     r   z"BaseXMLWriter._write_hit_accessionc                 C   r   r   r   r   ru   r   r   r   r     r   zBaseXMLWriter._write_hit_taxidc                 C   r   r   r   r   rv   r   r   r   r     r   z BaseXMLWriter._write_hit_scinamec                 C   r   r   r   r   
hit_lengthr   r   r   r     r   zBaseXMLWriter._write_hit_lenc                 C   r   r   r   rA   r   r   r   r     r   zBaseXMLWriter._start_hit_hspsc                 C   r   r   r   rA   r   r   r   r     r   zBaseXMLWriter._end_hit_hspsc                 C   r   r   r   rA   r   r   r   r     r   zBaseXMLWriter._start_hspc                 C   r   r   r   rA   r   r   r   r      r   zBaseXMLWriter._end_hspc                 C   r   r   r   r   r   r   r   r     r   zBaseXMLWriter._write_hsp_numc                 C   r   r   r   r   r   r   r   r   r     r   z"BaseXMLWriter._write_hsp_bit_scorec                 C   r   r   r   r   r   r   r   r   r     r   zBaseXMLWriter._write_hsp_scorec                 C   r   r   r   r   r   r   r   r   r     r   zBaseXMLWriter._write_hsp_evaluec                 C   r   r   r   r   r   r   r   r   r     r   z#BaseXMLWriter._write_hsp_query_fromc                 C   r   r   r   r   r   r   r   r   r     r   z!BaseXMLWriter._write_hsp_query_toc                 C   r   r   r   r   r   r   r   r   r     r   z!BaseXMLWriter._write_hsp_hit_fromc                 C   r   r   r   r   r   r   r   r   r      r   zBaseXMLWriter._write_hsp_hit_toc                 C   r   r   r   r   r   r   r   _write_hsp_pattern_from$  r   z%BaseXMLWriter._write_hsp_pattern_fromc                 C   r   r   r   r   r   r   r   _write_hsp_pattern_to(  r   z#BaseXMLWriter._write_hsp_pattern_toc                 C   r   r   r   r   r   r   r   r   r   ,  r   z$BaseXMLWriter._write_hsp_query_framec                 C   r   r   r   r   r   r   r   r   r   0  r   z"BaseXMLWriter._write_hsp_hit_framec                 C   r   r   r   r   r   r   r   r   r   4  r   z!BaseXMLWriter._write_hsp_identityc                 C   r   r   r   r   r   r   r   r   r   8  r   z!BaseXMLWriter._write_hsp_positivec                 C   r   r   r   r   r   r   r   r   r   <  r   zBaseXMLWriter._write_hsp_gapsc                 C   r   r   r   r   r   r   r   r   r   @  r   z"BaseXMLWriter._write_hsp_align_lenc                 C   r   r   r   r   densityr   r   r   _write_hsp_densityD  r   z BaseXMLWriter._write_hsp_densityc                 C   r   r   r   r   r   r   r   r   r   H  r   zBaseXMLWriter._write_hsp_qseqc                 C   r   r   r   r   r   r   r   r   r   L  r   zBaseXMLWriter._write_hsp_hseqc                 C   r   r   r   r   r   r   r   r   r   P  r   z BaseXMLWriter._write_hsp_midlineN)Y__name__
__module____qualname____doc__r   r>   r   r3   r5   r]   rl   r   r8   r   r   r   r:   r   r!   r%   r&   rI   rY   r\   r^   ra   rq   rd   re   rf   ri   rk   rm   ro   rp   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   r   r   r   r   r   r   r   rx   r   ry   r{   r|   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r      s2   (.	"#b

































































r   c                   @   sh  e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Z d<d= Z!d>d? Z"d@dA Z#dBdC Z$dDdE Z%dFdG Z&dHdI Z'dJdK Z(dLdM Z)dNdO Z*dPdQ Z+dRdS Z,dTdU Z-dVdW Z.dXdY Z/dZd[ Z0d\d] Z1d^d_ Z2d`da Z3dbdc Z4ddde Z5dfdg Z6dhdi Z7djdk Z8dldm Z9dndo Z:dpdq Z;drds Z<dtdu Z=dvdw Z>dxdy Z?dzd{ Z@d|d} ZAd~d ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdS )	XMLWriterzXML Writer.c                 C   r?   )Nst   <!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">
r@   rA   r   r   r   r   X     zXMLWriter._write_definitionc                 C   r?   )Ns   <BlastOutput>
r@   rA   r   r   r   r   _  rB   zXMLWriter._start_blastoutputc                 C   r?   )Ns   </BlastOutput>
r@   rA   r   r   r   r:   b  rB   zXMLWriter._end_blastoutputc                 C      | j d|  d S )Ns.   <BlastOutput_program>%b</BlastOutput_program>
r@   r   r   r   r   r   e     zXMLWriter._write_programc                 C   r  )Ns.   <BlastOutput_version>%b</BlastOutput_version>
r@   r   r   r   r   r!   h  r  zXMLWriter._write_versionc                 C   r  )Ns2   <BlastOutput_reference>%b</BlastOutput_reference>
r@   r   r   r   r   r%   k     zXMLWriter._write_referencec                 C   r  )Ns$   <BlastOutput_db>%b</BlastOutput_db>
r@   r   r   r   r   r&   p  r  zXMLWriter._write_dbc                 C   r  )Ns0   <BlastOutput_query-ID>%b</BlastOutput_query-ID>
r@   r   r   r   r   r*   s  r  zXMLWriter._write_query_idc                 C   r  )Ns2   <BlastOutput_query-def>%b</BlastOutput_query-def>
r@   r   r   r   r   r,   x  r  zXMLWriter._write_query_defc                 C   r  )Ns2   <BlastOutput_query-len>%d</BlastOutput_query-len>
r@   r   r   r   r   r.   }  r  zXMLWriter._write_query_lenc                 C   r  )Ns2   <BlastOutput_query-seq>%b</BlastOutput_query-seq>
r@   )r   r<   r   r   r   r2     r  zXMLWriter._write_query_seqc                 C   r?   )Ns     <BlastOutput_param>
r@   rA   r   r   r   rI     rB   zXMLWriter._start_paramc                 C   r?   )Ns     </BlastOutput_param>
r@   rA   r   r   r   rY     rB   zXMLWriter._end_paramc                 C   r?   )Ns   <BlastOutput_iterations>
r@   rA   r   r   r   r\     rB   zXMLWriter._start_iterationsc                 C   r?   )Ns   </BlastOutput_iterations>
r@   rA   r   r   r   r^     rB   zXMLWriter._end_iterationsc                 C   r?   )Ns     <BlastOutput_mbstat>
r@   rA   r   r   r   r7     rB   zXMLWriter._start_mbstatc                 C   r?   )Ns     </BlastOutput_mbstat>
r@   rA   r   r   r   r9     rB   zXMLWriter._end_mbstatc                 C   r?   )Ns   <Iteration>
r@   rA   r   r   r   ra     rB   zXMLWriter._start_iterationc                 C   r?   )Ns   </Iteration>
r@   rA   r   r   r   rq     rB   zXMLWriter._end_iterationc                 C   r  )Ns.     <Iteration_iter-num>%d</Iteration_iter-num>
r@   r   r   r   r   rc     r  zXMLWriter._write_iteration_numc                 C   r  )Ns,   <Iteration_query-ID>%b</Iteration_query-ID>
r@   r   r   r   r   rd     r  z#XMLWriter._write_iteration_query_idc                 C   r  )Ns.   <Iteration_query-def>%b</Iteration_query-def>
r@   r   r   r   r   re     r  z$XMLWriter._write_iteration_query_defc                 C   r  )Ns.   <Iteration_query-len>%d</Iteration_query-len>
r@   r   r   r   r   rf     r  z$XMLWriter._write_iteration_query_lenc                 C   r?   )Ns   <Iteration_hits>
r@   rA   r   r   r   rk     rB   zXMLWriter._start_iteration_hitsc                 C   r?   )Ns   </Iteration_hits>
r@   rA   r   r   r   rm     rB   zXMLWriter._end_iteration_hitsc                 C   r?   )Ns     <Iteration_stat>
r@   rA   r   r   r   ro     rB   zXMLWriter._start_iteration_statc                 C   r?   )Ns     </Iteration_stat>
r@   rA   r   r   r   rp     rB   zXMLWriter._end_iteration_statc                 C   r  )Ns0         <Parameters_matrix>%b</Parameters_matrix>
r@   r   r   r   r   rK     r  z"XMLWriter._write_parameters_matrixc                 C   r  )Ns0         <Parameters_expect>%g</Parameters_expect>
r@   r   r   r   r   rL     r  z"XMLWriter._write_parameters_expectc                 C   r  )Ns2         <Parameters_include>%g</Parameters_include>
r@   r   r   r   r   rM     r  z#XMLWriter._write_parameters_includec                 C   r  )Ns5          <Parameters_sc-match>%d</Parameters_sc-match>
r@   r   r   r   r   rN     r  z$XMLWriter._write_parameters_sc_matchc                 C   r  )Ns;          <Parameters_sc-mismatch>%d</Parameters_sc-mismatch>
r@   r   r   r   r   rO     r  z'XMLWriter._write_parameters_sc_mismatchc                 C   r  )Ns5          <Parameters_gap-open>%d</Parameters_gap-open>
r@   r   r   r   r   rP     r  z$XMLWriter._write_parameters_gap_openc                 C   r  )Ns9          <Parameters_gap-extend>%d</Parameters_gap-extend>
r@   r   r   r   r   rQ     r  z&XMLWriter._write_parameters_gap_extendc                 C   r  )Ns1          <Parameters_filter>%b</Parameters_filter>
r@   r   r   r   r   rR     r  z"XMLWriter._write_parameters_filterc                 C   r  )Ns3          <Parameters_pattern>%b</Parameters_pattern>
r@   r   r   r   r   rS     r  z#XMLWriter._write_parameters_patternc                 C   r  )Ns=          <Parameters_entrez-query>%b</Parameters_entrez-query>
r@   r   r   r   r   rT     r  z(XMLWriter._write_parameters_entrez_queryc                 C   r  )Ns0         <Statistics_db-num>%d</Statistics_db-num>
r@   r   r   r   r   r     r  z"XMLWriter._write_statistics_db_numc                 C   r  )Ns0         <Statistics_db-len>%d</Statistics_db-len>
r@   r   r   r   r   r     r  z"XMLWriter._write_statistics_db_lenc                 C   r  )Ns2         <Statistics_hsp-len>%d</Statistics_hsp-len>
r@   r   r   r   r   r     r  z#XMLWriter._write_statistics_hsp_lenc                 C   r  )Ns6         <Statistics_eff-space>%s</Statistics_eff-space>
r@   r   r   r   r   r     r  z%XMLWriter._write_statistics_eff_spacec                 C   r  )Ns.         <Statistics_kappa>%r</Statistics_kappa>
r@   r   r   r   r   r     r  z!XMLWriter._write_statistics_kappac                 C   r  )Ns0         <Statistics_lambda>%r</Statistics_lambda>
r@   r   r   r   r   r     r  z"XMLWriter._write_statistics_lambdac                 C   r  )Ns2         <Statistics_entropy>%r</Statistics_entropy>
r@   r   r   r   r   r     r  z#XMLWriter._write_statistics_entropyc                 C   r?   )Ns   <Hit>
r@   rA   r   r   r   rx     rB   zXMLWriter._start_iteration_hitc                 C   r?   )Ns   </Hit>
r@   rA   r   r   r   r     rB   zXMLWriter._end_iteration_hitc                 C   r  )Ns     <Hit_num>%d</Hit_num>
r@   r   r   r   r   ry     r  zXMLWriter._write_hit_numc                 C   r  )Ns     <Hit_id>%b</Hit_id>
r@   r   r   r   r   r{     r  zXMLWriter._write_hit_idc                 C   r  )Ns     <Hit_def>%b</Hit_def>
r@   r   r   r   r   r|     r  zXMLWriter._write_hit_defc                 C   r  )Ns$     <Hit_accession>%b</Hit_accession>
r@   r   r   r   r   r}     r  zXMLWriter._write_hit_accessionc                 C   r  )Ns     <Hit_len>%d</Hit_len>
r@   r   r   r   r   r     r  zXMLWriter._write_hit_lenc                 C   r?   )Ns     <Hit_hsps>
r@   rA   r   r   r   r     rB   zXMLWriter._start_hit_hspsc                 C   r?   )Ns     </Hit_hsps>
r@   rA   r   r   r   r     rB   zXMLWriter._end_hit_hspsc                 C   r?   )Ns
       <Hsp>
r@   rA   r   r   r   r     rB   zXMLWriter._start_hspc                 C   r?   )Ns       </Hsp>
r@   rA   r   r   r   r      rB   zXMLWriter._end_hspc                 C   r  )Ns       <Hsp_num>%d</Hsp_num>
r@   r   r   r   r   r   #  r  zXMLWriter._write_hsp_numc                 C   r  )Ns&       <Hsp_bit-score>%b</Hsp_bit-score>
r@   r   r   r   r   r   &  r  zXMLWriter._write_hsp_bit_scorec                 C   r  )Ns       <Hsp_score>%d</Hsp_score>
r@   r   r   r   r   r   )  r  zXMLWriter._write_hsp_scorec                 C   r  )Ns        <Hsp_evalue>%b</Hsp_evalue>
r@   r   r   r   r   r   ,  r  zXMLWriter._write_hsp_evaluec                 C   r  )Ns)        <Hsp_query-from>%d</Hsp_query-from>
r@   r   r   r   r   r   /  r  zXMLWriter._write_hsp_query_fromc                 C   r  )Ns%        <Hsp_query-to>%d</Hsp_query-to>
r@   r   r   r   r   r   2  r  zXMLWriter._write_hsp_query_toc                 C   r  )Ns%        <Hsp_hit-from>%d</Hsp_hit-from>
r@   r   r   r   r   r   5  r  zXMLWriter._write_hsp_hit_fromc                 C   r  )Ns!        <Hsp_hit-to>%d</Hsp_hit-to>
r@   r   r   r   r   r   8  r  zXMLWriter._write_hsp_hit_toc                 C   r  )Ns-        <Hsp_pattern-from>%d</Hsp_pattern-from>
r@   r   pattern_fromr   r   r   r   ;  r  z!XMLWriter._write_hsp_pattern_fromc                 C   r  )Ns)        <Hsp_pattern-to>%d</Hsp_pattern-to>
r@   r   
pattern_tor   r   r   r   @  r  zXMLWriter._write_hsp_pattern_toc                 C   r  )Ns+        <Hsp_query-frame>%d</Hsp_query-frame>
r@   r   r   r   r   r   C  r  z XMLWriter._write_hsp_query_framec                 C   r  )Ns'        <Hsp_hit-frame>%d</Hsp_hit-frame>
r@   r  r   r   r   r   F  r  zXMLWriter._write_hsp_hit_framec                 C   r  )Ns%        <Hsp_identity>%d</Hsp_identity>
r@   r  r   r   r   r   I  r  zXMLWriter._write_hsp_identityc                 C   r  )Ns%        <Hsp_positive>%d</Hsp_positive>
r@   r  r   r   r   r   L  r  zXMLWriter._write_hsp_positivec                 C   r  )Ns        <Hsp_gaps>%d</Hsp_gaps>
r@   r  r   r   r   r   O  r  zXMLWriter._write_hsp_gapsc                 C   r  )Ns'        <Hsp_align-len>%d</Hsp_align-len>
r@   r  r   r   r   r   R  r  zXMLWriter._write_hsp_align_lenc                 C   r  )Ns#        <Hsp_density>%d</Hsp_density>
r@   r  r   r   r   r  U  r  zXMLWriter._write_hsp_densityc                 C   r  )Ns         <Hsp_qseq>%b</Hsp_qseq>
r@   r	  r   r   r   r   X  r  zXMLWriter._write_hsp_qseqc                 C   r  )Ns         <Hsp_hseq>%b</Hsp_hseq>
r@   r
  r   r   r   r   [  r  zXMLWriter._write_hsp_hseqc                 C   r  )Ns$         <Hsp_midline>%b</Hsp_midline>
r@   r  r   r   r   r   ^  r  zXMLWriter._write_hsp_midlineN)Or  r  r  r  r   r   r:   r   r!   r%   r&   r*   r,   r.   r2   rI   rY   r\   r^   r7   r9   ra   rq   rc   rd   re   rf   rk   rm   ro   rp   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   r   r   r   r   r   r   r   rx   r   ry   r{   r|   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r  U  s    r  c                   @   s  e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Z d<d= Z!d>d? Z"d@dA Z#dBdC Z$dDdE Z%dFdG Z&dHdI Z'dJdK Z(dLdM Z)dNdO Z*dPdQ Z+dRdS Z,dTdU Z-dVdW Z.dXdY Z/dZd[ Z0d\d] Z1d^d_ Z2d`da Z3dbdc Z4ddde Z5dfdg Z6dhdi Z7djdk Z8dldm Z9dndo Z:dpdq Z;drds Z<dtdu Z=dvdw Z>dxdy Z?dzd{ Z@d|d} ZAd~d ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdS )
XML2WriterzXML2 Writer.c                 C   r?   )Ns  <BlastXML2
    xmlns="http://www.ncbi.nlm.nih.gov"
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    xs:schemaLocation="http://www.ncbi.nlm.nih.gov http://www.ncbi.nlm.nih.gov/data_specs/schema_alt/NCBI_BlastOutput2.xsd"
>
<BlastOutput2>
  <report>
    <Report>
r@   rA   r   r   r   r   e  r  zXML2Writer._start_blastoutputc                 C   r?   )Ns7       </Report>
  </report>
</BlastOutput2>
</BlastXML2>
r@   rA   r   r   r   r:   s  r  zXML2Writer._end_blastoutputc                 C   r  )Ns         <program>%b</program>
r@   r   r   r   r   r   }  r  zXML2Writer._write_programc                 C   r  )Ns         <version>%b</version>
r@   r   r   r   r   r!     r  zXML2Writer._write_versionc                 C   r  )Ns          <reference>%b</reference>
r@   r   r   r   r   r%     r  zXML2Writer._write_referencec                 C   r  )Nsf         <search-target>
        <Target>
          <db>%b</db>
        </Target>
      </search-target>
r@   r   r   r   r   r&     s
   zXML2Writer._write_dbc                 C   r?   )Ns$         <params>
        <Parameters>
r@   rA   r   r   r   rI     r  zXML2Writer._start_paramc                 C   r?   )Ns&           </Parameters>
      </params>
r@   rA   r   r   r   rY     r  zXML2Writer._end_paramc                 C   r?   )Ns"         <results>
        <Results>
r@   rA   r   r   r   r\     r  zXML2Writer._start_iterationsc                 C   r?   )Ns$           </Results>
      </results>
r@   rA   r   r   r   r^     r  zXML2Writer._end_iterationsc                 C   r?   )Ns          <search>
        <Search>
r@   rA   r   r   r   ra     r  zXML2Writer._start_iterationc                 C   r?   )Ns"           </Search>
      </search>
r@   rA   r   r   r   rq     r  zXML2Writer._end_iterationc                 C   r  )Ns&                 <query-id>%b</query-id>
r@   r   r   r   r   rd     
   z$XML2Writer._write_iteration_query_idc                 C   r  )Ns,                 <query-title>%b</query-title>
r@   r   r   r   r   re     r  z%XML2Writer._write_iteration_query_defc                 C   r  )Ns(                 <query-len>%d</query-len>
r@   r   r   r   r   rf     r  z%XML2Writer._write_iteration_query_lenc                 C   s    | j d|jd |jf  d S )Ns                 <query-masking>
                <Range>
                  <from>%d</from>
                  <to>%d</to>
                </Range>
              </query-masking>
r[   )r   r>   r   r   r   r   r   r   ri     s
   z)XML2Writer._write_iteration_query_maskingc                 C   r?   )Ns                 <hits>
r@   rA   r   r   r   rk     r  z XML2Writer._start_iteration_hitsc                 C   r?   )Ns                 </hits>
r@   rA   r   r   r   rm     r  zXML2Writer._end_iteration_hitsc                 C   r?   )Ns                 <stat>
r@   rA   r   r   r   ro     r  z XML2Writer._start_iteration_statc                 C   r?   )Ns                 </stat>
r@   rA   r   r   r   rp     r  zXML2Writer._end_iteration_statc                 C   r  )Ns             <matrix>%b</matrix>
r@   r   r   r   r   rK     r  z#XML2Writer._write_parameters_matrixc                 C   r  )Ns             <expect>%g</expect>
r@   r   r   r   r   rL     r  z#XML2Writer._write_parameters_expectc                 C   r  )Ns              <include>%g</include>
r@   r   r   r   r   rM     r  z$XML2Writer._write_parameters_includec                 C   r  )Ns"             <sc-match>%d</sc-match>
r@   r   r   r   r   rN     r  z%XML2Writer._write_parameters_sc_matchc                 C   r  )Ns(             <sc-mismatch>%d</sc-mismatch>
r@   r   r   r   r   rO   #  r  z(XML2Writer._write_parameters_sc_mismatchc                 C   r  )Ns"             <gap-open>%d</gap-open>
r@   r   r   r   r   rP   +  r  z%XML2Writer._write_parameters_gap_openc                 C   r  )Ns&             <gap-extend>%d</gap-extend>
r@   r   r   r   r   rQ   3  r  z'XML2Writer._write_parameters_gap_extendc                 C   r  )Ns             <filter>%b</filter>
r@   r   r   r   r   rR   ;  r  z#XML2Writer._write_parameters_filterc                 C   r  )Ns              <pattern>%b</pattern>
r@   r   r   r   r   rS   C  r  z$XML2Writer._write_parameters_patternc                 C   r  )Ns*             <entrez-query>%b</entrez-query>
r@   r   r   r   r   rT   K  r  z)XML2Writer._write_parameters_entrez_queryc                 C   r  )Ns             <cbs>%d</cbs>
r@   r   r   r   r   rU   S  r  z XML2Writer._write_parameters_cbsc                 C   r  )Ns,             <query-gencode>%d</query-gencode>
r@   r   r   r   r   rV   [  r  z*XML2Writer._write_parameters_query_gencodec                 C   r  )Ns&             <db-gencode>%d</db-gencode>
r@   r   r   r   r   rW   c  r  z'XML2Writer._write_parameters_db_gencodec                 C   r  )Ns(             <bl2seq-mode>%b</bl2seq-mode>
r@   r   r   r   r   rX   k  r  z(XML2Writer._write_parameters_bl2seq_modec                 C   r  )Ns&                     <db-num>%d</db-num>
r@   r   r   r   r   r   s  r  z#XML2Writer._write_statistics_db_numc                 C   r  )Ns&                     <db-len>%d</db-len>
r@   r   r   r   r   r   {  r  z#XML2Writer._write_statistics_db_lenc                 C   r  )Ns(                     <hsp-len>%d</hsp-len>
r@   r   r   r   r   r     r  z$XML2Writer._write_statistics_hsp_lenc                 C   r  )Ns,                     <eff-space>%s</eff-space>
r@   r   r   r   r   r     r  z&XML2Writer._write_statistics_eff_spacec                 C   r  )Ns$                     <kappa>%r</kappa>
r@   r   r   r   r   r     r  z"XML2Writer._write_statistics_kappac                 C   r  )Ns&                     <lambda>%r</lambda>
r@   r   r   r   r   r     r  z#XML2Writer._write_statistics_lambdac                 C   r  )Ns(                     <entropy>%r</entropy>
r@   r   r   r   r   r     r  z$XML2Writer._write_statistics_entropyc                 C   r?   )Ns                   <Hit>
r@   rA   r   r   r   rx     r  zXML2Writer._start_iteration_hitc                 C   r?   )Ns                   </Hit>
r@   rA   r   r   r   r     r  zXML2Writer._end_iteration_hitc                 C   r  )Ns                      <num>%d</num>
r@   r   r   r   r   ry     r  zXML2Writer._write_hit_numc                 C   r?   )Ns                      <description>
r@   rA   r   r   r   r     r  zXML2Writer._start_hit_targetsc                 C   r?   )Ns!                     </description>
r@   rA   r   r   r   r     r  zXML2Writer._end_hit_targetsc                 C   r?   )Ns                       <HitDescr>
r@   rA   r   r   r   r     r  zXML2Writer._start_hitdescrc                 C   r?   )Ns                        </HitDescr>
r@   rA   r   r   r   r     r  zXML2Writer._end_hitdescrc                 C   r  )Ns"                         <id>%b</id>
r@   r   r   r   r   r{     r  zXML2Writer._write_hit_idc                 C   r  )Ns(                         <title>%b</title>
r@   r   r   r   r   r|     r  zXML2Writer._write_hit_defc                 C   r  )Ns0                         <accession>%b</accession>
r@   r   r   r   r   r}     r  zXML2Writer._write_hit_accessionc                 C   r  )Ns                      <len>%d</len>
r@   r   r   r   r   r     r  zXML2Writer._write_hit_lenc                 C   r  )Ns(                         <taxid>%d</taxid>
r@   r   r   r   r   r     r  zXML2Writer._write_hit_taxidc                 C   r  )Ns,                         <sciname>%b</sciname>
r@   r   r   r   r   r     r  zXML2Writer._write_hit_scinamec                 C   r?   )Ns                     <hsps>
r@   rA   r   r   r   r     r  zXML2Writer._start_hit_hspsc                 C   r?   )Ns                     </hsps>
r@   rA   r   r   r   r     r  zXML2Writer._end_hit_hspsc                 C   r?   )Ns                       <Hsp>
r@   rA   r   r   r   r     r  zXML2Writer._start_hspc                 C   r?   )Ns                       </Hsp>
r@   rA   r   r   r   r   "  r  zXML2Writer._end_hspc                 C   r  )Ns$                         <num>%d</num>
r@   r   r   r   r   r   )  r  zXML2Writer._write_hsp_numc                 C   r  )Ns0                         <bit-score>%b</bit-score>
r@   r   r   r   r   r   1  r  zXML2Writer._write_hsp_bit_scorec                 C   r  )Ns(                         <score>%d</score>
r@   r   r   r   r   r   9  r  zXML2Writer._write_hsp_scorec                 C   r  )Ns*                         <evalue>%b</evalue>
r@   r   r   r   r   r   A  r  zXML2Writer._write_hsp_evaluec                 C   r  )Ns2                         <query-from>%d</query-from>
r@   r   r   r   r   r   I  r  z XML2Writer._write_hsp_query_fromc                 C   r  )Ns.                         <query-to>%d</query-to>
r@   r   r   r   r   r   Q  r  zXML2Writer._write_hsp_query_toc                 C   r  )Ns.                         <hit-from>%d</hit-from>
r@   r   r   r   r   r   Y  r  zXML2Writer._write_hsp_hit_fromc                 C   r  )Ns*                         <hit-to>%d</hit-to>
r@   r   r   r   r   r   a  r  zXML2Writer._write_hsp_hit_toc                 C   r  )Ns6                         <pattern-from>%d</pattern-from>
r@   r  r   r   r   r   i  r  z"XML2Writer._write_hsp_pattern_fromc                 C   r  )Ns2                         <pattern-to>%d</pattern-to>
r@   r  r   r   r   r   q  r  z XML2Writer._write_hsp_pattern_toc                 C   r  )Ns4                         <query-frame>%d</query-frame>
r@   r   r   r   r   r   y  r  z!XML2Writer._write_hsp_query_framec                 C   r  )Ns0                         <hit-frame>%d</hit-frame>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_hit_framec                 C   r  )Ns.                         <identity>%d</identity>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_identityc                 C   r  )Ns.                         <positive>%d</positive>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_positivec                 C   r  )Ns&                         <gaps>%d</gaps>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_gapsc                 C   r  )Ns0                         <align-len>%d</align-len>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_align_lenc                 C   r  )Ns,                         <density>%d</density>
r@   r  r   r   r   r    r  zXML2Writer._write_hsp_densityc                 C   r  )Ns&                         <qseq>%b</qseq>
r@   r	  r   r   r   r     r  zXML2Writer._write_hsp_qseqc                 C   r  )Ns&                         <hseq>%b</hseq>
r@   r
  r   r   r   r     r  zXML2Writer._write_hsp_hseqc                 C   r  )Ns,                         <midline>%b</midline>
r@   r  r   r   r   r     r  zXML2Writer._write_hsp_midlineN)Rr  r  r  r  r   r:   r   r!   r%   r&   rI   rY   r\   r^   ra   rq   rd   re   rf   ri   rk   rm   ro   rp   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   r   r   r   r   r   r   r   rx   r   ry   r   r   r   r   r{   r|   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r  b  s    
r  )codecsr
   abcr   r   Bio.Seqr   r   register_errorr   r  r  r   r   r   r   <module>   s     	    D  