#! /usr/bin/python # # Python script that communicates with the GlobPlotter web service at EMBL # WSDL: http://globplot.embl.de/webservice/globplot.wsdl # By Kate Gould (gould@embl.de). # # save the contents of this file to your computer and save with the .py extension # in order for this client script to run you need the following modules installed as part of your python package: # SOAPpy (see webpage: http://pywebsvcs.sourceforge.net/) # # pre-requirements for SOAPpy are the following two packages(as specified in SOAPpy package README file): # 1. fpconst 0.6.0 or later, # # 2. pyXML 0.8.3 or later, # import SOAPpy, sys def main(): """Command line interface to the GlobPlotter Web service """ endpoint = 'http://luna.embl.de:8080/axis2/services/GlobPlotter' namespace = 'http://globplot.embl.de/GlobPlotter' globplot = SOAPpy.SOAPProxy(endpoint) globplot.namespace = namespace globplot.noroot = 1 try: # the following three input fields are mandatory sequenceId = 'src_human' sequenceIdentifier = SOAPpy.Types.untypedType(sequenceId) sequenceIdentifier._name = 'sequenceIdentifier' seq = 'MGSNKSKPKDASQRRRSLEPAENVHGAGGGAFPASQTPSKPASADGHRGPSAAFAPAAAEPKLFGGFNSSDTVTSPQRAGPLAGGVTTFVALYDYESRTETDLSFKKGERLQIVNNTEGDWWLAHSLSTGQTGYIPSNYVAPSDSIQAEEWYFGKITRRESERLLLNAENPRGTFLVRESETTKGAYCLSVSDFDNAKGLNVKHYKIRKLDSGGFYITSRTQFNSLQQLVAYYSKHADGLCHRLTTVCPTSKPQTQGLAKDAWEIPRESLRLEVKLGQGCFGEVWMGTWNGTTRVAIKTLKPGTMSPEAFLQEAQVMKKLRHEKLVQLYAVVSEEPIYIVTEYMSKGSLLDFLKGETGKYLRLPQLVDMAAQIASGMAYVERMNYVHRDLRAANILVGENLVCKVADFGLARLIEDNEYTARQGAKFPIKWTAPEAALYGRFTIKSDVWSFGILLTELTTKGRVPYPGMVNREVLDQVERGYRMPCPPECPESLHDLMCQCWRKEPEERPTFEYLQAFLEDYFTSTEPQYQPGENL' sequence = SOAPpy.Types.untypedType(seq) sequence._name = 'querySequence' # see the WSDL file for all possible valid values for this input field. propensityValue = 'Russell/Linding' propensity = SOAPpy.Types.untypedType(propensityValue) propensity._name = 'propensity' # all the following input values are optional. # if this value is left with the default value of "no" all subsequent values are effectively ignored _includeMainGraphics = 'yes' includeMainGraphics = SOAPpy.Types.untypedType(_includeMainGraphics) includeMainGraphics._name = 'includeMainGraphics' # the includeMainGraphics element must be set to "yes" for all the following element settings to affect the output details _disorderFrames_minimumPeakWidth = '4' disorderFrames_minimumPeakWidth = SOAPpy.Types.untypedType(_disorderFrames_minimumPeakWidth) disorderFrames_minimumPeakWidth._name = 'disorderFrames_minimumPeakWidth' _disorderFrames_maximumJoinDistance = '5' disorderFrames_maximumJoinDistance = SOAPpy.Types.untypedType(_disorderFrames_maximumJoinDistance) disorderFrames_maximumJoinDistance._name = 'disorderFrames_maximumJoinDistance' _globularityFrames_minimumDomainLength = '74' globularityFrames_minimumDomainLength = SOAPpy.Types.untypedType(_globularityFrames_minimumDomainLength) globularityFrames_minimumDomainLength._name = 'globularityFrames_minimumDomainLength' _globularity_maximumLinkerLength = '15' globularity_maximumLinkerLength = SOAPpy.Types.untypedType(_globularity_maximumLinkerLength) globularity_maximumLinkerLength._name = 'globularity_maximumLinkerLength' _smoothingSettings_firstDerivativeSavitzkyGolayFrame = '10' smoothingSettings_firstDerivativeSavitzkyGolayFrame = SOAPpy.Types.untypedType(_smoothingSettings_firstDerivativeSavitzkyGolayFrame) smoothingSettings_firstDerivativeSavitzkyGolayFrame._name = 'smoothingSettings_firstDerivativeSavitzkyGolayFrame' _smoothingSettings_secondDerivativeSavitzkyGolayFrame = '10' smoothingSettings_secondDerivativeSavitzkyGolayFrame = SOAPpy.Types.untypedType(_smoothingSettings_secondDerivativeSavitzkyGolayFrame) smoothingSettings_secondDerivativeSavitzkyGolayFrame._name = 'smoothingSettings_secondDerivativeSavitzkyGolayFrame' _titleOfGraphics = 'test' titleOfGraphics = SOAPpy.Types.untypedType(_titleOfGraphics) titleOfGraphics._name = 'titleOfGraphics' _performSmartPfamDomainPredictionInGraphics = 'yes' performSmartPfamDomainPredictionInGraphics = SOAPpy.Types.untypedType(_performSmartPfamDomainPredictionInGraphics) performSmartPfamDomainPredictionInGraphics._name = 'performSmartPfamDomainPredictionInGraphics' _includeRawPlotInMainGraphics = 'yes' includeRawPlotInMainGraphics = SOAPpy.Types.untypedType(_includeRawPlotInMainGraphics) includeRawPlotInMainGraphics._name = 'includeRawPlotInMainGraphics' _includeDydxPlotGraphics = 'yes' includeDydxPlotGraphics = SOAPpy.Types.untypedType(_includeDydxPlotGraphics) includeDydxPlotGraphics._name = 'includeDydxPlotGraphics' _includeSmoothedResultFile = 'yes' includeSmoothedResultFile = SOAPpy.Types.untypedType(_includeSmoothedResultFile) includeSmoothedResultFile._name = 'includeSmoothedResultFile' _includeDisorderGlobularDomainRangesFile = 'yes' includeDisorderGlobularDomainRangesFile = SOAPpy.Types.untypedType(_includeDisorderGlobularDomainRangesFile) includeDisorderGlobularDomainRangesFile._name = 'includeDisorderGlobularDomainRangesFile' _includeDydxPlotFile = 'yes' includeDydxPlotFile = SOAPpy.Types.untypedType(_includeDydxPlotFile) includeDydxPlotFile._name = 'includeDydxPlotFile' # the following is a bare-bones call to the globplot webservice #predictions = globplot.runGlobPlotter(sequenceIdentifier, sequence, propensity) # the following is a call with optional input elements included predictions = globplot.runGlobPlotter(sequenceIdentifier, sequence, propensity, includeMainGraphics, disorderFrames_minimumPeakWidth, disorderFrames_maximumJoinDistance, globularityFrames_minimumDomainLength, globularity_maximumLinkerLength, smoothingSettings_firstDerivativeSavitzkyGolayFrame, smoothingSettings_secondDerivativeSavitzkyGolayFrame, titleOfGraphics, performSmartPfamDomainPredictionInGraphics, includeRawPlotInMainGraphics, includeDydxPlotGraphics, includeSmoothedResultFile, includeDisorderGlobularDomainRangesFile, includeDydxPlotFile) identifier = predictions.sequence.identifier basicResultsFileName = identifier + "_basic_results.txt" basicResultsFile = open(basicResultsFileName, 'w') basicResultsFile.write("identifier: " + identifier + "\n") basicResultsFile.write("sequence: " + predictions.sequence.sequence + "\n\n") for gff_record in predictions.prediction.gff_record: basicResultsFile.write("seqname: " + gff_record.seqname + "\n") basicResultsFile.write("source: " + gff_record.source + "\n") basicResultsFile.write("feature: " + gff_record.feature + "\n") basicResultsFile.write("start: " + gff_record.start + "\n") basicResultsFile.write("end: " + gff_record.end + "\n") basicResultsFile.write("score: " + gff_record.score + "\n\n") print "basic results stored in text file: " + basicResultsFileName + "\n" basicResultsFile.close() import base64 if (predictions.__dict__.has_key('file')): # need to determine if we are processing one file object or a list of file objects if isinstance(predictions.file, list): for file in predictions.file: resultsFileName = identifier + "_" + file.comment + ".txt" f = open(resultsFileName, 'w') f.write(base64.decodestring(file.content)) f.close() print resultsFileName + " text file stored in current directory\n" else: resultsFileName = identifier + "_" + predictions.file.comment + ".txt" f = open(resultsFileName, 'w') f.write(base64.decodestring(predictions.file.content)) f.close() print resultsFileName + " text file stored in current directory\n" if (predictions.__dict__.has_key('image')): # need to determine if we are processing one image object or a list of image objects if isinstance(predictions.image, list): for image in predictions.image: resultsFileName = identifier + "_" + image.comment + ".png" f = open(resultsFileName, 'w') f.write(base64.decodestring(image.content)) f.close() print resultsFileName + " image file stored in current directory\n" else: resultsFileName = identifier + "_" + predictions.image.comment + ".png" f = open(resultsFileName, 'w') f.write(base64.decodestring(predictions.image.content)) f.close() print resultsFileName + " image file stored in current directory\n" except Exception, e: print 'Exception:', e if __name__ == '__main__': main ()