コード例 #1
0
def makeDNASpecCompliant(sDNASeq, lFeatureMap, lDNASpec, dCFSeqs, bVerbose=True, bCheckOnly=False, dInsertIntoAndVerityOtherMaps=None):
	# Redefine print function to adheal to verbose printing (voodoo magic)
	print = genPrintFunc(bVerbose)
	
	# First check DNA
	print('Verifying DNA Sequence:')
	tVerResult = verifyDNASpecCompliance(sDNASeq, lFeatureMap, lDNASpec, dCFSeqs, bVerbose)
	
	# What to do
	if not tVerResult[1]: # If it cannot be mutated to create valid match its invalid and return None
		print('DNA sequence cannot be mutated to create valid sequence! - Returning None')
		return None, None
	elif tVerResult[0]: # DNA seq is valid
		
#		# PLACEHOLDER/ NOT CURRENTLY USED Function to insert this into aditional feature specifications and verify those too
#		def verifyAgainsAditionalMaps(sDNASeq, lFeatureMap, lDNASpec, dInsertIntoAndVerityOtherMaps, dCFSeqs, bVerbose=True):
#			lStaticFeatureMap = list(lDNASpec)
#			# First make a static DNA specification of using the iserted sequence
#			for iIndex, tRegion in enumerate(lFeatureMap):
#				lStaticFeatureMap[iIndex]['seq'] = sDNASeq[tRegion[0]:tRegion[1]]
		
		sDNASeqRevComp = getReverseComplement(sDNASeq)
		lRevFeatureMap = reverseFeatureMap(lFeatureMap)
		print('Verifying DNA Sequence Reverse Complement:')
		tRevCompVerResult = verifyDNASpecCompliance(sDNASeqRevComp, lRevFeatureMap, lDNASpec, dCFSeqs, bVerbose)
		if not tRevCompVerResult[1]: # If the reverse complement cannot be mutated to create valid match its invalid and return None
			print('DNA sequence reverse complement cannot be mutated to create valid sequence! - Returning None')
			return None, None
		elif tRevCompVerResult[0]: # DNA reverse complement is valid
			print('DNA sequence and its reverse complement are bought valid! - Returning Sequence')
			return sDNASeq, lFeatureMap # DNA sequence and its reverse compliment are valid thus return the sequence
	
	# So if it doesnt return anything either the DNA sequence or its reverse complement where invalid but can be mutated to get a valid result
	print('DNA sequence and/or its reverse complement are/is invalid but are bought mutable!', end='')
	if bCheckOnly:
		print(' - Returning None')
		return None, None
	print(' - Mutating Sequence')
	sDNASeq, lFeatureMap = genSpecDNA(lDNASpec) # Thus generate another version of the dna
	sDNASeq, lFeatureMap = makeDNASpecCompliant(sDNASeq, lFeatureMap, lDNASpec, dCFSeqs, bVerbose) # And try to make it compliant agan (gottal love recusion)
	return sDNASeq, lFeatureMap
		},
		{	'name'		: 'Memory-ScaI',
			'seq'		: 'AGTACT',
			'mutable'	: False,
			'maycontain': 
			[
				'Memory-ScaI'
			]
		},
		{	'name'		: 'DNARand-25',
			'seq'		: genRandomDNAFunction(25),
			'mutable'	: True,
			'maycontain': []
		},
		{	'name'		: 'ZifBindingMotif-E2C-RC',
			'seq'		: getReverseComplement('GGGGCCGGAGCCGCAGTG'),
			'mutable'	: False,
			'maycontain': 
			[
				'Zif-E2C'
			]
		},
		{	'name'		: 'DNARand-125',
			'seq'		: genRandomDNAFunction(125),
			'mutable'	: True,
			'maycontain': []
		},
		{	'name'		: 'NdeI',
			'seq'		: 'CATATG',
			'mutable'	: False,
			'maycontain': 
		},
		{	'name'		: 'Memory-ScaI',
			'seq'		: 'AGTACT',
			'mutable'	: False,
			'maycontain': 
			[
				'Memory-ScaI'
			]
		},
		{	'name'		: 'DNARand-25',
			'seq'		: genRandomDNAFunction(25),
			'mutable'	: True,
			'maycontain': []
		},
		{	'name'		: 'ZifBindingMotif-PTF-RC',
			'seq'		: getReverseComplement('ATCGGCGCCGGCGACATC'),
			'mutable'	: False,
			'maycontain': 
			[
				'Zif-PTF'
			]
		},
		{	'name'		: 'DNARand-125',
			'seq'		: genRandomDNAFunction(125),
			'mutable'	: True,
			'maycontain': []
		},
		{	'name'		: 'NdeI',
			'seq'		: 'CATATG',
			'mutable'	: False,
			'maycontain':