def prepare(self): """ If the target is a PDBModel its sequence will be written to disc as a fasta file. If it is already fasta file the path to the file will be passed on. """ try: ## if target is a PDBModel or simple sequence string if isinstance(self.target, PDBModel): fastaSeq, self.fastaID = MT.fasta(self.target) ## write fasta sequence file seq = open(self.f_in, 'w') seq.write(fastaSeq) seq.close() elif self.__verify_fasta(self.target): if type(self.target) is list: seq = open(self.f_in, 'w') seq.writelines(self.target) seq.close() else: ## else assume it is a fasta sequence file self.f_in = self.target else: raise HmmerError, 'cannot interpret target %r' % self.target except OSError, why: msg = 'Cannot write temporary fasta file %s' % self.f_in msg += '\nError: %r' % why raise HmmerError, msg
def prepare( self ): """ If the target is a PDBModel its sequence will be written to disc as a fasta file. If it is already fasta file the path to the file will be passed on. """ try: ## if target is a PDBModel or simple sequence string if isinstance(self.target, PDBModel): fastaSeq, self.fastaID = MT.fasta( self.target ) ## write fasta sequence file seq = open( self.f_in, 'w' ) seq.write( fastaSeq ) seq.close() elif self.__verify_fasta(self.target): if type(self.target) is list: seq = open( self.f_in, 'w' ) seq.writelines( self.target ) seq.close() else: ## else assume it is a fasta sequence file self.f_in = self.target else: raise HmmerError, 'cannot interpret target %r' % self.target except OSError, why: msg = 'Cannot write temporary fasta file %s' % self.f_in msg += '\nError: %r' % why raise HmmerError, msg
def prepare( self ): """ If the target id a PDBModel its sequence will be written to disc as a fasta file. If it is a fasta file the path to the file will be passed on. """ ## if target is a PDBModel if isinstance( self.target, PDBModel): fastaSeq, self.fastaID = MT.fasta( self.target ) ## write fasta sequence file seq = open( self.fName, 'w' ) seq.write( fastaSeq ) seq.close() ## else assume it is a fasta sequence file else: if self.__verify_fasta(self.target): self.fName = self.target
def align(self, model, hits): """ Performs alignment If there is more than one hit with the profile, the sequence will be subdevided and the alignment will be performed on each part. a final merger profile for the profile will be returned. @param model: structure model @type model: PDBModel @param hits: list with matching sections from L{searchHmmdb} @type hits: [[int,int]] @return: fastaSeq hmmSeq repete hmmGap:: fastaSeq - sequence hmmSeq - matching positions in profile repete - number of repetes of the profile hmmGap - list with gaps (deletions in search sequence) for each repete @rtype: str, str, int, [int] """ try: fastaSeq, self.fastaID = MT.fasta(model) fastaSeq = fastaSeq.split()[1] l = len(fastaSeq) ## sub sequence alignment j = 0 repete = 0 hmmGap = [] for h in hits: start = h[0] - 1 stop = h[1] sub_fastaSeq, self.fastaID = MT.fasta(model, start, stop) ## write sub-fasta sequence file fName = self.sub_fastaFile sub_seq = open(fName, 'w') sub_seq.write(sub_fastaSeq) sub_seq.close() ## get sub-alignmnet align = HmmerAlign(self.hmmFile, self.sub_fastaFile, self.fastaID, verbose=self.verbose, log=self.log) sub_fastaSeq, sub_hmmSeq = align.run() ## remove positions corresponding to insertions in ## search sequence sub_fastaSeq, sub_hmmSeq, del_hmm = \ self.removeGapInSeq( sub_fastaSeq, sub_hmmSeq ) hmmGap += [del_hmm] ## rebuild full lenght hmmSeq from sub_hmmSeq sub_hmmSeq = '.' * start + sub_hmmSeq + '.' * (l - stop) if j == 0: hmmSeq = sub_hmmSeq if j != 0: hmmSeq = self.mergeHmmSeq(hmmSeq, sub_hmmSeq) j += 1 repete += 1 return fastaSeq, hmmSeq, repete, hmmGap except IOError, e: raise HmmerError, "Error creating temporary file %r. "%e.filename+\ "Check that Biskit.settings.temDirShared is accessible!\n"+\ "See also .biskit/settings.cfg!"
def align( self, model, hits ): """ Performs alignment If there is more than one hit with the profile, the sequence will be subdevided and the alignment will be performed on each part. a final merger profile for the profile will be returned. @param model: structure model @type model: PDBModel @param hits: list with matching sections from L{searchHmmdb} @type hits: [[int,int]] @return: fastaSeq hmmSeq repete hmmGap:: fastaSeq - sequence hmmSeq - matching positions in profile repete - number of repetes of the profile hmmGap - list with gaps (deletions in search sequence) for each repete @rtype: str, str, int, [int] """ try: fastaSeq, self.fastaID = MT.fasta( model ) fastaSeq = fastaSeq.split()[1] l = len(fastaSeq) ## sub sequence alignment j = 0 repete = 0 hmmGap = [] for h in hits: start = h[0]-1 stop = h[1] sub_fastaSeq, self.fastaID = MT.fasta( model, start, stop ) ## write sub-fasta sequence file fName = self.sub_fastaFile sub_seq = open( fName, 'w' ) sub_seq.write( sub_fastaSeq ) sub_seq.close() ## get sub-alignmnet align = HmmerAlign( self.hmmFile, self.sub_fastaFile, self.fastaID, verbose=self.verbose, log=self.log) sub_fastaSeq, sub_hmmSeq = align.run() ## remove positions corresponding to insertions in ## search sequence sub_fastaSeq, sub_hmmSeq, del_hmm = \ self.removeGapInSeq( sub_fastaSeq, sub_hmmSeq ) hmmGap += [ del_hmm ] ## rebuild full lenght hmmSeq from sub_hmmSeq sub_hmmSeq = '.'*start + sub_hmmSeq + '.'*(l-stop) if j == 0: hmmSeq = sub_hmmSeq if j != 0: hmmSeq = self.mergeHmmSeq( hmmSeq, sub_hmmSeq ) j+= 1 repete += 1 return fastaSeq, hmmSeq, repete, hmmGap except IOError, e: raise HmmerError, "Error creating temporary file %r. "%e.filename+\ "Check that Biskit.settings.temDirShared is accessible!\n"+\ "See also .biskit/settings.cfg!"