Skip to content

Commit

Permalink
updated main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahn281 committed May 1, 2023
1 parent f4e42a0 commit 7f342f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# loads json file
the_input.load_json()

'''

# do blast search (either regular, clustered, or hierarchical)
hits = []
if the_input.blast_param["hierarchical_taxon_level"] != "None":
Expand All @@ -34,6 +34,7 @@
hits = [({'prot_id': 'WP_011079176'}, 'WP_272923659.1')]
#hits = [({'prot_id': 'WP_011079176'}, 'WP_039469417.1')]
#hits = [({'prot_id': 'WP_011079176'}, 'WP_053542922.1')]
'''

# treats each hit from the blast search as a potential ortholog and adds to list of orthologs
orthologs = []
Expand All @@ -44,18 +45,21 @@
orthologs_dict = {}
#goes through orthologs list to add to ortho dictionary and get records/sequences
for potential_olog in orthologs:
orthologs_dict[potential_olog.hit] = ""
olog_key = potential_olog.hit[1]
orthologs_dict[olog_key] = ""
potential_olog.get_nuc_rec() #gets nucleotide record for each ortholog
potential_olog.get_nuc_seq() #get nucleotide sequence from the record for each ortholog

print(orthologs)

# goes through list of orthologs and does popping algorithm that marks sequences that are too similar
for first_ortholog in range(len(orthologs)):
compared_ortholog = first_ortholog+1 # compares first ortholog with ortholog after it
while compared_ortholog < len(orthologs):
# gets percent similarity and marks in dictionary if above the threshold
per_similarity = orthologs[first_ortholog].percent_similarity(orthologs[compared_ortholog])
if per_similarity < 8: #checks if ortholog is less
orthologs_dict[compared_ortholog.hit] = "DELETE"
orthologs_dict[orthologs[compared_ortholog].hit] = "DELETE"
compared_ortholog += 1

# goes through ortholog dictionary to finalize which orthologs can stay
Expand All @@ -64,3 +68,5 @@
for ortholog in orthologs:
if (ortholog.hit == ortholog_key):
orthologs.remove(ortholog)

print(orthologs)

0 comments on commit 7f342f5

Please sign in to comment.