From a17f3c38045ca4509dc891722ea98143005119f6 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Fri, 4 Feb 2011 17:15:33 +0000 Subject: [PATCH] Disembl and Jronn web services work. Modified to produce raw scores Globplot script is added into binaries. Annotation IF renamed to SequenceAnnotation and getAnnotation() method returns Map> result instead of Set to unify. Changes cause by this is propagated. git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3704 e3abac25-378b-4346-85de-24260fe3988d --- TODO.txt | 15 +- binaries/src/globplot/GlobPipe.py | 225 ++++++++++++++++++++ binaries/src/globplot/GlobPipe.py.original | 222 +++++++++++++++++++ binaries/src/globplot/LICENSE | 121 +++++++++++ binaries/src/globplot/README | 32 +++ runner/compbio/runner/disorder/Disembl.java | 89 ++++---- runner/compbio/runner/disorder/GlobProt.java | 17 -- .../compbio/ws/client/AAConWSClientExample.java | 15 +- testsrc/compbio/ws/client/TestAAConWS.java | 28 +-- .../{Annotation.java => SequenceAnnotation.java} | 28 ++- .../data/msa/jaxws/GetAnnotationResponse.java | 9 +- webservices/compbio/ws/client/AAConClient.java | 33 +-- webservices/compbio/ws/client/IOHelper.java | 11 +- webservices/compbio/ws/client/Jws2Client.java | 14 +- webservices/compbio/ws/client/Services.java | 4 +- webservices/compbio/ws/server/AAConWS.java | 13 +- webservices/compbio/ws/server/DisemblWS.java | 157 ++++++++++++++ webservices/compbio/ws/server/JronnWS.java | 32 ++- 18 files changed, 933 insertions(+), 132 deletions(-) create mode 100644 binaries/src/globplot/GlobPipe.py create mode 100644 binaries/src/globplot/GlobPipe.py.original create mode 100644 binaries/src/globplot/LICENSE create mode 100644 binaries/src/globplot/README delete mode 100644 runner/compbio/runner/disorder/GlobProt.java rename webservices/compbio/data/msa/{Annotation.java => SequenceAnnotation.java} (86%) create mode 100644 webservices/compbio/ws/server/DisemblWS.java diff --git a/TODO.txt b/TODO.txt index f25cd0d..e3f5142 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,18 @@ TODO: +Add registry service to query services status + +Refactor web services checker to enable a programmatic access to its methods. +Rename it to avoid confusion with jabaws client + +Finish the client + +Add interface for Jalview annotation +Add the method to return Jalview Annotation to SequenceAnnotation IF + +Develop generic Interface to return Jalview annotation for easy to add new +services (?) + Replace conservation.Method with server.ws.Method and try building WS. If this does not work - get rid of Method @@ -10,7 +23,7 @@ integrate the above to tweak the size of the local job Add AACon ws Add iupred ws http://iupred.enzim.hu/ -Add globprot ws +Add globprot ws - does not report raw scores, just regions Add ronn ws Philogeny Mrbayes + Philip diff --git a/binaries/src/globplot/GlobPipe.py b/binaries/src/globplot/GlobPipe.py new file mode 100644 index 0000000..71be8a7 --- /dev/null +++ b/binaries/src/globplot/GlobPipe.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python +# Copyright (C) 2003 Rune Linding - EMBL +# GlobPlot TM +# GlobPlot is licensed under the Academic Free license + +from string import * +from sys import argv +import sys,re +import os +from os import system,popen3 + +relpath = re.sub("/GlobPipe.py$","",argv[0]) +newpath =os.getcwd()+"/"+relpath+"/biopython-1.50" +sys.path.append(newpath) + +import Bio +from Bio import File +from Bio import Fasta +import fpformat +import tempfile +import math + +# Russell/Linding +RL = {'N':0.229885057471264,'P':0.552316012226663,'Q':-0.187676577424997,'A':-0.261538461538462,'R':-0.176592654077609, \ + 'S':0.142883029808825,'C':-0.0151515151515152,'T':0.00887797506611258,'D':0.227629796839729,'E':-0.204684629516228, \ + 'V':-0.386174834235195,'F':-0.225572305974316,'W':-0.243375458622095,'G':0.433225711769886,'H':-0.00121743364986608, \ + 'Y':-0.20750516775322,'I':-0.422234699606962,'K':-0.100092289621613,'L':-0.337933495925287,'M':-0.225903614457831} + +def Sum(seq,par_dict): + sum = 0 + results = [] + raws = [] + sums = [] + p = 1 + for residue in seq: + try: + parameter = par_dict[residue] + except: + parameter = 0 + if p == 1: + sum = parameter + else: + sum = sum + parameter#*math.log10(p) + ssum = float(fpformat.fix(sum,10)) + sums.append(ssum) + p +=1 + return sums + +def getSlices(dydx_data, DOM_join_frame, DOM_peak_frame, DIS_join_frame, DIS_peak_frame): + DOMslices = [] + DISslices = [] + in_DOMslice = 0 + in_DISslice = 0 + beginDOMslice = 0 + endDOMslice = 0 + beginDISslice = 0 + endDISslice = 0 + for i in range( len(dydx_data) ): + #close dom slice + if in_DOMslice and dydx_data[i] > 0: + DOMslices.append([beginDOMslice, endDOMslice]) + in_DOMslice = 0 + #close dis slice + elif in_DISslice and dydx_data[i] < 0: + DISslices.append([beginDISslice, endDISslice]) + in_DISslice = 0 + # elseif inSlice expandslice + elif in_DOMslice: + endDOMslice += 1 + elif in_DISslice: + endDISslice += 1 + # if not in slice and dydx !== 0 start slice + if dydx_data[i] > 0 and not in_DISslice: + beginDISslice = i + endDISslice = i + in_DISslice = 1 + elif dydx_data[i] < 0 and not in_DOMslice: + beginDOMslice = i + endDOMslice = i + in_DOMslice = 1 + #last slice + if in_DOMslice: + DOMslices.append([beginDOMslice, endDOMslice]) + if in_DISslice: + DISslices.append([beginDISslice,endDISslice]) + k = 0 + l = 0 + while k < len(DOMslices): + if k+1 < len(DOMslices) and DOMslices[k+1][0]-DOMslices[k][1] < DOM_join_frame: + DOMslices[k] = [ DOMslices[k][0], DOMslices[k+1][1] ] + del DOMslices[k+1] + elif DOMslices[k][1]-DOMslices[k][0]+1 < DOM_peak_frame: + del DOMslices[k] + else: + k += 1 + while l < len(DISslices): + if l+1 < len(DISslices) and DISslices[l+1][0]-DISslices[l][1] < DIS_join_frame: + DISslices[l] = [ DISslices[l][0], DISslices[l+1][1] ] + del DISslices[l+1] + elif DISslices[l][1]-DISslices[l][0]+1 < DIS_peak_frame: + del DISslices[l] + else: + l += 1 + return DOMslices, DISslices + + +def SavitzkyGolay(window,derivative,datalist): + SG_bin = relpath +'/'+ 'sav_gol -V0 ' + stdin, stdout, stderr = popen3(SG_bin + '-D' + str(derivative) + ' -n' + str(window)+','+str(window)) + for data in datalist: + stdin.write(`data`+'\n') + try: + stdin.close() + except: + print stderr.readlines() + results = stdout.readlines() + stdout.close() + SG_results = [] + for result in results: + SG_results.append(float(fpformat.fix(result,6))) + return SG_results + + +def reportSlicesTXT(slices, sequence, maskFlag): + if maskFlag == 'DOM': + coordstr = '|GlobDoms:' + elif maskFlag == 'DIS': + coordstr = '|Disorder:' + else: + raise SystemExit + if slices == []: + #by default the sequence is in uppercase which is our search space + s = sequence + else: + # insert seq before first slide + if slices[0][0] > 0: + s = sequence[0:slices[0][0]] + else: + s = '' + for i in range(len(slices)): + #skip first slice + if i > 0: + coordstr = coordstr + ', ' + coordstr = coordstr + str(slices[i][0]+1) + '-' + str(slices[i][1]+1) + #insert the actual slice + if maskFlag == 'DOM': + s = s + lower(sequence[slices[i][0]:(slices[i][1]+1)]) + if i < len(slices)-1: + s = s + upper(sequence[(slices[i][1]+1):(slices[i+1][0])]) + #last slice + elif slices[i][1] < len(sequence)-1: + s = s + lower(sequence[(slices[i][1]+1):(len(sequence))]) + elif maskFlag == 'DIS': + s = s + upper(sequence[slices[i][0]:(slices[i][1]+1)]) + #insert untouched seq between disorder segments, 2-run labelling + if i < len(slices)-1: + s = s + sequence[(slices[i][1]+1):(slices[i+1][0])] + #last slice + elif slices[i][1] < len(sequence)-1: + s = s + sequence[(slices[i][1]+1):(len(sequence))] + return s,coordstr + + +def runGlobPlot(): + try: + smoothFrame = int(sys.argv[1]) + DOM_joinFrame = int(sys.argv[2]) + DOM_peakFrame = int(sys.argv[3]) + DIS_joinFrame = int(sys.argv[4]) + DIS_peakFrame = int(sys.argv[5]) + file = str(sys.argv[6]) + db = open(file,'r') + except: + print 'Usage:' + print ' ./GlobPipe.py SmoothFrame DOMjoinFrame DOMpeakFrame DISjoinFrame DISpeakFrame FASTAfile' + print ' Optimised for ELM: ./GlobPlot.py 10 8 75 8 8 sequence_file' + print ' Webserver settings: ./GlobPlot.py 10 15 74 4 5 sequence_file' + raise SystemExit + parser = Fasta.RecordParser() + iterator = Fasta.Iterator(db,parser) + while 1: + try: + cur_record = iterator.next() + #uppercase is searchspace + seq = upper(cur_record.sequence) + # sum function + sum_vector = Sum(seq,RL) + # Run Savitzky-Golay + smooth = SavitzkyGolay(`smoothFrame`,0, sum_vector) + dydx_vector = SavitzkyGolay(`smoothFrame`,1, sum_vector) + #test + sumHEAD = sum_vector[:smoothFrame] + sumTAIL = sum_vector[len(sum_vector)-smoothFrame:] + newHEAD = [] + newTAIL = [] + for i in range(len(sumHEAD)): + try: + dHEAD = (sumHEAD[i+1]-sumHEAD[i])/2 + except: + dHEAD = (sumHEAD[i]-sumHEAD[i-1])/2 + try: + dTAIL = (sumTAIL[i+1]-sumTAIL[i])/2 + except: + dTAIL = (sumTAIL[i]-sumTAIL[i-1])/2 + newHEAD.append(dHEAD) + newTAIL.append(dTAIL) + dydx_vector[:smoothFrame] = newHEAD + dydx_vector[len(dydx_vector)-smoothFrame:] = newTAIL + globdoms, globdis = getSlices(dydx_vector, DOM_joinFrame, DOM_peakFrame, DIS_joinFrame, DIS_peakFrame) + s_domMask, coordstrDOM = reportSlicesTXT(globdoms, seq, 'DOM') + s_final, coordstrDIS = reportSlicesTXT(globdis, s_domMask, 'DIS') + sys.stdout.write('>'+cur_record.title+coordstrDOM+coordstrDIS+'\n') + +# UNCOMMENT THIS IF NEED TO PRODUCE PER RESEDUE VALUES + for i in range(len(dydx_vector)): +# dydx (positive values seems to indicate disorder in rows more than ~6 chars) raw smoothed + sys.stdout.write(seq[i]+'\t'+fpformat.fix(dydx_vector[i],4)+ '\t'+fpformat.fix(smooth[i],4)+'\t'+fpformat.fix(sum_vector[i],4)+ '\n') + +# print s_final + print '\n' + except AttributeError: + break + return + +runGlobPlot() diff --git a/binaries/src/globplot/GlobPipe.py.original b/binaries/src/globplot/GlobPipe.py.original new file mode 100644 index 0000000..579945f --- /dev/null +++ b/binaries/src/globplot/GlobPipe.py.original @@ -0,0 +1,222 @@ +#!/usr/bin/env python +# Copyright (C) 2003 Rune Linding - EMBL +# GlobPlot TM +# GlobPlot is licensed under the Academic Free license + +from string import * +from sys import argv +import sys +import os +from os import system,popen3 + +relpath = re.sub("/GlobPipe.py$","",argv[0]) +cwd = re.sub("/$","", os.getcwd()) +print '!' +os.getcwd() +print '!!' +cwd +newpath =cwd+"/"+relpath+"/biopython-1.50" +sys.path.append(newpath) + +import Bio +from Bio import File +from Bio import Fasta +import fpformat +import tempfile +import math + +# Russell/Linding +RL = {'N':0.229885057471264,'P':0.552316012226663,'Q':-0.187676577424997,'A':-0.261538461538462,'R':-0.176592654077609, \ + 'S':0.142883029808825,'C':-0.0151515151515152,'T':0.00887797506611258,'D':0.227629796839729,'E':-0.204684629516228, \ + 'V':-0.386174834235195,'F':-0.225572305974316,'W':-0.243375458622095,'G':0.433225711769886,'H':-0.00121743364986608, \ + 'Y':-0.20750516775322,'I':-0.422234699606962,'K':-0.100092289621613,'L':-0.337933495925287,'M':-0.225903614457831} + +def Sum(seq,par_dict): + sum = 0 + results = [] + raws = [] + sums = [] + p = 1 + for residue in seq: + try: + parameter = par_dict[residue] + except: + parameter = 0 + if p == 1: + sum = parameter + else: + sum = sum + parameter#*math.log10(p) + ssum = float(fpformat.fix(sum,10)) + sums.append(ssum) + p +=1 + return sums + +def getSlices(dydx_data, DOM_join_frame, DOM_peak_frame, DIS_join_frame, DIS_peak_frame): + DOMslices = [] + DISslices = [] + in_DOMslice = 0 + in_DISslice = 0 + beginDOMslice = 0 + endDOMslice = 0 + beginDISslice = 0 + endDISslice = 0 + for i in range( len(dydx_data) ): + #close dom slice + if in_DOMslice and dydx_data[i] > 0: + DOMslices.append([beginDOMslice, endDOMslice]) + in_DOMslice = 0 + #close dis slice + elif in_DISslice and dydx_data[i] < 0: + DISslices.append([beginDISslice, endDISslice]) + in_DISslice = 0 + # elseif inSlice expandslice + elif in_DOMslice: + endDOMslice += 1 + elif in_DISslice: + endDISslice += 1 + # if not in slice and dydx !== 0 start slice + if dydx_data[i] > 0 and not in_DISslice: + beginDISslice = i + endDISslice = i + in_DISslice = 1 + elif dydx_data[i] < 0 and not in_DOMslice: + beginDOMslice = i + endDOMslice = i + in_DOMslice = 1 + #last slice + if in_DOMslice: + DOMslices.append([beginDOMslice, endDOMslice]) + if in_DISslice: + DISslices.append([beginDISslice,endDISslice]) + k = 0 + l = 0 + while k < len(DOMslices): + if k+1 < len(DOMslices) and DOMslices[k+1][0]-DOMslices[k][1] < DOM_join_frame: + DOMslices[k] = [ DOMslices[k][0], DOMslices[k+1][1] ] + del DOMslices[k+1] + elif DOMslices[k][1]-DOMslices[k][0]+1 < DOM_peak_frame: + del DOMslices[k] + else: + k += 1 + while l < len(DISslices): + if l+1 < len(DISslices) and DISslices[l+1][0]-DISslices[l][1] < DIS_join_frame: + DISslices[l] = [ DISslices[l][0], DISslices[l+1][1] ] + del DISslices[l+1] + elif DISslices[l][1]-DISslices[l][0]+1 < DIS_peak_frame: + del DISslices[l] + else: + l += 1 + return DOMslices, DISslices + + +def SavitzkyGolay(window,derivative,datalist): + SG_bin = '/homes/pvtroshin/soft/GlobPipe-2.3/sav_gol -V0 ' + stdin, stdout, stderr = popen3(SG_bin + '-D' + str(derivative) + ' -n' + str(window)+','+str(window)) + for data in datalist: + stdin.write(`data`+'\n') + try: + stdin.close() + except: + print stderr.readlines() + results = stdout.readlines() + stdout.close() + SG_results = [] + for result in results: + SG_results.append(float(fpformat.fix(result,6))) + return SG_results + + +def reportSlicesTXT(slices, sequence, maskFlag): + if maskFlag == 'DOM': + coordstr = '|GlobDoms:' + elif maskFlag == 'DIS': + coordstr = '|Disorder:' + else: + raise SystemExit + if slices == []: + #by default the sequence is in uppercase which is our search space + s = sequence + else: + # insert seq before first slide + if slices[0][0] > 0: + s = sequence[0:slices[0][0]] + else: + s = '' + for i in range(len(slices)): + #skip first slice + if i > 0: + coordstr = coordstr + ', ' + coordstr = coordstr + str(slices[i][0]+1) + '-' + str(slices[i][1]+1) + #insert the actual slice + if maskFlag == 'DOM': + s = s + lower(sequence[slices[i][0]:(slices[i][1]+1)]) + if i < len(slices)-1: + s = s + upper(sequence[(slices[i][1]+1):(slices[i+1][0])]) + #last slice + elif slices[i][1] < len(sequence)-1: + s = s + lower(sequence[(slices[i][1]+1):(len(sequence))]) + elif maskFlag == 'DIS': + s = s + upper(sequence[slices[i][0]:(slices[i][1]+1)]) + #insert untouched seq between disorder segments, 2-run labelling + if i < len(slices)-1: + s = s + sequence[(slices[i][1]+1):(slices[i+1][0])] + #last slice + elif slices[i][1] < len(sequence)-1: + s = s + sequence[(slices[i][1]+1):(len(sequence))] + return s,coordstr + + +def runGlobPlot(): + try: + smoothFrame = int(sys.argv[1]) + DOM_joinFrame = int(sys.argv[2]) + DOM_peakFrame = int(sys.argv[3]) + DIS_joinFrame = int(sys.argv[4]) + DIS_peakFrame = int(sys.argv[5]) + file = str(sys.argv[6]) + db = open(file,'r') + except: + print 'Usage:' + print ' ./GlobPipe.py SmoothFrame DOMjoinFrame DOMpeakFrame DISjoinFrame DISpeakFrame FASTAfile' + print ' Optimised for ELM: ./GlobPlot.py 10 8 75 8 8 sequence_file' + print ' Webserver settings: ./GlobPlot.py 10 15 74 4 5 sequence_file' + raise SystemExit + parser = Fasta.RecordParser() + iterator = Fasta.Iterator(db,parser) + while 1: + try: + cur_record = iterator.next() + #uppercase is searchspace + seq = upper(cur_record.sequence) + # sum function + sum_vector = Sum(seq,RL) + # Run Savitzky-Golay + smooth = SavitzkyGolay(`smoothFrame`,0, sum_vector) + dydx_vector = SavitzkyGolay(`smoothFrame`,1, sum_vector) + #test + sumHEAD = sum_vector[:smoothFrame] + sumTAIL = sum_vector[len(sum_vector)-smoothFrame:] + newHEAD = [] + newTAIL = [] + for i in range(len(sumHEAD)): + try: + dHEAD = (sumHEAD[i+1]-sumHEAD[i])/2 + except: + dHEAD = (sumHEAD[i]-sumHEAD[i-1])/2 + try: + dTAIL = (sumTAIL[i+1]-sumTAIL[i])/2 + except: + dTAIL = (sumTAIL[i]-sumTAIL[i-1])/2 + newHEAD.append(dHEAD) + newTAIL.append(dTAIL) + dydx_vector[:smoothFrame] = newHEAD + dydx_vector[len(dydx_vector)-smoothFrame:] = newTAIL + globdoms, globdis = getSlices(dydx_vector, DOM_joinFrame, DOM_peakFrame, DIS_joinFrame, DIS_peakFrame) + s_domMask, coordstrDOM = reportSlicesTXT(globdoms, seq, 'DOM') + s_final, coordstrDIS = reportSlicesTXT(globdis, s_domMask, 'DIS') + sys.stdout.write('>'+cur_record.title+coordstrDOM+coordstrDIS+'\n') + print s_final + print '\n' + except AttributeError: + break + return + +runGlobPlot() diff --git a/binaries/src/globplot/LICENSE b/binaries/src/globplot/LICENSE new file mode 100644 index 0000000..2da5f9c --- /dev/null +++ b/binaries/src/globplot/LICENSE @@ -0,0 +1,121 @@ +Academic Free License + Version 1.2 + +This Academic Free License applies to any original work of authorship +(the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the +Original Work: + +Licensed under the Academic Free License version 1.2 + +Grant of License. Licensor hereby grants to any person obtaining a +copy of the Original Work ("You") a world-wide, royalty-free, +non-exclusive, perpetual, non-sublicenseable license (1) to use, copy, +modify, merge, publish, perform, distribute and/or sell copies of the +Original Work and derivative works thereof, and (2) under patent claims +owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for +sale the Original Work and derivative works thereof, subject to the +following conditions. + +Attribution Rights. You must retain, in the Source Code of any +Derivative Works that You create, all copyright, patent or trademark +notices from the Source Code of the Original Work, as well as any +notices of licensing and any descriptive text identified therein as an +"Attribution Notice." You must cause the Source Code for any Derivative +Works that You create to carry a prominent Attribution Notice reasonably +calculated to inform recipients that You have modified the Original Work. + +Exclusions from License Grant. Neither the names of Licensor, nor the +names of any contributors to the Original Work, nor any of their +trademarks or service marks, may be used to endorse or promote products +derived from this Original Work without express prior written permission +of the Licensor. + +Warranty and Disclaimer of Warranty. Licensor warrants that the copyright +in and to the Original Work is owned by the Licensor or that the Original +Work is distributed by Licensor under a valid current license from the +copyright owner. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" +BASIS and WITHOUT WARRANTY, either express or implied, including, without +limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL +WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part +of this License. No license to Original Work is granted hereunder except +under this disclaimer. + +Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, +incidental, or consequential damages of any character arising as a result +of this License or the use of the Original Work including, without +limitation, damages for loss of goodwill, work stoppage, computer failure +or malfunction, or any and all other commercial damages or losses. This +limitation of liability shall not apply to liability for death or personal +injury resulting from Licensor's negligence to the extent applicable law +prohibits such limitation. Some jurisdictions do not allow the exclusion or +limitation of incidental or consequential damages, so this exclusion and +limitation may not apply to You. + +License to Source Code. The term "Source Code" means the preferred form of +the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for +as long as Licensor continues to distribute the Original Work, and by +publishing the address of that information repository in a notice immediately +following the copyright notice that applies to the Original Work. + +Mutual Termination for Patent Action. This License shall terminate +automatically and You may no longer exercise any of the rights granted to You +by this License if You file a lawsuit in any court alleging that any OSI +Certified open source software that is licensed under any license containing +this "Mutual Termination for Patent Action" clause infringes any patent +claims that are essential to use that software. + +Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises +not to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2002 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. + +-- +END OF LICENSE. The following is intended to describe the essential +differences between the Academic Free License (AFL) version 1.0 and other +open source licenses: + +The Academic Free License is similar to the BSD, MIT, UoI/NCSA and Apache +licenses in many respects but it is intended to solve a few problems with +those licenses. + +* The AFL is written so as to make it clear what software is being +licensed (by the inclusion of a statement following the copyright notice +in the software). This way, the license functions better than a template +license. The BSD, MIT and UoI/NCSA licenses apply to unidentified software. + +* The AFL contains a complete copyright grant to the software. The BSD +and Apache licenses are vague and incomplete in that respect. + +* The AFL contains a complete patent grant to the software. The BSD, MIT, +UoI/NCSA and Apache licenses rely on an implied patent license and contain +no explicit patent grant. + +* The AFL makes it clear that no trademark rights are granted to the +licensor's trademarks. The Apache license contains such a provision, but the +BSD, MIT and UoI/NCSA licenses do not. + +* The AFL includes the warranty by the licensor that it either owns the +copyright or that it is distributing the software under a license. None of +the other licenses contain that warranty. All other warranties are disclaimed, +as is the case for the other licenses. + +* The AFL is itself copyrighted (with the right granted to copy and distribute +without modification). This ensures that the owner of the copyright to the +license will control changes. The Apache license contains a copyright notice, +but the BSD, MIT and UoI/NCSA licenses do not. diff --git a/binaries/src/globplot/README b/binaries/src/globplot/README new file mode 100644 index 0000000..35a0e10 --- /dev/null +++ b/binaries/src/globplot/README @@ -0,0 +1,32 @@ +Quick install: + +-install python2.2+ +-install Biopython from www.biopython.org + +-download TISEAN source: http://www.mpipks-dresden.mpg.de/~tisean/archive.html#source +-compile the TISEAN package and get the sav_gol binary from the TISEAN_2.1/source_c directory, +move it to the same directory as this archive was extracted to or change the path in +the SavitzkyGolay routine. + +run globplot: ./GlobPlot.py + + +note: only Russell/Linding propensities are currently in the script, +you can replace them manually or mail and ask me to do it...but these +parameters are the ones we had best results with! + + +input: sequence_file is a fasta or file with multiple fasta sequences in! +output: note that the masking is OPPOSITE the one the www servers is giving, +CAPITAL letters means GlobDom or disorder! + + + + +cheers +r. + +GlobPlot & GlobPipe +Rune Linding +Copyright (C) 2003 +email: linding@embl.de diff --git a/runner/compbio/runner/disorder/Disembl.java b/runner/compbio/runner/disorder/Disembl.java index 337395c..83ca5d3 100644 --- a/runner/compbio/runner/disorder/Disembl.java +++ b/runner/compbio/runner/disorder/Disembl.java @@ -19,17 +19,14 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; - import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; - import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; - import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; @@ -39,26 +36,26 @@ import compbio.metadata.ResultNotAvailableException; import compbio.runner.Util; /** - * DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops - * fold_rem465 sequence_file print - * - * 'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 fasta_file > out' - * - * This version of DisEMBL is 1.4 (latest available for download in Feb 2011) - * capable of outputting raw values - * - * The values of the parameters are hard coded in DisEMBL.py script. - * smooth_frame=8 peak_frame=8 join_frame=4 fold_coils=1.2 fold_hotloops=1.4 - * fold_rem465=1.2 - * - * Changing these values are not recommended by developers, apart from smoothing window. - * However, 5 orders of magnitude changes in this parameter does not change the output - * so allowing this change also seems pointless. Finally, the binary, DisEMBL depends on - * - Tisean is not happy with arbitruary changes to these values, so changing them can - * lead to problems. - * + * DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops + * fold_rem465 sequence_file print + * + * 'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 fasta_file > out' + * + * This version of DisEMBL is 1.4 (latest available for download in Feb 2011) + * capable of outputting raw values + * + * The values of the parameters are hard coded in DisEMBL.py script. + * smooth_frame=8 peak_frame=8 join_frame=4 fold_coils=1.2 fold_hotloops=1.4 + * fold_rem465=1.2 * - * This is not a standard DisEMBL! The script has been modified! + * Changing these values are not recommended by developers, apart from smoothing + * window. However, 5 orders of magnitude changes in this parameter does not + * change the output so allowing this change also seems pointless. Finally, the + * binary, DisEMBL depends on - Tisean is not happy with arbitruary changes to + * these values, so changing them can lead to problems. + * + * + * This is not a standard DisEMBL! The script has been modified! * */ public class Disembl extends SkeletalExecutable @@ -72,6 +69,13 @@ public class Disembl extends SkeletalExecutable public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + /** + * For the region to be considered disordered the values must exceed these + */ + public final double COILS_EXPECTATION_THRESHOLD = 0.43; + public final double REM_EXPECTATION_THRESHOLD = 0.5; + public final double LOOPS_EXPECTATION_THRESHOLD = 0.086; + /* The parameter list there must not contain same values! */ public Disembl() { // remove default input to prevent it to appear in the parameters list @@ -84,26 +88,27 @@ public class Disembl extends SkeletalExecutable throws ResultNotAvailableException { InputStream inStream = null; - Map> results= null; - try { - inStream = new FileInputStream(new File(workDirectory, - getOutput())); - results = SequenceUtil.removeSequences(SequenceUtil.readDisembl(inStream)); - inStream.close(); - } catch (FileNotFoundException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (IOException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (UnknownFileFormatException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (NullPointerException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } - + Map> results = null; + // How about getting ranges? + try { + inStream = new FileInputStream(new File(workDirectory, getOutput())); + results = SequenceUtil.removeSequences(SequenceUtil + .readDisembl(inStream)); + inStream.close(); + } catch (FileNotFoundException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (IOException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (UnknownFileFormatException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (NullPointerException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } + return results; } diff --git a/runner/compbio/runner/disorder/GlobProt.java b/runner/compbio/runner/disorder/GlobProt.java deleted file mode 100644 index 4ef7a3f..0000000 --- a/runner/compbio/runner/disorder/GlobProt.java +++ /dev/null @@ -1,17 +0,0 @@ -package compbio.runner.disorder; - -/** - * - * ./GlobPipe.py SmoothFrame DOMjoinFrame DOMpeakFrame DISjoinFrame DISpeakFrame - * FASTAfile - * - * Optimised for ELM: ./GlobPlot.py 10 8 75 8 8 sequence_file - * - * Webserver settings: ./GlobPlot.py 10 15 74 4 5 sequence_file - * - * @author pvtroshin - * - */ -public class GlobProt { - -} diff --git a/testsrc/compbio/ws/client/AAConWSClientExample.java b/testsrc/compbio/ws/client/AAConWSClientExample.java index 98c2dfc..4178ada 100644 --- a/testsrc/compbio/ws/client/AAConWSClientExample.java +++ b/testsrc/compbio/ws/client/AAConWSClientExample.java @@ -3,10 +3,11 @@ package compbio.ws.client; import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.Map; -import compbio.data.msa.Annotation; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; @@ -70,8 +71,9 @@ public class AAConWSClientExample { /* * Annotation interface for AAConWS web service instance */ - Annotation client = (Annotation) Jws2Client.connect( - "http://www.compbio.dundee.ac.uk/aacon", Services.AAConWS); + SequenceAnnotation client = (SequenceAnnotation) Jws2Client + .connect("http://www.compbio.dundee.ac.uk/aacon", + Services.AAConWS); /* Get the list of available presets */ PresetManager presetman = client.getPresets(); @@ -94,7 +96,7 @@ public class AAConWSClientExample { String jobId = client.presetAnalize(fastalist, preset); /* This method will block for the duration of the calculation */ - Set result = client.getAnnotation(jobId); + Map> result = client.getAnnotation(jobId); /* * This is a better way of obtaining results, it does not involve @@ -108,7 +110,8 @@ public class AAConWSClientExample { // } /* Output the alignment to standard out */ - Score.write(result, System.out); + IOHelper.writeOut(System.out, result); + // Score.write(result, System.out); /* Alternatively, you can record retrieved alignment into the file */ // FileOutputStream out = new FileOutputStream("result.txt"); diff --git a/testsrc/compbio/ws/client/TestAAConWS.java b/testsrc/compbio/ws/client/TestAAConWS.java index acaf57f..4fa90ac 100644 --- a/testsrc/compbio/ws/client/TestAAConWS.java +++ b/testsrc/compbio/ws/client/TestAAConWS.java @@ -11,12 +11,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Map; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import compbio.data.msa.Annotation; import compbio.data.msa.JABAService; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.ConservationMethod; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; @@ -33,7 +34,7 @@ import compbio.util.SysPrefs; public class TestAAConWS { - Annotation msaws; + SequenceAnnotation msaws; @BeforeTest void initConnection() { @@ -49,7 +50,7 @@ public class TestAAConWS { */ JABAService client = Jws2Client.connect("http://localhost:8080/jabaws", Services.AAConWS); - msaws = (Annotation) client; + msaws = (SequenceAnnotation) client; } @Test @@ -77,12 +78,13 @@ public class TestAAConWS { System.out.println("Pres: " + msaws.getPresets().getPresets()); String jobId = msaws.analize(fsl); System.out.println("J: " + jobId); - HashSet result = msaws.getAnnotation(jobId); + Map> result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.size(), 1); - assertEquals(result.iterator().next().getMethod(), - ConservationMethod.SHENKIN); - List scores = result.iterator().next().getScores(); + assertEquals(result.values().iterator().next().iterator().next() + .getMethod(), ConservationMethod.SHENKIN); + List scores = result.values().iterator().next().iterator() + .next().getScores(); assertNotNull(scores); assertEquals(scores.size(), 568); @@ -142,7 +144,7 @@ public class TestAAConWS { PresetManager presets = msaws.getPresets(); String jobId = msaws.presetAnalize(fsl, presets.getPresetByName("Quick conservation")); - HashSet result = msaws.getAnnotation(jobId); + Map> result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.size(), 13); @@ -197,12 +199,12 @@ public class TestAAConWS { // .setDefaultValue("MAX_SCORE"); // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1"); String jobId = msaws.customAnalize(fsl, options.getArguments()); - HashSet result = msaws.getAnnotation(jobId); + Map> result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.size(), 1); assertEquals( - new ArrayList(result).get(0).getScores().get(0), - 0.698f); + new ArrayList(result.values().iterator().next()) + .get(0).getScores().get(0), 0.698f); options.getArgument("Calculation method").setDefaultValue("SMERFS"); options.removeArgument("Normalize"); @@ -212,8 +214,8 @@ public class TestAAConWS { assertNotNull(result); assertEquals(result.size(), 1); assertEquals( - new ArrayList(result).get(0).getScores().get(0), - 0.401f); + new ArrayList(result.values().iterator().next()) + .get(0).getScores().get(0), 0.401f); } catch (WrongParameterException e) { e.printStackTrace(); diff --git a/webservices/compbio/data/msa/Annotation.java b/webservices/compbio/data/msa/SequenceAnnotation.java similarity index 86% rename from webservices/compbio/data/msa/Annotation.java rename to webservices/compbio/data/msa/SequenceAnnotation.java index 27a1d55..d238d6b 100644 --- a/webservices/compbio/data/msa/Annotation.java +++ b/webservices/compbio/data/msa/SequenceAnnotation.java @@ -1,6 +1,7 @@ package compbio.data.msa; import java.security.InvalidParameterException; +import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -21,6 +22,8 @@ import compbio.metadata.WrongParameterException; /** * Interface for tools that results to one or more annotation to sequence(s) * + * Single, multiple sequences their groups or alignments can be annotated + * * @author Peter Troshin * * @param @@ -29,7 +32,11 @@ import compbio.metadata.WrongParameterException; * @version 1.0 November 2010 */ @WebService(targetNamespace = "http://msa.data.compbio/01/12/2010/") -public interface Annotation extends JABAService, JManagement, Metadata { +public interface SequenceAnnotation + extends + JABAService, + JManagement, + Metadata { /** * @@ -167,7 +174,13 @@ public interface Annotation extends JABAService, JManagement, Metadata { * * @param jobId * a unique job identifier - * @return the HashSet of Score objects + * @return the Map with the sequence names, sequence group names or the word + * 'Alignment' in case of alignments and values the represented by a + * Set of Score objects. The alignment can be represented in as + * little as one key->value pair in this map, the list of sequences + * will be represented by multiple key->value mappings. If multiple + * annotations were calculated, then they are represented as a Set + * of Scores. * @throws ResultNotAvailableException * this exception is throw if the job execution was not * successful or the result of the execution could not be found. @@ -178,9 +191,16 @@ public interface Annotation extends JABAService, JManagement, Metadata { * @throws InvalidParameterException * thrown if jobId is empty or cannot be recognised e.g. in * invalid format + * */ @WebMethod - HashSet getAnnotation(@WebParam(name = "jobId") String jobId) + HashMap> getAnnotation( + @WebParam(name = "jobId") String jobId) throws ResultNotAvailableException; - + /* + * The method should really return Map and Set, but unfortunately JAXB + * cannot serialize interfaces, has a concrete implementation is used Could + * also specify the generic Set e.g. ? extends Set. But this would require + * the client cast or operate with generic Set. Keep it simple for now. + */ } diff --git a/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java b/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java index c9d0d5b..d7adf3c 100644 --- a/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java +++ b/webservices/compbio/data/msa/jaxws/GetAnnotationResponse.java @@ -1,6 +1,7 @@ package compbio.data.msa.jaxws; +import java.util.HashMap; import java.util.HashSet; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -14,14 +15,14 @@ import javax.xml.bind.annotation.XmlType; public class GetAnnotationResponse { @XmlElement(name = "return", namespace = "") - private HashSet _return; + private HashMap> _return; /** * * @return - * returns HashSet + * returns HashMap> */ - public HashSet getReturn() { + public HashMap> getReturn() { return this._return; } @@ -30,7 +31,7 @@ public class GetAnnotationResponse { * @param _return * the value for the _return property */ - public void setReturn(HashSet _return) { + public void setReturn(HashMap> _return) { this._return = _return; } diff --git a/webservices/compbio/ws/client/AAConClient.java b/webservices/compbio/ws/client/AAConClient.java index 34fc751..57cf59f 100644 --- a/webservices/compbio/ws/client/AAConClient.java +++ b/webservices/compbio/ws/client/AAConClient.java @@ -33,7 +33,9 @@ import java.io.IOException; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -42,7 +44,7 @@ import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebServiceException; -import compbio.data.msa.Annotation; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; @@ -102,7 +104,7 @@ public class AAConClient { File parametersFile = IOHelper.getFile(cmd, paramFile, true); String presetName = CmdHelper.getPresetName(cmd); - Annotation msaws = connect(); + SequenceAnnotation msaws = connect(); Preset preset = null; if (presetName != null) { preset = MetadataHelper.getPreset(msaws, presetName); @@ -113,7 +115,7 @@ public class AAConClient { customOptions = MetadataHelper.processParameters(prms, msaws.getRunnerOptions()); } - Set result = null; + Map> result = null; if (inputFile != null) { System.out.println("Calculating conservation..."); result = analize(inputFile, msaws, preset, customOptions); @@ -153,9 +155,14 @@ public class AAConClient { * @param result * the AACon scores to output */ - static void writeOut(OutputStream outStream, Set result) { + static void writeOut(OutputStream outStream, + Map> result) { try { - Score.write(result, outStream); + for (Map.Entry> entry : result + .entrySet()) { + System.out.println(">" + entry.getKey()); + Score.write(entry.getValue(), outStream); + } } catch (IOException e) { System.err .println("Problems writing output file! Stack trace is below: "); @@ -175,11 +182,12 @@ public class AAConClient { * Connects to a AACon web service by the host and the service name * * - * @return {@link Annotation} + * @return {@link AlignmentAnnotation} * @throws WebServiceException * if cannot connect to a web service */ - public static Annotation connect() throws WebServiceException { + public static SequenceAnnotation connect() + throws WebServiceException { URL url = null; log.log(Level.FINE, "Attempting to connect..."); try { @@ -193,8 +201,8 @@ public class AAConClient { QName portName = new QName(QUALIFIED_SERVICE_NAME, "AAConWS" + "Port"); @SuppressWarnings("unchecked") - Annotation serviceIF = serv - .getPort(portName, Annotation.class); + SequenceAnnotation serviceIF = serv.getPort(portName, + SequenceAnnotation.class); log.log(Level.FINE, "Connected successfully!"); return serviceIF; @@ -214,11 +222,12 @@ public class AAConClient { * @return Set the conservation scores * @throws UnknownFileFormatException */ - static Set analize(File file, Annotation wsproxy, - Preset preset, List> customOptions) { + static Map> analize(File file, + SequenceAnnotation wsproxy, Preset preset, + List> customOptions) { List fastalist = null; - Set scores = null; + Map> scores = null; try { fastalist = SequenceUtil.openInputStream(file.getAbsolutePath()); diff --git a/webservices/compbio/ws/client/IOHelper.java b/webservices/compbio/ws/client/IOHelper.java index 79357e5..414af9c 100644 --- a/webservices/compbio/ws/client/IOHelper.java +++ b/webservices/compbio/ws/client/IOHelper.java @@ -10,8 +10,9 @@ import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.Map; import compbio.data.sequence.Alignment; import compbio.data.sequence.ClustalAlignmentUtil; @@ -118,9 +119,13 @@ public class IOHelper { * @param result * the AACon scores to output */ - static void writeOut(OutputStream outStream, Set result) { + static void writeOut(OutputStream outStream, + Map> result) { try { - Score.write(result, outStream); + for (Map.Entry> entry : result.entrySet()) { + System.out.println(">" + entry.getKey()); + Score.write(entry.getValue(), outStream); + } } catch (IOException e) { System.err .println("Problems writing output file! Stack trace is below: "); diff --git a/webservices/compbio/ws/client/Jws2Client.java b/webservices/compbio/ws/client/Jws2Client.java index 1673e18..62aa383 100644 --- a/webservices/compbio/ws/client/Jws2Client.java +++ b/webservices/compbio/ws/client/Jws2Client.java @@ -37,18 +37,19 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; +import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.ws.Service; import javax.xml.ws.WebServiceException; -import compbio.data.msa.Annotation; import compbio.data.msa.JABAService; import compbio.data.msa.Metadata; import compbio.data.msa.MsaWS; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.Alignment; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; @@ -160,8 +161,8 @@ public class Jws2Client { outStream = System.out; } if (service == Services.AAConWS) { - Set result = analize(inputFile, ((Annotation) msaws), - preset, customOptions); + Map> result = analize(inputFile, + ((SequenceAnnotation) msaws), preset, customOptions); IOHelper.writeOut(outStream, result); } else { alignment = align(inputFile, (MsaWS) msaws, preset, @@ -202,11 +203,12 @@ public class Jws2Client { * @return Set the conservation scores * @throws UnknownFileFormatException */ - Set analize(File file, Annotation wsproxy, Preset preset, + Map> analize(File file, + SequenceAnnotation wsproxy, Preset preset, List> customOptions) { List fastalist = null; - Set scores = null; + Map> scores = null; try { fastalist = SequenceUtil.openInputStream(file.getAbsolutePath()); diff --git a/webservices/compbio/ws/client/Services.java b/webservices/compbio/ws/client/Services.java index 6734a36..f18eadf 100644 --- a/webservices/compbio/ws/client/Services.java +++ b/webservices/compbio/ws/client/Services.java @@ -23,9 +23,9 @@ import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; -import compbio.data.msa.Annotation; import compbio.data.msa.JABAService; import compbio.data.msa.MsaWS; +import compbio.data.msa.SequenceAnnotation; /** * List of web services currently supported by JABAWS version 2 @@ -70,7 +70,7 @@ public enum Services { switch (this) { case AAConWS : - return service.getPort(portName, Annotation.class); + return service.getPort(portName, SequenceAnnotation.class); // deliberate leaking case ClustalWS : diff --git a/webservices/compbio/ws/server/AAConWS.java b/webservices/compbio/ws/server/AAConWS.java index a32533f..433728b 100644 --- a/webservices/compbio/ws/server/AAConWS.java +++ b/webservices/compbio/ws/server/AAConWS.java @@ -2,6 +2,7 @@ package compbio.ws.server; import java.io.File; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -11,7 +12,7 @@ import javax.xml.ws.WebServiceContext; import org.apache.log4j.Logger; -import compbio.data.msa.Annotation; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; import compbio.engine.AsyncExecutor; @@ -33,8 +34,8 @@ import compbio.metadata.WrongParameterException; import compbio.runner.Util; import compbio.runner.conservation.AACon; -@WebService(endpointInterface = "compbio.data.msa.Annotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "AAConWS") -public class AAConWS implements Annotation { +@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "AAConWS") +public class AAConWS implements SequenceAnnotation { // Ask for resource injection @Resource @@ -58,15 +59,17 @@ public class AAConWS implements Annotation { } @Override - public HashSet getAnnotation(String jobId) + public HashMap> getAnnotation(String jobId) throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine .getResults(jobId); HashSet mas = aacon.getResults(); + HashMap> result = new HashMap>(); + result.put("Alignment", mas); log.trace(jobId + " getConservation : " + mas); - return mas; + return result; } /* * @SuppressWarnings("unchecked") public JalviewAnnotation diff --git a/webservices/compbio/ws/server/DisemblWS.java b/webservices/compbio/ws/server/DisemblWS.java new file mode 100644 index 0000000..00f3f69 --- /dev/null +++ b/webservices/compbio/ws/server/DisemblWS.java @@ -0,0 +1,157 @@ +package compbio.ws.server; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import javax.annotation.Resource; +import javax.jws.WebService; +import javax.xml.ws.WebServiceContext; + +import org.apache.log4j.Logger; + +import compbio.data.msa.SequenceAnnotation; +import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.Score; +import compbio.engine.AsyncExecutor; +import compbio.engine.Configurator; +import compbio.engine.client.ConfiguredExecutable; +import compbio.metadata.ChunkHolder; +import compbio.metadata.JobStatus; +import compbio.metadata.JobSubmissionException; +import compbio.metadata.Limit; +import compbio.metadata.LimitExceededException; +import compbio.metadata.LimitsManager; +import compbio.metadata.Option; +import compbio.metadata.Preset; +import compbio.metadata.PresetManager; +import compbio.metadata.ResultNotAvailableException; +import compbio.metadata.RunnerConfig; +import compbio.metadata.UnsupportedRuntimeException; +import compbio.metadata.WrongParameterException; +import compbio.runner.Util; +import compbio.runner.disorder.Disembl; + +@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "DisemblWS") +public class DisemblWS implements SequenceAnnotation { + + // Ask for resource injection + @Resource + WebServiceContext wsContext; + + private static Logger statLog = Logger.getLogger("DisemblWS-stats"); + + private static Logger log = Logger.getLogger(DisemblWS.class); + + private static final RunnerConfig disemblOptions = Util + .getSupportedOptions(Disembl.class); + + private static final PresetManager disemblPresets = Util + .getPresets(Disembl.class); + + ConfiguredExecutable init(List sequences) + throws JobSubmissionException { + Disembl disembl = new Disembl(); + disembl.setInput("fasta.in").setOutput("disembl.out"); + return Configurator.configureExecutable(disembl, sequences); + } + + @Override + public HashMap> getAnnotation(String jobId) + throws ResultNotAvailableException { + WSUtil.validateJobId(jobId); + AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); + ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine + .getResults(jobId); + HashMap> mas = aacon.getResults(); + log.trace(jobId + " getConservation : " + mas); + return mas; + } + + @Override + public Limit getLimit(String presetName) { + return new Disembl().getLimit(presetName); + } + + @Override + public LimitsManager getLimits() { + return new Disembl().getLimits(); + } + + @Override + public ChunkHolder pullExecStatistics(String jobId, long position) { + // Execution stat is not supported + return new ChunkHolder("", -1); + } + + @Override + public boolean cancelJob(String jobId) { + WSUtil.validateJobId(jobId); + return WSUtil.cancelJob(jobId); + } + + @Override + public JobStatus getJobStatus(String jobId) { + WSUtil.validateJobId(jobId); + return WSUtil.getJobStatus(jobId); + } + + @Override + public PresetManager getPresets() { + return disemblPresets; + } + + @Override + public RunnerConfig getRunnerOptions() { + return disemblOptions; + } + + String analize(List sequences, + ConfiguredExecutable confExec, Logger log, String method, + Limit limit) throws JobSubmissionException { + if (limit != null && limit.isExceeded(sequences)) { + throw LimitExceededException.newLimitExceeded(limit, sequences); + } + + compbio.runner.Util.writeInput(sequences, confExec); + AsyncExecutor engine = Configurator.getAsyncEngine(confExec); + String jobId = engine.submitJob(confExec); + return jobId; + } + + @Override + public String analize(List sequences) + throws UnsupportedRuntimeException, LimitExceededException, + JobSubmissionException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confDisembl = init(sequences); + + return analize(sequences, confDisembl, null, "analize", getLimit("")); + } + + /* + * No options are supported, thus the result of this call will be as simple + * call to analize without parameters + */ + @Override + public String customAnalize(List sequences, + List> options) throws UnsupportedRuntimeException, + LimitExceededException, JobSubmissionException, + WrongParameterException { + return analize(sequences); + } + + /* + * No presets are supported, thus the result of this call will be as simple + * call to analize without parameters + */ + @Override + public String presetAnalize(List sequences, + Preset preset) throws UnsupportedRuntimeException, + LimitExceededException, JobSubmissionException, + WrongParameterException { + + return analize(sequences); + } + +} diff --git a/webservices/compbio/ws/server/JronnWS.java b/webservices/compbio/ws/server/JronnWS.java index 9f5be63..13fe708 100644 --- a/webservices/compbio/ws/server/JronnWS.java +++ b/webservices/compbio/ws/server/JronnWS.java @@ -1,6 +1,7 @@ package compbio.ws.server; import java.io.File; +import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -10,7 +11,7 @@ import javax.xml.ws.WebServiceContext; import org.apache.log4j.Logger; -import compbio.data.msa.Annotation; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.Score; import compbio.engine.AsyncExecutor; @@ -33,8 +34,8 @@ import compbio.runner.Util; import compbio.runner.conservation.AACon; import compbio.runner.disorder.Jronn; -@WebService(endpointInterface = "compbio.data.msa.Annotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "JronnWS") -public class JronnWS implements Annotation { +@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "JronnWS") +public class JronnWS implements SequenceAnnotation { // Ask for resource injection @Resource @@ -44,27 +45,27 @@ public class JronnWS implements Annotation { private static Logger log = Logger.getLogger(JronnWS.class); - private static final RunnerConfig aaconOptions = Util + private static final RunnerConfig jronnOptions = Util .getSupportedOptions(Jronn.class); - private static final PresetManager aaconPresets = Util + private static final PresetManager jronnPresets = Util .getPresets(Jronn.class); ConfiguredExecutable init(List sequences) throws JobSubmissionException { Jronn jronn = new Jronn(); - jronn.setInput("fasta.in").setOutput("aacon.out"); + jronn.setInput("fasta.in").setOutput("jronn.out"); return Configurator.configureExecutable(jronn, sequences); } @Override - public HashSet getAnnotation(String jobId) + public HashMap> getAnnotation(String jobId) throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine + ConfiguredExecutable jronn = (ConfiguredExecutable) asyncEngine .getResults(jobId); - HashSet mas = aacon.getResults(); + HashMap> mas = jronn.getResults(); log.trace(jobId + " getConservation : " + mas); return mas; } @@ -101,12 +102,12 @@ public class JronnWS implements Annotation { @Override public PresetManager getPresets() { - return aaconPresets; + return jronnPresets; } @Override public RunnerConfig getRunnerOptions() { - return aaconOptions; + return jronnOptions; } String analize(List sequences, @@ -127,10 +128,9 @@ public class JronnWS implements Annotation { throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException { WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confAAcon = init(sequences); + ConfiguredExecutable confJronn = init(sequences); - // set default conservation method to fastest - SHENKIN - return analize(sequences, confAAcon, null, "analize", getLimit("")); + return analize(sequences, confJronn, null, "analize", getLimit("")); } @Override @@ -140,9 +140,7 @@ public class JronnWS implements Annotation { WrongParameterException { WSUtil.validateFastaInput(sequences); ConfiguredExecutable confJronn = init(sequences); - // Could not do that! Space separated values - // will all be treated as keys! thus duplicates removed - // String params = cbuilder.getCommand(); + List params = WSUtil.getCommands(options, AACon.KEY_VALUE_SEPARATOR); confJronn.addParameters(params); -- 1.7.10.2