supercat666 commited on
Commit
dcc8d7f
1 Parent(s): 78b5697
Files changed (1) hide show
  1. cas9on.py +11 -2
cas9on.py CHANGED
@@ -68,6 +68,15 @@ def fetch_ensembl_sequence(transcript_id):
68
  print(f"Error fetching sequence data from Ensembl: {response.text}")
69
  return None
70
 
 
 
 
 
 
 
 
 
 
71
  def find_crispr_targets(sequence, chr, start, strand, transcript_id, pam="NGG", target_length=20):
72
  targets = []
73
  len_sequence = len(sequence)
@@ -115,7 +124,7 @@ def process_gene(gene_symbol, model_path):
115
  if transcripts:
116
  for i in range(len(transcripts)):
117
  Exons = transcripts[i]['Exon']
118
- cds = transcripts[i]['cds']
119
  transcript_id = transcripts[i]['display_name']
120
  for j in range(len(Exons)):
121
  exon_id = Exons[j]['id']
@@ -137,7 +146,7 @@ def process_gene(gene_symbol, model_path):
137
  print("Failed to retrieve transcripts.")
138
 
139
  # Note: Returning last exon's sequence, might need adjustment based on use-case
140
- return results, gene_sequence, Exons, cds
141
 
142
  def create_genbank_features(formatted_data):
143
  features = []
 
68
  print(f"Error fetching sequence data from Ensembl: {response.text}")
69
  return None
70
 
71
+ def fetch_ensembl_cds(transcript_id):
72
+ url = f"https://rest.ensembl.org/overlap/id/{transcript_id}?feature=cds;content-type=application/json"
73
+ response = requests.get(url)
74
+ if response.status_code == 200:
75
+ cds_data = response.json()
76
+ return cds_data
77
+ else:
78
+ print(f"Error fetching CDS data from Ensembl: {response.text}")
79
+ return []
80
  def find_crispr_targets(sequence, chr, start, strand, transcript_id, pam="NGG", target_length=20):
81
  targets = []
82
  len_sequence = len(sequence)
 
124
  if transcripts:
125
  for i in range(len(transcripts)):
126
  Exons = transcripts[i]['Exon']
127
+ cds_list = fetch_ensembl_cds(transcript_id)
128
  transcript_id = transcripts[i]['display_name']
129
  for j in range(len(Exons)):
130
  exon_id = Exons[j]['id']
 
146
  print("Failed to retrieve transcripts.")
147
 
148
  # Note: Returning last exon's sequence, might need adjustment based on use-case
149
+ return results, gene_sequence, Exons, cds_list
150
 
151
  def create_genbank_features(formatted_data):
152
  features = []