Spaces:
Runtime error
Runtime error
Kevin Louis commited on
Commit ·
2c8f0e3
1
Parent(s): 14066c2
app main files
Browse filesFiles changed (7)
- CTS_user_log.csvAdded+43
- DNAseq.pyAdded+119
- code_function_mapping.csvAdded+10
- helper.pyAdded+34
- parameter_extractor.pyAdded+23
- ref_query_db_indexAdded
- reference_query_db.jsonAdded
12345678910111213141516171819202122232425262728293031323334353637383940414243user_query,ref_question,query_score,code_executed,ref_question_2,query_score_2,ref_question_3,query_score_3,similarity_metric,model_used_for_embeddings,lower_threshold,upper_threshold,date,time,response
How many bases are there in the sequence,How many bases are there in the sequence,1.06480165e-20,a2,How many bases does the sequence have,0.032355085,How many bases does the sequence have,0.032355085,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:21:36,930
there are cats and two dogs,How many bases are there,1.6690745,a2,What is the number of bases,1.6727788,What is the number of bases,1.6727788,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:25:06,Your Query Wasn't Understood. Can You Rephrase The Query
What is the base at position 78,What is the base at position/site 5 and 50,0.48746616,b1,What is the base at position/site 5,0.51927286,What is the base at position/site 5,0.51927286,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:31:04,c
What is the base at position 0,What is the base at position/site 5,0.5530416,b1,What are the bases from/between position 10 to/and 20?,0.6031008,What are the bases from/between position 10 to/and 20?,0.6031008,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:31:09,Position is out of range. Positions should be 1 - 930
What is the base at position 1000,What is the base at position/site 5 and 50,0.48386246,b1,"What is the base at position/site 5, 50, 515, 1568, 34578",0.49479663,"What is the base at position/site 5, 50, 515, 1568, 34578",0.49479663,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:31:38,Position is out of range. Positions should be 1 - 930
What are the bases from position 5 to 90,What are the bases from/between position 10 to/and 20?,0.24776845,b3,how many bases are there from positions 5 to/and 9,0.32962877,how many bases are there from positions 5 to/and 9,0.32962877,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:42:59,"ttgaggagaccattgacaccgtcattagcaatgcactacaactgtcacaacctaaaccgcagaaacaactcacggcccaatcgac"
How many are there from position 5 to 90,how many bases are there from positions 5 to/and 9,0.81035805,b2,how many bases are there between position 5 to/and 9,0.81407386,how many bases are there between position 5 to/and 9,0.81407386,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:43:26,86
what is the base at site 7 8 and 21,What is the base at position/site 34578,0.5133599,b1,What is the base at position/site 15,0.51463896,What is the base at position/site 15,0.51463896,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,10:48:34,g
What is the base at site 789,What is the base at position/site 1568,0.6266778,b1,What is the base at position/site 34578,0.6326653,What is the base at position/site 34578,0.6326653,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:09:15,a
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:10:19,930
How many bases are there,How many bases are there,7.908044e-21,a2,What is the number of bases,0.18966407,What is the number of bases,0.18966407,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:38:25,20
What is the base at site 5,What is the base at position/site 5,0.2645588,b1,What is the base at position/site 515,0.3784331,What is the base at position/site 515,0.3784331,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:46:46,t
What is the base at site 6,What is the base at position/site 5,0.49194798,b1,What is the base at position/site 515,0.53231597,What is the base at position/site 515,0.53231597,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:48:47,t
How many bases are in the sequence,How many bases are there in the sequence,0.0076738065,a2,How many bases does the sequence have,0.03213788,How many bases does the sequence have,0.03213788,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:49:22,15
Is there a pig on the plane,What is the amino acid count in the sequence,1.7117482,a1,What is the number of amino acids in the sequence,1.7167848,What is the number of amino acids in the sequence,1.7167848,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:49:54,Your Query Wasn't Understood. Can You Rephrase The Query
How many thymine,How many thymine t are there?,0.26310813,a6,What is the number of thymine t?,0.34814063,What is the number of thymine t?,0.34814063,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:50:27,5
how many guanines are there,How many guanines g are there?,0.30252665,a3,What is the number of guanines g?,0.41288453,What is the number of guanines g?,0.41288453,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,11:56:27,6
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:19:13,60
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:26:05,60
How many guanines bases are there in the sequence,How many guanines g does the sequence have?,0.3019901,a3,How many guanines g are there in the sequence?,0.3040974,How many guanines g are there in the sequence?,0.3040974,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:26:11,11
What is the base at position 10,What is the base at position/site 5,0.4366287,b1,What is the base at position/site 5 and 50,0.4367645,What is the base at position/site 5 and 50,0.4367645,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:26:20,g
What are the bases from position 2 to 10,What are the bases from/between position 10 to/and 20?,0.1379996,b3,how many bases are there from positions 5 to/and 9,0.28074524,how many bases are there from positions 5 to/and 9,0.28074524,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:26:29,gcattgagg
How many bases are there from position 2 to 10,how many bases are there between position 5 to/and 9,0.1829868,b2,how many bases are there from positions 5 to/and 9,0.18728873,how many bases are there from positions 5 to/and 9,0.18728873,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:26:40,9
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:27:21,60
What is the length,What is the length of the DNA ,0.86588484,a2,What is the length of the sequence,0.8859824,What is the length of the sequence,0.8859824,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:32:32,0
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:35:44,0
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:35:54,0
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:41:09,60
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:46:29,0
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:51:46,0
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:51:57,0
,What is the quantiy of amino acids in the sequence,1.7896336,a1,What is the base at position/site 15,1.8019854,What is the base at position/site 15,1.8019854,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:52:06,Your Query Wasn't Understood. Can You Rephrase The Query
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:53:57,0
,What is the quantiy of amino acids in the sequence,1.7896336,a1,What is the base at position/site 15,1.8019854,What is the base at position/site 15,1.8019854,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,12:54:09,Your Query Wasn't Understood. Can You Rephrase The Query
What is the length of the sequence,What is the length of the sequence,1.974797e-20,a1,How long is the sequence,0.1940434,How long is the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,13:43:27,60
What are the bases from position 2 to 10,What are the bases from/between position 10 to/and 20?,0.1379996,b3,how many bases are there from positions 5 to/and 9,0.28074524,how many bases are there from positions 5 to/and 9,0.28074524,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,13:43:53,gcattgagg
What is the base at position 10,What is the base at position/site 5,0.4366287,b1,What is the base at position/site 5 and 50,0.4367645,What is the base at position/site 5 and 50,0.4367645,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,14:11:51,g
How many bases are there from position 2 to 10,how many bases are there between position 5 to/and 9,0.1829868,b2,how many bases are there from positions 5 to/and 9,0.18728873,how many bases are there from positions 5 to/and 9,0.18728873,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,14:12:54,9
How long is the sequence ,How long is the sequence,2.4214691e-20,a1,What is the length of the sequence,0.1940434,What is the length of the sequence,0.1940434,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,14:13:48,60
Is there an S strand in the DNA sequence ,What is the length of the DNA sequence,0.8219202,a2,How long is the DNA sequence,0.84429514,How long is the DNA sequence,0.84429514,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,14:14:44,60
Do you like syrup waffles? ,How many adenine a are there in the sequence?,1.8768792,a4,How many adenine a does the sequence contain?,1.8772323,How many adenine a does the sequence contain?,1.8772323,k nearest neighbours,all-mpnet-base-v2,1.1,1.4,2023-09-19,14:16:35,Your Query Wasn't Understood. Can You Rephrase The Query123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119class DNAseq: def __init__(self, sequence): self.sequence = sequence.lower()
def get_total_bases(self): return len(self.sequence) # Total length of sequence
def get_base_count(self, base): base = base.lower() return self.sequence.count(base) # Total number of specified base. Can be A, T, G or C
def get_base_counts(self): base_counts = { 'a': self.get_base_count('a'), 't': self.get_base_count('t'), 'g': self.get_base_count('g'), 'c': self.get_base_count('c'), } return base_counts # Total number of each base within the sequence returned as a dictionary
def get_base_percentage(self, base): total_bases = self.get_total_bases() base_count = self.get_base_count(base) base_percentage = (base_count / total_bases) * 100 return base_percentage # Base content by percentage.Can be A, T, G or C
def get_base_percentages(self): base_percentages = { 'a': self.get_base_percentage('a'), 't': self.get_base_percentage('t'), 'g': self.get_base_percentage('g'), 'c': self.get_base_percentage('c') } return base_percentages # Base content percentage for each base returned as a dictionary
def get_gc_content(self): total_bases = self.get_total_bases() gc_count = self.sequence.count('g') + self.sequence.count('c') gc_content = (gc_count / total_bases) * 100 return gc_content # Guanine Cytosine (gc) content by percentage
def get_at_content(self): total_bases = self.get_total_bases() at_count = self.sequence.count('a') + self.sequence.count('t') at_content = (at_count / total_bases) * 100 return at_content # Adenine Thymine (at) content by percentage
def get_purine_content(self): total_bases = self.get_total_bases() ag_count = self.sequence.count('a') + self.sequence.count('g') ag_content = (ag_count / total_bases) * 100 return ag_content # Adenine Guanine (purine) content by percentage
def get_pyrimidine_content(self): total_bases = self.get_total_bases() ct_count = self.sequence.count('c') + self.sequence.count('t') ct_content = (ct_count / total_bases) * 100 return ct_content # Cytosine Thymine (pyrimidine) content by percentage
def get_base_at_position(self, position): pos = position - 1
if 0 <= pos < len(self.sequence): base_at_pos = self.sequence[pos] return base_at_pos else: return "Position is out of range. Positions should be 1 - {}".format(len(self.sequence)) # Returns the base at a specified position in the sequence
def get_base_at_positions(self, position_list): if self.check_positions(position_list): pos_dict = {i: self.sequence[i - 1] for i in position_list if 0 <= i < len(self.sequence)} return pos_dict else: return "Position is out of range.Positions should be 1 - {}".format(len(self.sequence)) # Returns base for each position in list
def check_positions(self, position_list): # Check if the positions are within the range of the sequence length # Value = 0 -> position out of sequence range # Value = 1 -> position within sequence range
checked = {} for pos in position_list: if pos <= 0 or pos > len(self.sequence): checked[pos] = 0 else: checked[pos] = 1
# Check if all values are equal to 1 / All positions in the list are within the range of the sequence length all_values_equal_to_1 = all(value == 1 for value in checked.values())
if all_values_equal_to_1: valid = True else: valid = False
return valid
def get_subsequence(self, start_position, end_position): # Ensure the start and end positions are within the bounds of the sequence if start_position > 0 and end_position <= len(self.sequence): return self.sequence[start_position - 1:end_position] else: return "Position is out of range. Positions should be 1 - {}".format(len(self.sequence)) # Returns the subsequence based on given positions
def subsequence_total_bases(self, start_position, end_position): return len(self.get_subsequence(start_position, end_position))
12345678910code,function,descriptiona1,DNAseq(dna).get_total_bases(),calculates the total number of amino acids in the sequencea2,DNAseq(dna).get_total_bases(),calculates the total number of bases in the sequencea3,DNAseq(dna).get_base_count('g'),calculates the total number of guanine bases in the sequencea4,DNAseq(dna).get_base_count('a'),calculates the total number of adenine bases in the sequencea5,DNAseq(dna).get_base_count('c'),calculates the total number of cytosine bases in the sequencea6,DNAseq(dna).get_base_count('t'),calculates the total number of thymine bases in the sequenceb1,DNAseq(dna).get_base_at_position(list_at_index_0(ParameterExtractor(query).extract_integers())),Returns the base at a specified positionb2,"DNAseq(dna).subsequence_total_bases(list_at_index_0(ParameterExtractor(query).extract_integers()), list_at_index_1(ParameterExtractor(query).extract_integers()))",Calculates the total number of bases in a subsequence defined by specified start and end positionsb3,"DNAseq(dna).get_subsequence(list_at_index_0(ParameterExtractor(query).extract_integers()), list_at_index_1(ParameterExtractor(query).extract_integers()))",Returns the bases in a subsequence defined by specified start and end positions12345678910111213141516171819202122232425262728293031323334import csvimport datetime
def list_at_index(extracted_list, index): value_at_index = extracted_list[index]
return value_at_index
def list_at_index_0(extracted_list): value_at_index = extracted_list[0]
return value_at_index
def list_at_index_1(extracted_list): value_at_index = extracted_list[1]
return value_at_index
def logger(log_filename, log_data, response): with open(log_filename, mode='a', newline='') as log_file: log_writer = csv.writer(log_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
# Get the current date and time current_datetime = datetime.datetime.now() date_str = current_datetime.strftime("%Y-%m-%d") time_str = current_datetime.strftime("%H:%M:%S") log_data.append(date_str) log_data.append(time_str) log_data.append(response) # Write the log data to the CSV file log_writer.writerow(log_data)
1234567891011121314151617181920212223class ParameterExtractor: def __init__(self, query): self.query = query.lower()
def extract_integers(self): extracted_integers = [] current_number = ""
for char in self.query: if char.isdigit(): # Append digits to the current number current_number += char elif current_number: # If a number is complete, convert and append it extracted_integers.append(int(current_number)) current_number = "" # Reset current_number
# Check for any remaining numbers after the loop if current_number: extracted_integers.append(int(current_number))
sorted_integers = sorted(extracted_integers) return sorted_integersCTS_user_log.csvAdded+43
DNAseq.pyAdded+119
code_function_mapping.csvAdded+10
helper.pyAdded+34
parameter_extractor.pyAdded+23
ref_query_db_indexAdded
reference_query_db.jsonAdded