def sequenceDatabaseDownloadStep(self, sequenceDB): """Download UniProt/GeneBank sequence from its respective database """ # sequenceDB = str(sequenceDB) if self.uniProtSequence.get() is not None: seqHandler = emconv.SequenceHandler() elif self._getGeneBankID() is not None: seqHandler = emconv.SequenceHandler(isAminoacid=False) seqDic, error = seqHandler.downloadSeqFromDatabase(sequenceDB) if seqDic is None: print("Error: ", error) self.setAborted() exit(0) if self.inputSequenceID.get() is not None: self.id = self.inputSequenceID.get() elif sequenceDB != '': self.id = sequenceDB else: self.id = self.name if seqDic['description'] != '': self.description = seqDic['description'] self.sequence = seqDic['sequence'] self.alphabet = emconv.alphabetToIndex( self.inputSequence == emconv.SEQ_TYPE_AMINOACIDS, seqDic['alphabet'])
def fileDownloadStep(self, sequenceFile): # If sequencePath contains more than one sequence, only # the first one will be considered seqHandler = emconv.SequenceHandler() seqDic = seqHandler.readSequenceFromFile(sequenceFile, type="fasta") if self.inputSequenceID.get() is not None: self.id = self.inputSequenceID.get() elif seqDic['seqID'] != '': self.id = seqDic['seqID'] else: self.id = self.name if seqDic['description'] != '': self.description = seqDic['description'] self.sequence = seqDic['sequence'] self.alphabet = emconv.alphabetToIndex( self.inputSequence == emconv.SEQ_TYPE_AMINOACIDS, seqDic['alphabet'])
def fileDownloadStep(self, sequenceFile): # If sequencePath contains more than one sequence, only # the first one will be considered seqHandler = emconv.SequenceHandler() record = seqHandler.downloadSeqFromFile(sequenceFile, type="fasta") if self.inputSequenceID.get() is not None: self.id = self.inputSequenceID.get() elif record.id != '': self.id = record.id else: self.id = self.name if record.description != '': self.description = record.description self.sequence = str(record.seq) self.alphabet = emconv.alphabetToIndex(self.inputSequence == emconv.SEQ_TYPE_AMINOACIDS, record.seq.alphabet)
def getSequenceOfChainStep(self, chainId): # sequece is obtained from PDB file # form has a wizard that creates label with the format # [model: x, chain: x, xxx residues] import json chainIdDict = json.loads(self.inputStructureChain.get()) selectedModel = chainIdDict['model'] selectedChain = chainIdDict['chain'] self.structureHandler = AtomicStructHandler() if self.pdbId.get() is not None: # PDB from remote database pdbID = self.pdbId.get() tmpFilePath = os.path.join("/tmp", pdbID + ".cif").lower() if exists(tmpFilePath): # wizard already downloaded the file self.structureHandler.read(tmpFilePath) else: # wizard has not used and the file has not been downloaded yet self.structureHandler.readFromPDBDatabase(pdbID, dir="/tmp") else: # PDB from file self.structureHandler.read(self.pdbFile.get()) _sequence = self.structureHandler.getSequenceFromChain( selectedModel, selectedChain) self.sequence = str(_sequence) self.alphabet = emconv.alphabetToIndex(self.inputSequence == emconv.SEQ_TYPE_AMINOACIDS, _sequence.alphabet) # Assignation of sequence ID: if the user has provided a specific # ID, this will be adopted by default; otherwise, a sequence ID # related with the starting structure will be selected. if self.inputSequenceID.get() is not None: self.id = self.inputSequenceID.get() else: self.id = self.structureHandler.getFullID( selectedModel, selectedChain) print("Selected chain: %s from model: %s from structure: %s" % (selectedChain, selectedModel, self.structureHandler.structure.get_id()))