-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
234 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
posts/intro_to_python_and_jupyter/exercise_solutions/exercise_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
for genus in np_atlas_set: | ||
bacteria_genera.append(genus) |
13 changes: 13 additions & 0 deletions
13
posts/intro_to_python_and_jupyter/exercise_solutions/exercise_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import requests as r | ||
|
||
def get_compound_data_by_name(compound_name): | ||
response = r.get("https://www.npatlas.org/api/v1/compounds/full/?name="+compound_name) | ||
return response.json()[0] | ||
|
||
compound_list = ['Lincomycin','Collismycin A','Streptomycin','Erythromycin B'] | ||
for compound in compound_list: | ||
try: | ||
compound_data = get_compound_data_by_name(compound) | ||
print(compound_data['original_name'],"is produced by",compound_data['origin_organism']['genus'],"and has a molecular weight of",compound_data['mol_weight'],"Da.") | ||
except: | ||
print(compound,"was not found in the NPAtlas database.") |