コード例 #1
0
ファイル: GorIV_bx_WS.py プロジェクト: jexhson/gbiows
 def __init__(self):
     self.abs_path = realpath('%s/../' % dirname(__file__))
     self.app_name = 'gorIV'
     self.app_path = 'gorIV'
     self.app_title = basename(__file__).replace('_bx_WS.py', '')
     self.wsdl = '%s/wsdl/GorIV_bx.wsdl' % self.abs_path
     CommonService.__init__(self)
     GorIV.__init__(self)
コード例 #2
0
ファイル: GorIV_bx_WS.py プロジェクト: jexhson/gbiows
 def soap_submitGorIV(self, ps, **kw):
     request, response = GorIV.soap_submitGorIV(self, ps, **kw)
     self.job_id = str(uuid1())
     self.initJob()
     self.app_args = ['-prd',  self.input_file, '-seq', '/usr/share/gorIV/DATABASE/New_KS.267.seq',
         '-obs', '/usr/share/gorIV/DATABASE/New_KS.267.obs', '-pro', self.output_file, '>', self.log_file]
     self.submit()
     save_sequence = SequenceRecord()
     save_sequence.sequence = str(request.get_element_sequence())
     save_sequence.customName = str(request.get_element_customName())
     save_sequence.customNote = str(request.get_element_customNote())
     formalReference = request.get_element_formalReference()    
     if formalReference is not None:
         save_sequence.formalReference_accession = str(formalReference.get_element_accession())
     sequenceFile = '>1 %s %s\n%s\n' %  (save_sequence.formalReference_accession or '<None',
         save_sequence.customName, save_sequence.sequence)
    # TODO: Return SOAP fault
     if not s3uploadContents(self.job_id, 'sequence.pick', dumps(save_sequence)):
         response.set_element_jobId('error')
     elif not s3uploadContents(self.job_id, self.input_file, sequenceFile):
         response.set_element_jobId('error')
     else:
         response.set_element_jobId(self.job_id)
     return request, response
コード例 #3
0
ファイル: GorIV_bx_WS.py プロジェクト: jexhson/gbiows
 def soap_getResultsGorIV(self, ps, **kw):
     request, response = GorIV.soap_getResultsGorIV(self, ps, **kw)
     self.job_id = request.get_element_jobId()
     if check_jobid(self.job_id) == 1:
         # Return a soap fault!
         return request, response
     if self.check_status() != 'done':
         # Return a soap fault!
         return request, response
     self.initIOFile()
     secondaryStructure = response.new_secondaryStructure()
     # Sequence record
     seqDump = s3retrieveContents(self.job_id, 'sequence.pick')
     # TODO: Return SOAP fault if seqDump == ''
     sequence = loads(seqDump)
     sequenceRecord = secondaryStructure.new_sequenceRecord()
     sequenceRecord.set_element_sequence(sequence.sequence)
     if sequence.customName != 'None':
         sequenceRecord.set_element_customName(sequence.customName)
     if sequence.customNote != 'None':
         sequenceRecord.set_element_customNote(sequence.customNote)
     ## FormalReference
     if sequence.formalReference_accession != 'None':
         formalReference = sequenceRecord.new_formalReference()
         formalReference.set_element_accession(sequence.formalReference_accession)
         sequenceRecord.set_element_formalReference(formalReference)
     secondaryStructure.set_element_sequenceRecord(sequenceRecord)
     # Method
     method = secondaryStructure.new_method()
     method.set_attribute_localId('%s%s' % (datetime.now().strftime('%Y-%m-%d'), self.app_title))
     method.set_element_name(self.app_title)
     method.set_element_uri('%s%s/' % (SITE_URL, self.app_title))
     method.set_element_version('0.2')
     method.set_element_date(time())
     ## WebservicReference
     webserviceReference = method.new_webserviceReference()
     webserviceReference.set_element_wsdl('%s%s/wsdl/' % (SITE_URL, self.app_title))
     method.set_element_webserviceReference(webserviceReference)
     secondaryStructure.set_element_method([method])
     # Anotation
     idx = 0
     previous_prd = None
     annotation = None
     occurence_list = []
     annotation_list = []
     gorIVoutfile = s3retrieveContents(self.job_id, self.output_file)
     lines = gorIVoutfile.split('\n')
     for i in lines[5:]:
         if len(i) == 0:
             continue
         _, seq, _, _, prd, _, h, e, c = i.split(' ')
         idx+=1
         if prd != previous_prd:
             previous_prd = prd
             if len(occurence_list) > 0:
                 annotation.set_element_occurence(occurence_list)
                 occurence_list = []
                 annotation_list.append(annotation)
             annotation = secondaryStructure.new_annotation()
             ## Feature
             feature = annotation.new_feature()
             feature.set_element_name(prd)
             annotation.set_element_feature(feature)
         ## Occurence
         occurence = annotation.new_occurence()
         ### Position
         position = occurence.new_position()
         position.set_element_point(idx)
         occurence.set_element_position(position)
         ### Evidence
         evidence = occurence.new_evidence()
         #### Predicted
         predicted = evidence.new_predicted()
         score_list = []
         predicted.set_element_methodId('%s%s' % (datetime.now().strftime('%Y-%m-%d'), self.app_title))
         for t, v in (('H', h), ('E', e), ('C', c)):
             score = predicted.new_score()
             score.set_element_type(t)
             score.set_element_value(float(v))
             score_list.append(score)
         predicted.set_element_score(score_list)
         if h > e and h > c:
             verdict = 'H'
         elif e > h and e > c:
             verdict = 'E'
         else:
             verdict = 'C'
         predicted.set_element_verdict(verdict)
         evidence.set_element_predicted(predicted)
         occurence.set_element_evidence([evidence,])
         occurence_list.append(occurence)
     secondaryStructure.set_element_annotation(annotation_list)
     response.set_element_secondaryStructure(secondaryStructure)
     response.set_element_logout(s3retrieveContents(self.job_id, self.log_file))
     return request, response    
コード例 #4
0
ファイル: GorIV_bx_WS.py プロジェクト: jexhson/gbiows
 def soap_cancelGorIV(self, ps, **kw):
     request, response = GorIV.soap_cancelGorIV(self, ps, **kw)
     self.job_id = request.get_element_jobId()
     response.set_element_status(self.cancel())
     return request, response