예제 #1
0
def parse_outfiles(pathfile):
    complexes = {}

    for line in open(pathfile):
        words = line.strip().split()
        if not len(words) == 2:
            logging.warning('skipping non-conforming line: %s' % line)
            continue
        complex, path = words

        print path
        if not complexes.has_key(complex): complexes[complex] = {}

        scandna = re_scandna.search(open(path).read())
        if scandna:
            chain, pos, type = re_scandna.search(open(path).read()).groups()
        else:
            chain, pos, type = ['NA', '0', 'NA']
        DNApos = '%s.%s.%s' % (chain, pos, type)
        print DNApos

        if debugoutput: print complex, DNApos
        if not complexes[complex].has_key(DNApos):
            complexes[complex][DNApos] = {}

        for line in open(path):
            line = line.strip()
            #match = re_substitution_new.match(line)
            #if match:
            #	aa, chainpos, nataa, bound, binding, specbound, specbinding = match.groups()
            match = re_subs_2012.match(line)
            if match:
                aa, chain, pos, nataa, bound, binding, specbound, specbinding = match.groups(
                )
                aa = get_oneletter(aa)
                nataa = get_oneletter(nataa)
                if debugoutput:
                    print aa, chain, pos, nataa
                chainpos = '%s.%s' % (chain, pos)
                if not complexes[complex][DNApos].has_key(chainpos):
                    complexes[complex][DNApos][chainpos] = Position(nataa)

                complexes[ complex ][ DNApos ][ chainpos ].append( \
                 Substitution( aa, bound, binding, specbound, specbinding ) )
    return complexes
def parse_outfiles(pathfile):
	complexes = {}

	for line in open(pathfile):
		words = line.strip().split()
		if not len(words) == 2:
			logging.warning('skipping non-conforming line: %s' %line)
			continue
		complex,path = words

		print path
		if not complexes.has_key( complex ): complexes[ complex ] = {}

		scandna = re_scandna.search( open(path).read() )
		if scandna:
			chain,pos,type = re_scandna.search( open(path).read() ).groups()
		else:
			chain,pos,type = ['NA','0','NA']
		DNApos = '%s.%s.%s' %(chain,pos,type)
		print DNApos

		if debugoutput: print complex, DNApos
		if not complexes[ complex ].has_key( DNApos ): complexes[ complex ][ DNApos ] = {}

		for line in open(path):
			line = line.strip()
			#match = re_substitution_new.match(line)
			#if match:
			#	aa, chainpos, nataa, bound, binding, specbound, specbinding = match.groups()
			match = re_subs_2012.match(line)
			if match:
				aa, chain, pos, nataa, bound, binding, specbound, specbinding = match.groups()
				aa = get_oneletter(aa)
				nataa = get_oneletter(nataa)
				if debugoutput:
					print aa, chain, pos, nataa
				chainpos = '%s.%s' %(chain,pos)
				if not complexes[ complex ][ DNApos ].has_key(chainpos):
					complexes[ complex ][ DNApos ][ chainpos ] = Position(nataa)

				complexes[ complex ][ DNApos ][ chainpos ].append( \
					Substitution( aa, bound, binding, specbound, specbinding ) )
	return complexes
예제 #3
0
 def dna(self):
     os = ['> %s\n' % self.filename]
     keys = self.residues.keys()
     keys.sort()
     for chainpos in keys:
         res = self.residues[chainpos]
         if not res.type in nucleic_acids: continue
         letter = get_oneletter(res.type)
         os.append(letter)
     os.append('\n')
     return string.join(os, '')
예제 #4
0
	def dna(self):
		os = ['> %s\n' %self.filename]
		keys = self.residues.keys()
		keys.sort()
		for chainpos in keys:
			res = self.residues[chainpos]
			if not res.type in nucleic_acids: continue
			letter = get_oneletter(res.type)
			os.append(letter)
		os.append('\n')
		return string.join( os, '' )
예제 #5
0
 def fasta(self):
     os = ['> %s\n' % self.filename]
     # note: self.residues is indexed by instances of ChainPos
     keys = self.residues.keys()
     keys.sort()  # ChainPos knows how to sort itself
     for chainpos in keys:
         res = self.residues[chainpos]
         # skip DNA
         if res.type in nucleic_acids: continue
         letter = get_oneletter(res.type)
         os.append(letter)
     os.append('\n')
     return string.join(os, '')
예제 #6
0
	def fasta( self ):
		os = ['> %s\n' %self.filename]
		# note: self.residues is indexed by instances of ChainPos
		keys = self.residues.keys()
		keys.sort() # ChainPos knows how to sort itself
		for chainpos in keys:
			res = self.residues[chainpos]
			# skip DNA
			if res.type in nucleic_acids: continue
			letter = get_oneletter(res.type)
			os.append(letter)
		os.append('\n')
		return string.join( os, '' )