Skip to content

Commit

Permalink
fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Nov 8, 2023
1 parent 8c59e43 commit b49231b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,7 @@ def get_transcripts_from_names(self, transcript_names, remove_unknown = False):
transcripts = [self.convert_raw_transcript(transcript_raw) for transcript_raw in transcripts_raw]

if not remove_unknown:
transcripts_not_in_db = list(set(transcript_names) - set([x[2] for x in transcripts_raw]))
transcripts_not_in_db = list(set(transcript_names) - set([x[3] for x in transcripts_raw]))
transcripts_not_in_db = [models.Transcript(id=None, gene=None, name=transcript_name, biotype=None, length=None, chrom="", start=0, end=0, orientation="", source="ensembl" if transcript_name.startswith('ENST') else "refseq", is_gencode_basic=None,is_mane_select=None,is_mane_plus_clinical=None,is_ensembl_canonical=None) for transcript_name in transcripts_not_in_db]
transcripts.extend(transcripts_not_in_db)

Expand Down
2 changes: 1 addition & 1 deletion src/common/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def sort_transcript_dict(input_dict):
def sort_transcripts(transcript_names):
from common.db_IO import Connection
conn = Connection()
transcripts = conn.get_transcripts_from_names(transcript_names)
transcripts = conn.get_transcripts_from_names(transcript_names, remove_unknown = True)
#print(transcripts)
conn.close()
transcripts_sorted = order_transcripts(transcripts)
Expand Down
12 changes: 10 additions & 2 deletions src/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,22 @@ def get_preferred_transcripts(self):

if consequences is None:
return None
if len(consequences) == 0:
return None

sortable_dict = {}
for consequence in consequences:
if consequence.transcript.source == 'ensembl':
sortable_dict[consequence.transcript.name] = consequence

if len(sortable_dict) == 0:
return None

#print("sortable dict:")
#print(sortable_dict)
transcripts_sorted, consequences_sorted = functions.sort_transcript_dict(sortable_dict)
#print("transcripts_sorted:")
#print(transcripts_sorted)
#print("consequences_sorted:")
#print(consequences_sorted)
result.append(consequences_sorted.pop(0)) # always append the first one
for consequence in consequences_sorted: # scan for all mane select transcripts
if consequence.transcript.is_mane_select:
Expand Down

0 comments on commit b49231b

Please sign in to comment.