def subscore(self, protein, aa, aa2, sec_struct_type, onlyone=False):
		tag1 = aacode(aa.type)
		tag2 = aacode(aa2.type)
		if tag1 >= AMINO_ACID_COUNT: tag1 = 0
		if tag2 >= AMINO_ACID_COUNT: tag2 = 0
		
		if self.refstate == True:
			zone1 = aa.tolocal(aa2.acarbon).floor()
			zone2 = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(sec_struct_type, (zone1, zone2))
			if subscore == 0:
				if consec == 0:	subscore = 1e-3
				else:			subscore = 1e-2
			subscore = -math.log((subscore / self.total_interactions[sec_struct_type]) / reference_state.position_ref(zone2))
			if onlyone:
				print subscore
				return (subscore * self.weight, subscore * self.weight, self.total_interactions[sec_struct_type], self.total_interactions[sec_struct_type])
			return subscore
		else:
			zone1 = aa.tolocal(aa2.acarbon).floor()
			zone2 = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(sec_struct_type, (zone1, zone2))
			if subscore == 0:
				if consec == 0:	subscore = 1e-3
				else:			subscore = 1e-2
			subscore = -math.log(subscore / self.median_frequencies[sec_struct_type] * self.total_interactions[sec_struct_type] / self.total_median)
			if onlyone:
				print subscore
				return (subscore * self.weight, subscore * self.weight, self.total_interactions[sec_struct_type], self.total_interactions[sec_struct_type])
			return subscore
	def subscore(self, protein, aa, aa2, onlyone=False, consec=2, zero_value=0.01):
		tag1 = aacode(aa.type)
		tag2 = aacode(aa2.type)
		if tag1 >= AMINO_ACID_COUNT: tag1 = 0
		if tag2 >= AMINO_ACID_COUNT: tag2 = 0
		
		if self.refstate:
			zone = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(tag2, tag1, zone)
			if subscore == 0:
				subscore = zero_value
			zone = aa.tolocal(aa2.acarbon).floor()
			subscore2 = self.alpha_frequency(tag1, tag2, zone)
			if subscore2 == 0:
				subscore2 = zero_value
			if onlyone:
				print subscore, subscore2
				return (subscore * self.weight, subscore2 * self.weight, self.total_interactions[tag1][tag2], self.total_interactions[tag2][tag1])
			vol = protein.volume()
			contact_type = 2
			if self.short_range: contact_type = 1
			elif consec == 1: contact_type = 0
			return -math.log(((subscore * subscore2) / (self.total_interactions[tag1][tag2] ** 2)) * reference_state.contact_probability(tag1, tag2, vol, contact_type) / (4000.0 * math.pi / (3 * vol) * reference_state.position_ref(zone)))
			#return -math.log((subscore * subscore2 / (self.total_interactions[tag2][tag1] ** 2)) / reference_state.position_ref(zone))
		else:
			zone = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(tag2, tag1, zone)
			if subscore == 0:
				subscore = zero_value
			subscore = -math.log(subscore / self.median_frequencies[tag2][tag1] * self.total_interactions[tag2][tag1] / self.total_median)
			zone2 = aa.tolocal(aa2.acarbon).floor()
			subscore2 = self.alpha_frequency(tag1, tag2, zone2)
			if subscore2 == 0:
				subscore2 = zero_value
			subscore2 = -math.log(subscore2 / self.median_frequencies[tag1][tag2] * self.total_interactions[tag1][tag2] / self.total_median)
			if onlyone:
				print subscore, subscore2
				return (subscore * self.weight, subscore2 * self.weight, self.total_interactions[tag1][tag2], self.total_interactions[tag2][tag1])
			return subscore + subscore2
	def subscore(self, protein, aa, aa2, onlyone=False, consec=2, zero_value=0.01):
		tag1 = aacode(aa.type)
		tag2 = aacode(aa2.type)
		if tag1 >= AMINO_ACID_COUNT: tag1 = 0
		if tag2 >= AMINO_ACID_COUNT: tag2 = 0
		
		#Switch the amino acids around
		if tag1 > tag2 or (tag1 == tag2 and aa.tag > aa2.tag):
			cache = aa
			aa = aa2
			aa2 = cache
			cache = tag1
			tag1 = tag2
			tag2 = cache
		
		if self.refstate:
			zone1 = aa.tolocal(aa2.acarbon).floor()
			zone2 = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(tag1, tag2, (zone1, zone2))
			if subscore == 0:
				subscore = zero_value
			if onlyone:
				print subscore
				return (subscore * self.weight, subscore * self.weight, self.total_interactions[tag1][tag2], self.total_interactions[tag2][tag1])
			vol = protein.volume()
			contact_type = 2
			if self.short_range: contact_type = 1
			elif consec == 1: contact_type = 0
			return -math.log((subscore / self.total_interactions[tag1][tag2]) * reference_state.contact_probability(tag1, tag2, vol, contact_type) / (4000.0 * math.pi / (3 * vol) * reference_state.position_ref(zone2)))
			#return -math.log((subscore / (self.total_interactions[tag1][tag2])) / reference_state.position_ref(zone2))
		else:
			zone1 = aa.tolocal(aa2.acarbon).floor()
			zone2 = aa2.tolocal(aa.acarbon).floor()
			subscore = self.alpha_frequency(tag2, tag1, (zone1, zone2))
			if subscore == 0:
				subscore = zero_value
			subscore = -math.log(subscore / self.median_frequencies[tag2][tag1] * self.total_interactions[tag2][tag1] / self.total_median)
			if onlyone:
				print subscore
				return (subscore * self.weight, self.total_interactions[tag1][tag2], self.total_interactions[tag2][tag1])
			return subscore