Skip to content

Commit

Permalink
Update DIAMOND_analysis_counter.py with if/else for multiple brackets…
Browse files Browse the repository at this point in the history
… in annotations

Thanks to Menia Gavriilidou for this suggestion!  

In the DIAMOND_analysis_counter.py script, there's now logic to account for if a RefSeq annotation description includes multiple sets of square brackets `[]`.  Not guaranteed, but better than dropping the line.
  • Loading branch information
transcript authored Mar 25, 2024
1 parent 4c015c0 commit 2bfbc0b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python_scripts/DIAMOND_analysis_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,16 @@ def string_find(usage_term):
db_id = str(splitline[0])[1:]

# name and functional description
db_entry = line.split("[", 1)
db_entry = db_entry[0].split(" ", 1)
db_entry = db_entry[1][:-1]

# updated to account for multiple brackets; thanks Menia G.!
if line.count("[") != 1:
db_entry = line.rsplit("[",1) ## Split the line at the first "[" from the end
db_entry = db_entry[0].split(" ", 1)
db_entry = db_entry[1][:-1]
else:
db_entry = line.split("[", 1) ## splits the line into two parts, one before the first occurence of "[" and the other after
db_entry = db_entry[0].split(" ", 1) ##splits the first parts into two
db_entry = db_entry[1][:-1] ##keeps the second part

# organism name
if line.count("[") != 1:
splitline = line.split("[")
Expand Down

0 comments on commit 2bfbc0b

Please sign in to comment.