B
    b%                 @   sr   d Z ddlmZ dZdZdZdZddlZddlZddl	m
Z
 dd	l	mZ dd
lmZ eeZG dd deZdS )z
Validate.py
^^^^^^^^^^

API for wwPDB Validation Web Service

:copyright: @wwPDB
:license: Apache 2.0, see LICENSE file for more details.


Updates:

     3-Aug-2016 jdw  add Authorization header
    20-Sep-2016 jdw  refactor for standard packaging
    )unicode_literalszrestructuredtext enzJohn Westbrookzjwest@rcsb.rutgers.eduz
Apache 2.0N)__version__)
__apiUrl__)ApiBasec                   s   e Zd Zd* f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  ZS )+ValidateNonedep_error_flagonedep_status_textc                s   |r|nt }|r|nd}dttj d f }d}tt| j||||dd dgdgdgdgd	gd	gd
gdgdgdgdgdgdgdgd}| | | j	||d dS )ay  
        OneDep validation webservice client API

        :param string apiKey: (Optional) security token.
        :param string apiUrl: (Optional) alternative API server URL.
        :param string errorFlagKey: (Optional) key for error flag in service return dictionary
        :param string statusTextKey: (Optional) key for status text in service return dictionary

        Z	anonymouszOneDepClient/%s Python/%s r   ZvalwsF)apiKey	userAgentapiNameapiUrlZverifypdbxanyznmr-starmapZpdfZxmlZtxtZsvg)modelzstructure-factorsznmr-chemical-shiftsznmr-restraintsznmr-data-nefznmr-data-strz	em-volumezvalidation-report-fullzvalidation-datazvalidation-data-cifzvalidation-report-logzvalidation-report-sliderzvalidation-report-2fo-map-coefzvalidation-report-fo-map-coef)errorFlagKeystatusTextKeyN)
r   r   sysversionsplitsuperr   __init__ZsetContentTypesZsetApiReturnStatusKeys)selfr	   r   r   r   r
   r   ZvalContentTypes)	__class__ 2lib/python3.7/site-packages/onedep/api/Validate.pyr   +   s*    


zValidate.__init__c             C   s   |   S )zCreate a new OneDep service session.

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text, and session_id)

        )ZcreateSession)r   r   r   r   
newSessionS   s    zValidate.newSessionc             C   s   | j |dddS )a  Input file containing model coordinates in PDBx/mmCIF format.

        :param string pdbxFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)

        r   r   )filePathcontentType
fileFormat)	inputFile)r   pdbxFilePathr   r   r   inputModelXyzFile[   s    zValidate.inputModelXyzFilec             C   s   | j |dddS )a
  Input file containing structure factor amplitudes in PDBx/mmCIF format.

        :param string pdbxFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        zstructure-factorsr   )r   r   r   )upload)r   r!   r   r   r   inputStructureFactorFilee   s    z!Validate.inputStructureFactorFilec             C   s   | j |dddS )a  Input file containing NMR chemical shift data in PDBx/mmCIF format.

        :param string pdbxFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        znmr-chemical-shiftsr   )r   r   r   )r#   )r   r!   r   r   r   inputNmrChemicalShiftsFilen   s    z#Validate.inputNmrChemicalShiftsFilec             C   s   | j |dddS )zInput file containing NMR restraints data in NEF/STAR format.

        :param string nefFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        znmr-restraintsZnef)r   r   r   )r#   )r   ZnefFilePathr   r   r   inputNmrRestraintsw   s    zValidate.inputNmrRestraintsc             C   s   | j |dddS )a  Input file containing NMR Data conforming to NEF dictionary in NMRstar format.

        :param string nmrDataFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        znmr-data-nefznmr-star)r   r   r   )r#   )r   nmrDataFilePathr   r   r   inputNmrDataNef   s    zValidate.inputNmrDataNefc             C   s   | j |dddS )a  Input file containing NMR Data conforming to NMRstar dictionary in NMRstar format.

        :param string nmrDataFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        znmr-data-strznmr-star)r   r   r   )r#   )r   r'   r   r   r   inputNmrDataStar   s    zValidate.inputNmrDataStarc             C   s   | j |dddS )zInput file containing EM volume data in CCP4 map format.

         :param string ccp4MapFilePath: full path to the input data file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        z	em-volumer   )r   r   r   )r#   )r   Zccp4MapFilePathr   r   r   inputEmVolume   s    zValidate.inputEmVolumec             C   s   |  |||S )a  Add the input data file to the current session context.

        :param string filePath: full path to the input data file
        :param string contentType: a supported content type (e.g. model, structure factors, ...)
        :param string fileFormat: a supported format type (e.g. pdbx, map, ...)

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        )r#   )r   r   r   r   r   r   r   r       s    	zValidate.inputFilec             C   s   | j ddS )zReturn the service status for the current session.

        :rtype: json service response converted to dictionary (with mininal keys: status, api_error_flag, api_status_text)
        Zsession_status)endPoint)post)r   r   r   r   	getStatus   s    zValidate.getStatusc             C   s   | j |ddS )a"  Store the output validation report from the current session context in the specified output file path.

        :param string filePath: full path to the output file

         :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        zvalidation-report-full)dstPathr   )downloadByType)r   r   r   r   r   	getReport   s    zValidate.getReportc             C   s   | j |ddS )a%  Store the output validation data file from the current session context in the specified output file path.

        :param string filePath: full path to the output file

         :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        zvalidation-data)r.   r   )r/   )r   r   r   r   r   getReportData   s    zValidate.getReportDatac             C   s   | j |ddS )a+  Store the mmCif output validation data file from the current session context in the specified output file path.

        :param string filePath: full path to the output file

         :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        zvalidation-data-cif)r.   r   )r/   )r   r   r   r   r   getReportDataMmCif   s    zValidate.getReportDataMmCifc             C   s   | j |ddS )a   Store the output session log file from the current session context in the specified output file path.

        :param string filePath: full path to the output file

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        zvalidation-report-log)r.   r   )r/   )r   r   r   r   r   getReportLog   s    zValidate.getReportLogc             C   s   | j ||dS )ad  Store the output file containing 'contentType' from the current session context in the specified output file path.

        :param string filePath: full path to the output file
        :param string contentType: target contentType

         :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        )r.   r   )r/   )r   r   r   r   r   r   getOutputByType   s    zValidate.getOutputByTypec             C   s   | j ddS )zReturn a catalog of the data content of the current session.

        :rtype: json service response converted to dictionary (catalog plus keys - api_error_flag, api_status_text, index)
        Zsession_index)r+   )r,   )r   r   r   r   getIndex   s    zValidate.getIndexc             C   s   | j ddS )zReturn a summary service activity for the current service user.

        :rtype: json service response converted to dictionary (catalog plus keys - api_error_flag, api_status_text, activity_summary)
        Zactivity)r+   )r,   )r   r   r   r   getActivity   s    zValidate.getActivityc             K   s   | j f ddi|S )zSubmit request to run the validation suite using the current session
            data file content.

        :rtype: json service response converted to dictionary (with mininal keys: api_error_flag, api_status_text)
        r+   Zvalidate_request)r,   )r   paramsr   r   r   run   s    zValidate.run)NNr   r   )__name__
__module____qualname__r   r   r"   r$   r%   r&   r(   r)   r*   r    r-   r0   r1   r2   r3   r4   r5   r6   r8   __classcell__r   r   )r   r   r   *   s&   (
										
r   )__doc__Z
__future__r   Z__docformat__
__author__Z	__email__Z__license__Zloggingr   Zonedepr   r   Zonedep.utils.ApiBaser   Z	getLoggerr9   logr   r   r   r   r   <module>   s   
