API
ADToolbox has its own way of figuring out the path to the required files and configurations required for running different methods. The entire toolbox relies on the configs module. Objects of different classes in ADToolbox are instantiated by an instance of the corresponding class in the configs module. For instance, if you want to use the methods of the metagenomics class in core module, you should do the following:
from adtoolbox import configs and core
metag_conf=configs.Metagenomics()
metag_object=core.Metagenomics(metag_conf)
Doing this will result in that any core.Metagenomics method will refer to the defult configurations defined in the configs module. If you want to overwright the defult configuration, you can pass the desired argument to the configs.Metagenomics constructor. For example, if you want to change the docker repository for VSEARCH you can:
metag_conf=configs.Metagenomics(vsearch_docker="mydocker")
metag_object=core.Metagenomics(metag_conf)
Now when you execute the corresponding method in core.Metagenomics it will use mydocker instead of the defult. To learn more about defult configs, go to the configs api.
configs
You can access this module by:
from adtoolbox import configs
This module contains configurations that are required by other classes in the package and also links to remote databases. The following classes are included in this module:
1. Database
An instance of this class will hold all the configuration information for core.Database functionalities.
Source code in adtoolbox/configs.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
2. Metagenomics
An instance of this class will hold all the configuration information for core.Metagenomics functionalities.
Source code in adtoolbox/configs.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
3. Utils
An instance of this class will hold all the configuration information for utils module functionalities.
Source code in adtoolbox/configs.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
core
You can access this module by:
from adtoolbox import core
This module includes the following classes:
1. Experiment
This class creates an interface for the experimental data to be used in different places in ADToolbox. First you should give each experiment a name. Time must be a list of time points in days, and there must be a time 0 point assinged to each experiment. variables must be a list of integers that represent the variables that are the index of the ADM species that we have concentration data for. data must be a list of lists. Each list in the list must be a list of concentrations for each species at each time point. IMPORTANT: The order of the species in the data list must match the order of the species in the variables list. if there are specific initial concentrations for the ADM species, they can be passed as a dictionary to the initial_concentrations argument. reference is an optional argument that can be used to provide a reference for the experimental data. If using the database module to query for Experiment objects you can query by name or reference or model_type. So, having a descriptive reference can be useful for querying as well. default model name is "e_adm". This can be changed by passing a different model name to the model_name argument. This also helps with querying.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A unique name for the experiment. |
required |
time |
list
|
A list of time points in days. |
required |
variables |
list
|
A list of integers that represent the variables that are the index of the ADM species that we have concentration data for. |
required |
data |
list
|
A list of lists. Each list in the list must be a list of concentrations for each species at each time point. |
required |
initial_concentrations |
dict
|
A dictionary of initial concentrations for the ADM species. Defaults to {}. |
dataclasses.field(default_factory=dict)
|
reference |
str
|
A reference for the experimental data. Defaults to ''. |
''
|
model_name |
str
|
The name of the model that the experimental data is for. Defaults to "e_adm". |
'e_adm'
|
Examples:
>>> from adtoolbox import configs
>>> import json
>>> with open(configs.Database().species,"r") as f:
... species=json.load(f)
>>> S_su_index=species.index("S_su")
>>> S_aa_index=species.index("S_aa")
>>> exp=Experiment(name="Test",time=[0,1,2],variables=[S_su_index,S_aa_index],data=[[1,2,3],[4,5,6]],reference="Test reference")
Source code in adtoolbox/core.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
2. Feed
The Feed class is used to store the feed information, and later use it in the e_adm model. all the entered numbers must in percentages. Carbohudrates, lipids, and proteins and si must sum up to 100, and they form the total dissolved solids. Carbohydrates, lipids, proteins, and xi must sum up to 100, and they form the total suspended solids.
IMPORTANT: It is assumed that lipid, proteins and carbohydrates have the same fraction in soluble and insoluble fractions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A unique name for the feed. |
required |
carbohydrates |
float
|
percentage of carbohydrates in the feed. |
required |
lipids |
float
|
percentage of lipids in the feed. |
required |
proteins |
float
|
percentage of proteins in the feed. |
required |
tss |
float
|
percentage of total COD in the form of suspended solids. |
required |
si |
float
|
percentage of percentage of soluble inorganics in the TDS. |
required |
xi |
float
|
percentage of percentage of insoluble inorganics in the TSS. |
required |
reference |
str
|
A reference for the feed data. Defaults to ''. |
''
|
Examples:
>>> feed=Feed(name="Test",carbohydrates=20,lipids=20,proteins=20,si=20,xi=20,tss=70)
>>> assert feed.ch_tss==feed.lip_tss==feed.prot_tss==feed.xi_tss==0.25
Source code in adtoolbox/core.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
3. MetegenomicsStudy
This class is used to communicate between the metagenomics studies database and the ADM model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the metagenomics study. Its okay if it is not unique. |
required |
study_type |
str
|
The type of the metagenomics study. It can be "amplicon" or "WGS". |
required |
microbiome |
str
|
The microbiome that the metagenomics study is about. |
required |
sample_accession |
str
|
The SRA sample accession number of the metagenomics study. This must be unique. |
required |
comments |
str
|
Any comments that you want to add to the metagenomics study. |
required |
study_accession |
str
|
The SRA study accession number of the metagenomics study. |
required |
Examples:
>>> study=MetagenomicsStudy(name="Test",study_type="WGS",microbiome="test_microbiome",sample_accession="test_accession",comments="test_comments",study_accession="test_study_accession")
>>> assert study.name=="Test"
Source code in adtoolbox/core.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
4. Reaction
This class provides a simple interface between information about biochemical reactions and multiple functionalities of ADToolbox. In order to instantiate a reaction object, you need to pass a dictionary of the reaction information. This dictionary must include 'name','stoichiometry' keys. This follows the format of the seed database. stoichiometry must be formatted like seed database. The seed database format is as follows: stoichiometry: '-1:cpd00079:0:0:"D-glucose-6-phosphate";1:cpd00072:0:0:"D-fructose-6-phosphate"'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
A dictionary containing the reaction information. This follows the format of the seed database. |
required |
Examples:
>>> A={"name":'D-glucose-6-phosphate aldose-ketose-isomerase',"stoichiometry":'-1:cpd00079:0:0:"D-glucose-6-phosphate";1:cpd00072:0:0:"D-fructose-6-phosphate"'}
>>> a=Reaction(A)
>>> print(a)
D-glucose-6-phosphate aldose-ketose-isomerase
Source code in adtoolbox/core.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
stoichiometry: dict
property
Returns the stoichiometry of the reaction by the seed id of the compounds as key and the stoichiometric coefficient as value.
Examples:
>>> A={"name":'D-glucose-6-phosphate aldose-ketose-isomerase',"stoichiometry":'-1:cpd00079:0:0:"D-glucose-6-phosphate";1:cpd00072:0:0:"D-fructose-6-phosphate"'}
>>> a=Reaction(A)
>>> a.stoichiometry=={'cpd00079': -1, 'cpd00072': 1}
True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Reaction
|
An instance of the Reaction. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The stoichiometry of the reaction |
5. Metabolite
This class provides a simple interface between information about metabolites and multiple functionalities of ADToolbox. In order to instantiate a metabolite object, you need to pass a dictionary of the metabolite information. This dictionary must include 'name','mass','formula' keys. This follows the format of the seed database. formula must be formatted like seed database. The seed database format is as follows: formula: 'C6H12O6' Possibly the main advantage of instantiating a metabolite object is that it provides a COD attribute that can be used to convert the concentration of the metabolite from g/l to gCOD/l. This is useful for comparing the experimental data with the model outputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
A dictionary containing the metabolite information. This follows the format of the seed database. |
required |
Examples:
>>> A={"name":"methane","mass":16,"formula":"CH4"}
>>> a=Metabolite(A)
>>> print(a)
methane
Source code in adtoolbox/core.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
cod_calc(add_h=0, add_c=0, add_o=0)
Calculates the conversion rates for g/l -> gCOD/l In some cases we would like to add extra atoms for COD calculations For example, model seed biochemistry database only uses acetate instead of acetic acid. The 1 hydrogen difference changes the COD conversion rate. For this reason we can add extra atoms to the formula to calculate the COD conversion rate without changing anything else.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
add_h |
float
|
The number of extra hydrogen atoms to add to the formula for COD calculation. |
0
|
add_c |
float
|
The number of extra carbon atoms to add to the formula for COD calculation. |
0
|
add_o |
float
|
The number of extra oxygen atoms to add to the formula for COD calculation. |
0
|
Examples:
>>> A={"name":"methane","mass":16,"formula":"CH4"}
>>> a=Metabolite(A)
>>> a.cod
4.0
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
Metabolite
|
An instance of the Metabolite class: Note |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
COD conversion from g/l to gCOD/l |
Source code in adtoolbox/core.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
6.SeedDB
This class is designed to interact with seed database. The main advantage of using this class is that it can be used to instantiate a reaction and metabolite object, and it provides extra functionalities that rely on information in the seed database. For example, If there is a chemical formula assigned to a metabolite in the seed database, then the informattion about the COD of that metabolite can be computed using the chemical formula.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
configs.SeedDB
|
An instance of the SeedDB class in the configs module. This class contains the information about the seed database. |
required |
Examples:
>>> seed_db=SeedDB(configs.SeedDB())
>>> assert seed_db.compound_db==configs.SeedDB().compound_db
>>> assert seed_db.reaction_db==configs.SeedDB().reaction_db
Source code in adtoolbox/core.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
get_seed_rxn_from_ec(ec_number)
This method is used to get the seed reaction identifiers for a given EC number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ec_number |
str
|
The EC number. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of seed reaction identifiers. |
Required Configs
- config.reaction_db
Examples:
>>> seed_db=SeedDB()
>>> seed_rxn_list=seed_db.get_seed_rxn_from_ec("1.1.1.1")
>>> assert len(seed_rxn_list)>0
Source code in adtoolbox/core.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
instantiate_metabs(seed_id)
This method is used to instantiate metabolite objects from the seed database. In order to instantiate a metabolite object, you need to pass the seed identifier for that metabolite.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed_id |
str
|
The seed identifier for the metabolite. |
required |
Returns:
Name | Type | Description |
---|---|---|
Metabolite |
Metabolite
|
An instance of the Metabolite class. |
Required Configs
- config.compound_db
Examples:
>>> seed_db=SeedDB()
>>> metab=seed_db.instantiate_metabs("cpd01024")
>>> assert metab.cod==4.0
Source code in adtoolbox/core.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
instantiate_rxns(seed_id)
This method is used to instantiate reaction objects from the seed database. in order to instantiate a reaction object, you need to pass the seed identifier for that reaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed_id |
str
|
The seed identifier for the reaction. |
required |
Returns:
Name | Type | Description |
---|---|---|
Reaction |
Reaction
|
An instance of the Reaction class. |
Reaction
|
Required Configs
- config.reaction_db
Examples:
>>> seed_db=SeedDB()
>>> rxn=seed_db.instantiate_rxns("rxn00558")
>>> assert rxn.data["name"]=="D-glucose-6-phosphate aldose-ketose-isomerase"
Source code in adtoolbox/core.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
7. Database
Here is a schematic of the Database Module
This class is designed to supply any data requirement for ADToolbox. All functionalisties for saving, loading, and querying data are implemented here. ADToolbox in general contains the following databases:
-
The seed reaction database
-
The seed compound database
-
ADToolbox's Feed database
-
ADToolbox's Metagenomics studies database
-
ADToolbox's Experimental data database
-
ADToolbox's Protein database
-
ADToolbox's Reaction database
-
GTDB-tk database for bacterial and archaeal 16s rRNA sequences
-
ADM and e_adm model parameters
This class is instantiated with a configs.Database object. This object contains the paths to all the databases that ADToolbox uses. Please refer to the documentation of each method for more information on the required configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
configs.Database
|
A configs.Database object. Defaults to configs.Database(). |
configs.Database()
|
Examples:
>>> db=Database(config=configs.Database())
>>> assert type(db)==Database and type(db.config)==configs.Database
Source code in adtoolbox/core.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 |
|
add_experiment_to_experiments_db(experiment)
This function adds an experiment to the experiments database. It takes an experiment and adds it to the experiments database.
Required Configs
- config.experimental_data_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment |
Experiment
|
An instance of the Experiment class. |
required |
Examples:
>>> import os,json
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.tsv"))==False
>>> db=Database(config=configs.Database(experimental_data_db=os.path.join(Main_Dir,"experiments_test_db.json")))
>>> experiment=Experiment(name="test_study",time=[0,1,2],variables=[2,6],data= [[1,2,3],[4,5,6]],reference="test")
>>> db.add_experiment_to_experiments_db(experiment)
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.json"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"experiments_test_db.json"))>0
>>> os.remove(os.path.join(Main_Dir,"experiments_test_db.json"))
Source code in adtoolbox/core.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
|
add_feed_to_feed_db(feed)
This function adds a feed to the feed database. It takes the feed name and the feed composition and adds them to the feed database.
Required Configs
- config.feed_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feed |
Feed
|
An instance of the Feed class. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==False
>>> db=Database(config=configs.Database(feed_db=os.path.join(Main_Dir,"feed_test_db.tsv")))
>>> feed=Feed(name="test_feed",carbohydrates=10,lipids=20,proteins=30,tss=80,si=10,xi=30,reference="test")
>>> db.add_feed_to_feed_db(feed)
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter="\t").shape[0]>0
>>> os.remove(os.path.join(Main_Dir,"feed_test_db.tsv"))
Source code in adtoolbox/core.py
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
|
add_metagenomics_study_to_metagenomics_studies_db(metagenomics_study)
This function adds a metagenomics study to the metagenomics studies database. It takes a metagenomics study and adds it to the metagenomics studies database.
Required Configs
- config.metagenomics_studies_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metagenomics_study |
MetagenomicsStudy
|
An instance of the MetagenomicsStudy class. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==False
>>> db=Database(config=configs.Database(metagenomics_studies_db=os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv")))
>>> metagenomics_study=MetagenomicsStudy(name="test_study",study_type="metagenomics",microbiome="anaerobic digester",sample_accession="test",comments="test",study_accession="test")
>>> db.add_metagenomics_study_to_metagenomics_studies_db(metagenomics_study)
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").shape[0]>0
>>> os.remove(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))
Source code in adtoolbox/core.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
|
add_protein_to_protein_db(protein_id, header_tail)
This funciton adds a protein sequence to the protein database. It takes a uniprot id and an EC number it is assigned to and adds the corresponding protein sequence to the protein database.
Required Configs
- config.protein_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
protein_id |
str
|
The uniprot id of the protein. |
required |
header_tail |
str
|
A text to append to the header of the entry in the database; |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta")))
>>> db.add_protein_to_protein_db("P0A9P0","1.2.3.4")
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"protein_test_db.fasta"))>0
>>> import utils
>>> assert len(utils.fasta_to_dict(os.path.join(Main_Dir,"protein_test_db.fasta")))>0
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta"))
Source code in adtoolbox/core.py
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
add_proteins_from_ecnumbers_to_protein_db(ec_numbers)
This function adds protein sequences to the protein database from a list of EC numbers. It takes a list of EC numbers and finds the protein sequences for each EC number in the list. Then it saves the protein sequences in a fasta file.
Required Configs
- config.protein_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ec_numbers |
list
|
A list of EC numbers. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta")))
>>> db.add_proteins_from_ecnumbers_to_protein_db(["1.1.1.1","1.1.1.2"])
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True
>>> import utils
>>> assert len(utils.fasta_to_dict(os.path.join(Main_Dir,"protein_test_db.fasta")))>0
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta"))
Source code in adtoolbox/core.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
|
build_mmseqs_database(container='None')
Builds an indexed mmseqs database from the ADToolbox's fasta protein database.
Required Configs
- config.protein_db
- config.adtoolbox_singularity
- config.adtoolbox_docker
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container |
str
|
The container to run the script with. Defaults to "None". |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The script to build the mmseqs database. |
str
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta")))
>>> db.add_protein_to_protein_db("P0A9P0","x,x,x,x")
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"protein_test_db.fasta"))>0
>>> script=db.build_mmseqs_database()
>>> assert script=="mmseqs createdb "+str(os.path.join(Main_Dir,"protein_test_db.fasta"))+" "+str(db.config.protein_db_mmseqs)
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta"))
Source code in adtoolbox/core.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
|
build_protein_db_from_reactions_db()
This function builds the protein database from the reaction database. It takes the reaction database and finds the protein sequences for each EC number in the reaction database. Then it saves the protein sequences in a fasta file.
Required Configs
- config.reaction_db
- config.protein_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False
>>> assert os.path.exists(os.path.join(Main_Dir,"reaction_test_db.tsv"))==False
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta"),reaction_db=os.path.join(Main_Dir,"reaction_test_db.tsv")))
>>> reaction_db=pd.DataFrame(columns=["EC_Numbers","Seed Ids","Reaction Names","ADM1_Reaction","e_adm_Reactions","Pathways"])
>>> reaction_db.loc[0,"EC_Numbers"]="1.1.1.1"
>>> reaction_db.to_csv(os.path.join(Main_Dir,"reaction_test_db.tsv"),index=False,sep="\t")
>>> db.build_protein_db_from_reactions_db()
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True
>>> assert os.path.exists(os.path.join(Main_Dir,"reaction_test_db.tsv"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"protein_test_db.fasta"))>0
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta"))
>>> os.remove(os.path.join(Main_Dir,"reaction_test_db.tsv"))
Source code in adtoolbox/core.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
|
cazy_ec()
This method returns a list of EC numbers that are extracted from the Cazy website. This method is useful for adding more carbohydrate metabolism reactions to the reaction database.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of EC numbers for carbohydrate metabolism found on CAZy database. |
Examples:
>>> db=Database()
>>> ec_list=db.cazy_ec()
>>> assert len(ec_list)>0
Source code in adtoolbox/core.py
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
|
download_adm_parameters(verbose=True)
Downloads the parameters needed for running ADM models in ADToolbox.
Required Configs
- config.adm_parameters_base_dir
- config.adm_parameters_urls
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"adm_parameters_test"))==False
>>> db=Database(config=configs.Database(adm_parameters_base_dir=os.path.join(Main_Dir,"adm_parameters_test")))
>>> db.download_adm_parameters(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"adm_parameters_test"))==True
>>> assert len(os.listdir(os.path.join(Main_Dir,"adm_parameters_test")))==12
>>> os.system("rm -r "+os.path.join(Main_Dir,"adm_parameters_test"))
0
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Source code in adtoolbox/core.py
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 |
|
download_all_databases(verbose=True)
This function will download all the required databases for all the functionalities of ADToolbox. NOTE: each method that this function calls is individually tested so it is skipped from testing!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Required Configs
- config.adm_parameters_base_dir
- config.adm_parameters_urls
- config.seed_rxn_url
- config.seed_compound_url
- config.reaction_db
- config.compound_db
- config.protein_db_url
- config.protein_db
- config.adtoolbox_rxn_db_url
- config.csv_reaction_db
- config.feed_db_url
- config.feed_db
- config.amplicon_to_genome_db
- config.amplicon_to_genome_urls
- config.qiime_classifier_db_url
- config.qiime_classifier_db
- config.studies_db
- config.studies_urls
Examples:
>>> import os
>>> db=Database(config=configs.Database())
>>> db.download_all_databases(verbose=False)
Source code in adtoolbox/core.py
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 |
|
download_amplicon_to_genome_db(verbose=True)
This function will automatically download the GTDB-tk database for genome assignment.
Required Configs
- config.amplicon_to_genome_db
- config.amplicon_to_genome_urls
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"amplicon_to_genome_test_db"))==False
>>> db=Database(config=configs.Database(amplicon_to_genome_db=os.path.join(Main_Dir,"amplicon_to_genome_test_db")))
>>> db.download_amplicon_to_genome_db(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"amplicon_to_genome_test_db"))==True
>>> assert len(os.listdir(os.path.join(Main_Dir,"amplicon_to_genome_test_db")))>0
>>> os.system("rm -r "+os.path.join(Main_Dir,"amplicon_to_genome_test_db"))
0
Source code in adtoolbox/core.py
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
|
download_feed_database(verbose=True)
This function will download the feed database from the remote repository.
Required Configs
- config.feed_db_url
- config.feed_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==False
>>> db=Database(config=configs.Database(feed_db=os.path.join(Main_Dir,"feed_test_db.tsv")))
>>> db.download_feed_database(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"feed_test_db.tsv"))>0
>>> os.remove(os.path.join(Main_Dir,"feed_test_db.tsv"))
Source code in adtoolbox/core.py
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 |
|
download_protein_database(verbose=True)
Downloads the prebuilt protein database from the remote repository.
Required Configs
- config.protein_db_url
- config.protein_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta")))
>>> db.download_protein_database(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"protein_test_db.fasta"))>0
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta"))
Source code in adtoolbox/core.py
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
|
download_reaction_database(verbose=True)
This function will download the reaction database from the remote repository.
Required Configs
- config.adtoolbox_rxn_db_url
- config.csv_reaction_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"reaction_test_db.csv"))==False
>>> db=Database(config=configs.Database(csv_reaction_db=os.path.join(Main_Dir,"reaction_test_db.csv")))
>>> db.download_reaction_database(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"reaction_test_db.csv"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"reaction_test_db.csv"))>0
>>> os.remove(os.path.join(Main_Dir,"reaction_test_db.csv"))
Source code in adtoolbox/core.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 |
|
download_seed_databases(verbose=True)
This function will download the seed databases, both compound and reaction databases.
Required Configs
- config.seed_rxn_url
- config.seed_compound_url
- config.reaction_db
- config.compound_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print the progress or not. Defaults to True. |
True
|
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"seed_rxn.json"))==False
>>> assert os.path.exists(os.path.join(Main_Dir,"seed_compound.json"))==False
>>> db=Database(config=configs.Database(reaction_db=os.path.join(Main_Dir,"seed_rxn.json"),compound_db=os.path.join(Main_Dir,"seed_compound.json")))
>>> db.download_seed_databases(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"seed_rxn.json"))==True
>>> assert os.path.exists(os.path.join(Main_Dir,"seed_compound.json"))==True
>>> os.remove(os.path.join(Main_Dir,"seed_rxn.json"))
>>> os.remove(os.path.join(Main_Dir,"seed_compound.json"))
Source code in adtoolbox/core.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
|
download_studies_database(verbose=True)
This function will download the required files for studies functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbode |
bool
|
Whether to print the progress or not. Defaults to True. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"studies_test_db.tsv"))==False
>>> db=Database(config=configs.Database(studies_db=os.path.join(Main_Dir,"studies_test_db.tsv")))
>>> db.download_studies_database(verbose=False)
>>> assert os.path.exists(os.path.join(Main_Dir,"studies_test_db.tsv"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"studies_test_db.tsv"))>0
>>> os.remove(os.path.join(Main_Dir,"studies_test_db.tsv"))
Source code in adtoolbox/core.py
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 |
|
filter_seed_from_ec(ec_list, save=False)
This function takes a list of EC numbers and filters the seed database to find the seed reactions that have the EC numbers in their EC number list. This will help to trim the large seed database to a smaller one that only contains the reactions that are relevant to the AD process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ec_list |
list[str]
|
A list of EC numbers. |
required |
save |
bool
|
Whether to save the filtered seed database or not. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple
|
A tuple containing the filtered seed reaction database and the seed compound database, respectively. |
Required Configs
- config.reaction_db
- config.compound_db
- config.local_reaction_db
- config.local_compound_db
Examples:
>>> db=Database()
>>> seed_rxn_db,seed_compound_db=db.filter_seed_from_ec(["1.1.1.1","1.1.1.2"])
>>> assert len(seed_rxn_db)>0 and len(seed_compound_db)>0
>>> assert pd.read_json(configs.Database().reaction_db).shape[0]>pd.DataFrame(seed_rxn_db).shape[0]
Source code in adtoolbox/core.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
get_experiment_from_experiments_db(field_name, query)
This function returns an experiment from the experiments database. It takes the query string and the column name to query and returns the experiment that contains the query string in the given column.
Required Configs
- config.experimental_data_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Returns:
Name | Type | Description |
---|---|---|
Experiment |
list[Experiment]
|
An instance of the Experiment class. |
Examples:
>>> import os,json
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.tsv"))==False
>>> db=Database(config=configs.Database(experimental_data_db=os.path.join(Main_Dir,"experiments_test_db.json")))
>>> experiment=Experiment(name="test_study",time=[0,1,2],variables=[2,6],data= [[1,2,3],[4,5,6]],reference="test")
>>> db.add_experiment_to_experiments_db(experiment)
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.json"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"experiments_test_db.json"))>0
>>> experiment=db.get_experiment_from_experiments_db("name","test_study")
>>> assert experiment[0].name=="test_study"
>>> os.remove(os.path.join(Main_Dir,"experiments_test_db.json"))
Source code in adtoolbox/core.py
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
|
get_feed_from_feed_db(field_name, query)
This function returns a feed from the feed database. It takes the query string and the column name to query and returns the feed that contains the query string in the given column.
Required Configs
- config.feed_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Returns:
Name | Type | Description |
---|---|---|
Feed |
list[Feed]
|
An instance of the Feed class. |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==False
>>> db=Database(config=configs.Database(feed_db=os.path.join(Main_Dir,"feed_test_db.tsv")))
>>> feed=Feed(name="test_feed",carbohydrates=10,lipids=20,proteins=30,tss=80,si=10,xi=30,reference="test")
>>> db.add_feed_to_feed_db(feed)
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter="\t").shape[0]>0
>>> feed=db.get_feed_from_feed_db("name","test_feed")
>>> assert feed[0].name=="test_feed"
>>> os.remove(os.path.join(Main_Dir,"feed_test_db.tsv"))
Source code in adtoolbox/core.py
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
|
get_metagenomics_study_from_metagenomics_studies_db(field_name, query)
This function returns a metagenomics study from the metagenomics studies database. It takes the query string and the column name to query and returns the metagenomics study that contains the query string in the given column.
Required Configs
- config.metagenomics_studies_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Returns:
Name | Type | Description |
---|---|---|
MetagenomicsStudy |
list[MetagenomicsStudy]
|
An instance of the MetagenomicsStudy class. |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==False
>>> db=Database(config=configs.Database(metagenomics_studies_db=os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv")))
>>> metagenomics_study=MetagenomicsStudy(name="test_study",study_type="metagenomics",microbiome="anaerobic digester",sample_accession="test",comments="test",study_accession="test")
>>> db.add_metagenomics_study_to_metagenomics_studies_db(metagenomics_study)
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").shape[0]>0
>>> metagenomics_study=db.get_metagenomics_study_from_metagenomics_studies_db("name","test_study")
>>> assert metagenomics_study[0].name=="test_study"
>>> os.remove(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))
Source code in adtoolbox/core.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
get_protein_seqs_from_uniprot(uniprot_id)
This function takes a uniprot id and fetches the protein sequence from Uniprot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uniprot_id |
str
|
The uniprot id of the protein. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The protein sequence. |
Examples:
>>> db=Database()
>>> seq=db.get_protein_seqs_from_uniprot("P0A9P0")
>>> assert type(seq)==str and len(seq)>0
Source code in adtoolbox/core.py
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
|
initialize_experimental_data_db()
This function intializes ADToolbox's experimental data database by creating an empty json file. Be careful, this will overwrite any existing file with the same name.
Required Configs
- config.experimental_data_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"experimental_data_test_db.json"))==False
>>> db=Database(config=configs.Database(experimental_data_db=os.path.join(Main_Dir,"experimental_data_test_db.json")))
>>> db.initialize_experimental_data_db()
>>> assert pd.read_json(os.path.join(Main_Dir,"experimental_data_test_db.json")).shape[0]==0
>>> with open(os.path.join(Main_Dir,"experimental_data_test_db.json"),"r") as f:
... assert json.load(f)==[]
>>> os.remove(os.path.join(Main_Dir,"experimental_data_test_db.json"))
Source code in adtoolbox/core.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
|
initialize_feed_db()
This function intializes ADToolbox's Feed database by creating an empty tsv file. Be careful, this will overwrite any existing file with the same name.
Required Configs
- config.feed_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==False
>>> db=Database(config=configs.Database(feed_db=os.path.join(Main_Dir,"feed_test_db.tsv")))
>>> db.initialize_feed_db()
>>> assert pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter='\t').shape[0]==0
>>> assert set(pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter='\t').columns)==set(["name","carbohydrates","lipids","proteins","tss","si","xi","reference"])
>>> os.remove(os.path.join(Main_Dir,"feed_test_db.tsv"))
Source code in adtoolbox/core.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
initialize_metagenomics_studies_db()
This function intializes ADToolbox's Metagenomics studies database by creating an empty tsv file. Be careful, this will overwrite any existing file with the same name.
Required Configs
- config.metagenomics_studies_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==False
>>> db=Database(config=configs.Database(metagenomics_studies_db=os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv")))
>>> db.initialize_metagenomics_studies_db()
>>> assert pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").shape[0]==0
>>> assert set(pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").columns)==set(["name","study_type","microbiome","sample_accession","comments","study_accession"])
>>> os.remove(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))
Source code in adtoolbox/core.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
|
initialize_protein_db()
This function intializes ADToolbox's protein database by creating an empty fasta file. Be careful, this will overwrite any existing file with the same name. Logically, this needs method needs config.protein_db to be defined.
Required Configs
- config.protein_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==False # This is just to make sure that the following lines create the file
>>> db=Database(config=configs.Database(protein_db=os.path.join(Main_Dir,"protein_test_db.fasta"))) # point to a test non-existing file
>>> db.initialize_protein_db() # initialize the protein database
>>> assert os.path.exists(os.path.join(Main_Dir,"protein_test_db.fasta"))==True # check if the file is created
>>> os.remove(os.path.join(Main_Dir,"protein_test_db.fasta")) # remove the file to clean up
Source code in adtoolbox/core.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
|
initialize_reaction_db()
This function intializes ADToolbox's reaction database by creating an empty tsv file. Be careful, this will overwrite any existing file with the same name.
Required Configs
- config.reaction_db
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"reaction_test_db.tsv"))==False
>>> db=Database(config=configs.Database(reaction_db=os.path.join(Main_Dir,"reaction_test_db.tsv")))
>>> db.initialize_reaction_db()
>>> assert pd.read_table(os.path.join(Main_Dir,"reaction_test_db.tsv"),delimiter="\t").shape[0]==0
>>> assert set(pd.read_csv(os.path.join(Main_Dir,"reaction_test_db.tsv"),delimiter="\t").columns)==set(["ec_numbers","seed_ids","reaction_names","adm1_reaction","e_adm_reactions","pathways"])
>>> os.remove(os.path.join(Main_Dir,"reaction_test_db.tsv"))
Source code in adtoolbox/core.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
|
proteins_from_ec(ec_number)
This function returns a dictionary of protein sequences for a given EC number. The keys are the uniprot ids and ec number compatible with ADToolbox protein database and the values are the protein sequences. Since ADToolbox deals with microbial process, only bacterial and archaeal proteins are considered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ec_number |
str
|
The EC number. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary of protein sequences. |
dict
|
Examples:
>>> db=Database()
>>> protein_seqs=db.proteins_from_ec("1.1.1.1")
>>> assert len(protein_seqs)>0
>>> assert list(protein_seqs.keys())[0].split("|")[1]=="1.1.1.1"
Source code in adtoolbox/core.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
remove_experiment_from_experiments_db(field_name, query)
This function removes experiments that contain the query in the given column, field name, from the experiments database.
Required Configs
- config.experimental_data_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Examples:
>>> import os,json
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.tsv"))==False
>>> db=Database(config=configs.Database(experimental_data_db=os.path.join(Main_Dir,"experiments_test_db.json")))
>>> experiment=Experiment(name="test_study",time=[0,1,2],variables=[2,6],data= [[1,2,3],[4,5,6]],reference="test")
>>> db.add_experiment_to_experiments_db(experiment)
>>> assert os.path.exists(os.path.join(Main_Dir,"experiments_test_db.json"))==True
>>> assert os.path.getsize(os.path.join(Main_Dir,"experiments_test_db.json"))>0
>>> db.remove_experiment_from_experiments_db("name","test_study")
>>> assert pd.read_json(os.path.join(Main_Dir,"experiments_test_db.json")).shape[0]==0
>>> os.remove(os.path.join(Main_Dir,"experiments_test_db.json"))
Source code in adtoolbox/core.py
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
|
remove_feed_from_feed_db(field_name, query)
This function removes studyes that contain the query in the given column, field name, from the feed database.
Required Configs
- config.feed_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==False
>>> db=Database(config=configs.Database(feed_db=os.path.join(Main_Dir,"feed_test_db.tsv")))
>>> feed=Feed(name="test_feed",carbohydrates=10,lipids=20,proteins=30,tss=80,si=10,xi=30,reference="test")
>>> db.add_feed_to_feed_db(feed)
>>> assert os.path.exists(os.path.join(Main_Dir,"feed_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter="\t").shape[0]>0
>>> db.remove_feed_from_feed_db("name","test_feed")
>>> assert pd.read_table(os.path.join(Main_Dir,"feed_test_db.tsv"),delimiter="\t").shape[0]==0
>>> os.remove(os.path.join(Main_Dir,"feed_test_db.tsv"))
Source code in adtoolbox/core.py
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
|
remove_metagenomics_study_from_metagenomics_studies_db(field_name, query)
This function removes studies that contain the query in the given column, field name, from the metagenomics studies database.
Required Configs
- config.metagenomics_studies_db
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_name |
str
|
The name of the column to query. |
required |
query |
str
|
The query string. |
required |
Examples:
>>> import os
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==False
>>> db=Database(config=configs.Database(metagenomics_studies_db=os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv")))
>>> metagenomics_study=MetagenomicsStudy(name="test_study",study_type="metagenomics",microbiome="anaerobic digester",sample_accession="test",comments="test",study_accession="test")
>>> db.add_metagenomics_study_to_metagenomics_studies_db(metagenomics_study)
>>> assert os.path.exists(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))==True
>>> assert pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").shape[0]>0
>>> db.remove_metagenomics_study_from_metagenomics_studies_db("name","test_study")
>>> assert pd.read_table(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"),delimiter="\t").shape[0]==0
>>> os.remove(os.path.join(Main_Dir,"metagenomics_studies_test_db.tsv"))
Source code in adtoolbox/core.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
|
8. Metagenomics
Here is a schematic view of core.Metagenomics API:
This is the main class for Metagenomics functionality of ADToolbox. This class contains all the methods required for metagenomics analysis that ADToolbox offers.
Source code in adtoolbox/core.py
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 |
|
__init__(config)
In order to instntiate an object from this class, you need to provide a metagenomics configs object from the configs module : configs.Metagenomics. Information for inputs and of each method is then obtained from the corresponding configs object. The following example shows how to instantiate an object from this class using the default configs object:
Examples:
>>> from adtoolbox import core, configs
>>> config=configs.Metagenomics() ### This uses default arguments. Refer to configs module for more information.
>>> metagenomics=core.Metagenomics(config)
>>> assert type(metagenomics)==core.Metagenomics
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
configs.Metagenomics
|
A metagenomics configs object from configs module. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in adtoolbox/core.py
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
|
align_genome_to_protein_db(address, outdir, name, container='None')
This is a function that will align a genome to the Protein Database of the ADToolbox using mmseqs2. If you want to save the scripts, set save to True. Note that the alignment tables will be saved in any case. Note that this function uses mmseqs2 to align the genomes to the protein database. So, to run this function without any container you need to have mmseqs2 installed on your system. However, if you want to run this function with a container, you need to have the container installed on your system. You may select from "None", "docker", "singularity".
Requires
config.genome_alignment_output: The path to the directory where the alignment results will be saved.
config.protein_db: The path to the ADToolbox protein database in fasta.
config.adtoolbox_docker: The name of the docker image to be used by ADToolbox (Only if using Docker as container).
config.adtoolbox_singularity: The name of the singularity image to be used by ADToolbox (Only if using Singularity as container).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address |
str
|
The address of the genome fasta file. The file must be in fasta format. |
required |
run |
bool
|
Whether to run the alignment. Defaults to True. |
required |
save |
bool
|
Whether to save the alignment scripts. Defaults to True. |
required |
container |
str
|
The container to use. Defaults to "None". You may select from "None", "docker", "singularity". |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A dictionary containing the alignment files. |
str |
str
|
The bash script that is used to align the genomes or to be used to align the genomes. |
Source code in adtoolbox/core.py
1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 |
|
align_short_reads_to_protein_db(query_seq, alignment_file_name, container='None')
This function aligns shotgun short reads to the protein database of the ADToolbox using mmseqs2. mmseqs wrappers in utils are used to perform this task. The result of this task is an alignment table.
Required Configs
protein_db_mmseqs (str): The address of the existing/to be created protein database of the ADToolbox for mmseqs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_seq |
str
|
The address of the query sequence. |
required |
alignment_file_name |
str
|
The name of the alignment file. |
required |
container |
str
|
The container to use. Defaults to "None". You may select from "None", "docker", "singularity". |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The bash script that is used to align the genomes or to be used to align the genomes. |
str |
str
|
The address of the alignment file. |
Source code in adtoolbox/core.py
1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 |
|
align_to_gtdb(query_dir, output_dir, container='None')
This function takes the representative sequences of the top k features and generates the script to align these feature sequences to gtdb using VSEARCH. If you intend to run this you either need to have VSEARCH installed or run it with a container option. You can use either the docker or singularity as container options. Otherwise you can use None and run it with the assumption that VSEARCH is installed. If you only want the script and not to run it, set run to False.
Required Configs
config.gtdb_dir_fasta: The path to the gtdb fasta database.
config.vsearch_similarity: The similarity threshold for the alignment to be used by VSEARCH.
config.vsearch_threads: The number of threads to be used by VSEARCH.
config.adtoolbox_docker: The name of the docker image to be used by ADToolbox (Only if using Docker as container).
config.adtoolbox_singularity: The name of the singularity image to be used by ADToolbox (Only if using Singularity as container).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container |
str
|
The container to use. Defaults to "None". |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The script that is supposed to be running later. |
Source code in adtoolbox/core.py
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
|
assign_ec_to_genome(alignment_file)
This function takes an alignment file and assigns the EC numbers to the genomes based on the alignment file, and the e-adm groupings of the EC numbers. The output is a dictionary where the keys e-adm reactions and the values are the EC numbers, that are found in the genome and are grouped under the e-adm reaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alignment_file |
str
|
The address of the alignment file. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the e-adm reactions and the EC numbers that are found in the genome and are grouped under the e-adm reaction. |
Source code in adtoolbox/core.py
1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 |
|
calculate_group_abundances(elements_feature_abundances, rel_abund)
This method is defined to calculate the features for each sample given: 1) The relative abundances of the genomes in each sample: - In this dictionary the keys are the sample names and the values are dictionaries where the keys are the genome names and the values are the relative abundances of the genomes in the sample. 2) The relative abundances of the elements in each genome. - In this dictionary the keys are the genome names and the values are dictionaries where the keys are the element names and the values are the relative abundances of the elements in the genome.
Required Configs
None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elements_feature_abundances |
dict[str, dict]
|
A dictionary containing the relative abundances of the elements in each genome. |
required |
rel_abund |
dict[str, dict]
|
A dictionary containing the relative abundances of the genomes in each sample. |
required |
Returns:
Type | Description |
---|---|
dict[str, dict[str, float]]
|
dict[str,dict[str,float]]: A dictionary containing the relative abundances of the elements in each sample. |
Source code in adtoolbox/core.py
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 |
|
download_genome(identifier, output_dir, container='None')
This function downloads the genomes from NCBI using the refseq/genbank identifiers. Note that this function uses rsync to download the genomes.
Required Configs
config.genomes_base_dir: The path to the base directory where the genomes will be saved.
config.adtoolbox_docker: The name of the docker image to be used by ADToolbox (Only if using Docker as container).
config.adtoolbox_singularity: The name of the singularity image to be used by ADToolbox (Only if using Singularity as container).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
list[str]
|
The list of identifiers for the genomes. It can be either refseq or genbank. |
required |
container |
str
|
The container to use. Defaults to "None". You may select from "None", "docker", "singularity". |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The bash script that is used to download the genomes or to be used to download the genomes. |
Source code in adtoolbox/core.py
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
|
extract_ec_from_alignment(alignment_file)
This function extracts the number of times an EC number is found in the alignment file when aligned to ADToolbox protein database.
Required Configs
config.e_value: The e-value threshold for the filtering the alignment table.
config.bit_score: The bit score threshold for the filtering the alignment table.
config.ec_counts_from_alignment: The address of the json file that the results will be saved in.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alignment_file |
str
|
The address of the alignment file. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, int]
|
A dictionary of EC numbers and their counts. |
Source code in adtoolbox/core.py
1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 |
|
extract_genome_info(endpattern='genomic.fna.gz', filters={'INCLUDE': [], 'EXCLUDE': ['cds', 'rna']})
This function extracts the genome information from the genomes base directory. The output is a dictionary where the keys are the genome IDs and the values are the paths to the genome files.
Required Configs
config.genomes_base_dir: The path to the base directory where the genomes are saved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
genome_info |
dict[str, str]
|
A dictionary containing the genome information. |
required |
endpattern |
str
|
The end pattern of the genome files. Defaults to "genomic.fna.gz". |
'genomic.fna.gz'
|
filters |
dict
|
The filters to be applied to the genome files. This filter must be a |
{'INCLUDE': [], 'EXCLUDE': ['cds', 'rna']}
|
dictionary |
with two keys
|
INCLUDE and EXCLUDE. The values of these keys must be lists of strings. |
required |
Defaults |
to {"INCLUDE"
|
[],"EXCLUDE":["cds","rna"]}. This defult is compatible with the genomes downloaded |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str,str]: A dictionary containing the address of the genomes that are downloaded or to be downloaded. |
Source code in adtoolbox/core.py
1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
|
extract_relative_abundances(feature_table_dir, sample_names=None, top_k=-1)
This method extracts the relative abundances of the features in each sample from the feature table. The feature table must follow the qiime2 feature-table format. NOTE: The final feature abundances sum to 1 for each sample.
Required Configs
None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature_table_dir |
str
|
The path to the feature table. |
required |
sample_names |
Union[list[str], None]
|
The list of sample names. to be considered. If None, all the samples will be considered. Defaults to None. |
None
|
top_k |
int
|
The number of top features to be used. If -1, all the features will be used. Defaults to -1. |
-1
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the relative abundances of the features in each sample. |
Source code in adtoolbox/core.py
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 |
|
find_top_taxa(sample_name, treshold, mode='top_k')
This function needs three inputs from qiime: 1. feature table: This is the abundance of each feature in each sample (TSV). 2. taxonomy table: This is the taxonomy of each feature (TSV). 3. rep seqs: This is the representative sequence of each feature (fasta). It then finds the top k features or features that form specific percentile of the community of the sample.
Required Configs
config.feature_table_dir: The path to the feature table tsv file.
config.taxonomy_table_dir: The path to the taxonomy table tsv file.
config.rep_seq_fasta: The path to the representative sequence fasta file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample_name |
str
|
The name of the sample. |
required |
threshold |
int, float
|
The threshold for the top k or the percentile. |
required |
mode |
str
|
Whether to find the top k features or features that form specific percentile of the community of the sample. Defaults to 'top_k'. Options: 'top_k', 'percentile'. |
'top_k'
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary of the top k features and their taxonomy. |
Source code in adtoolbox/core.py
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 |
|
get_cod_from_ec_counts(ec_counts)
This function takes a json file that comtains ec counts and converts it to ADM microbial agents counts.
Required Configs
config.adm_mapping : A dictionary that maps ADM reactions to ADM microbial agents.
config.csv_reaction_db : The address of the reaction database of ADToolbox.
config.adm_cod_from_ec : The address of the json file that the results will be saved in.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ec_counts |
dict
|
A dictionary containing the counts for each ec number. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the ADM microbial agents counts. |
Source code in adtoolbox/core.py
1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 |
|
get_genomes_from_gtdb_alignment(alignment_dir)
This function takes the alignment file generated from the align_to_gtdb function and generates the the genome information using the GTDB-Tk. In the outputted dictionary, the keys are feature ids and the values are the representative genomes.
Required Configs
config.align_to_gtdb_outputs_dir: The path to the directory where the outputs of the align_to_gtdb function are saved.
config.feature_to_taxa: The path to the json file where the json file including feature ids and the representative genomes will be saved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save |
bool
|
Whether to save the json file or not. Defaults to True. |
required |
Source code in adtoolbox/core.py
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 |
|
run_qiime2_from_sra(read_1, read_2, sample_name=None, manifest_dir=None, workings_dir=None, save_manifest=True, container='None')
This method uses the input fastq files to run qiime2. The method uses the qiime2 template scripts that are provided in pkg_data module. The method also creates a manifest file for qiime2. The manifest file is created based on the input fastq files.
Required Configs
config.qiime2_single_end_bash_str: The path to the qiime2 bash script for single end reads.
config.qiime2_paired_end_bash_str: The path to the qiime2 bash script for paired end reads.
config.qiime_classifier_db: The path to the qiime2 classifier database.
config.qiime2_docker_image: The name of the docker image to be used by ADToolbox (Only if using Docker as container).
config.qiime2_singularity_image: The name of the singularity image to be used by ADToolbox (Only if using Singularity as container).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
read_1 |
str
|
directory of the forward reads file |
required |
read_2 |
str
|
directory of the reverse reads file. This is provided only if the reads are paired end. If this is not the case, |
required |
sample_name |
str
|
The name of the sample. If None, the name of the sample will be the name of the directory where the fastq files are located. Defaults to None. |
None
|
manifest_dir |
str
|
The directory where the manifest file will be saved. If None, the manifest file will be saved in the same directory as the fastq files. Defaults to None. |
None
|
workings_dir |
str
|
The directory where the qiime2 outputs will be saved. If None, the outputs will be saved in the same directory as the fastq files. Defaults to None. |
None
|
container |
str
|
If you want to run the qiime2 commands in a container, specify the container name here. Defaults to 'None'. |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
qiime2_bash_str |
str
|
The bash script that will be used to run qiime2 in python string format |
manifest |
dict
|
The manifest file that will be used to run qiime2 in python dictionary format |
Source code in adtoolbox/core.py
2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 |
|
seqs_from_sra(accession, target_dir, container='None')
This method downloads the fastq files from the SRA database using the accession number (ONLY SAMPLE ACCESSION AND NOT PROJECT ACCESSION) of the project or run. The method uses the fasterq-dump tool to download the fastq files. This method also extracts the sample metadata from the SRA database for future use.
NOTE In order for this method to work without any container, you need to have the SRA toolkit installed on your system or
at least have prefetch and fasterq-dump installed on your system. For more information on how to install the SRA toolkit, please refer to the following link: https://github.com/ncbi/sra-tools
Required Configs
None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
accession |
str
|
The accession number of the SRA project or run |
required |
target_dir |
str
|
The directory where the fastq files will be downloaded |
required |
container |
str
|
The containerization tool that will be used to run the bash scripts. Defaults to "None". Options are "None","docker","singularity" |
'None'
|
Returns:
Name | Type | Description |
---|---|---|
prefetch_script |
str
|
The bash script that will be used to download the SRA files in python string format |
sample_metadata |
dict
|
A dictionary that contains the sample metadata |
Source code in adtoolbox/core.py
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
|
adm
Here is a schematic view of adm API:
You can access this module by:
from adtoolbox import adm
This module includes the following classes:
Model
Any kinetic model could be an instance of this class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_parameters |
dict
|
a dictionary which contains model parameters |
required |
base_parameters |
dict
|
a dictionary which contains base paramters |
required |
initial_conditions |
dict
|
a dictionary containing inlet conditions for all species |
required |
inlet_conditions |
dict
|
a dictionary containing inlet conditions for all species |
required |
feed |
Feed
|
a Feed instance which contains the feed information |
required |
reactions |
list
|
a list containing all types of reactions |
required |
species |
list
|
a list containing all species |
required |
ode_system |
Callable
|
a callable which outputs the ODE system compatible with Scipy.integrate.solve_ivp |
required |
build_stoichiometric_matrix(Callable) |
a callable which builds the stoichiometric matrix |
required | |
control_state |
dict
|
a dictionary containing the states that are desired to be constant. Defaults to {}. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Model | returns a model instance for downstream purposes. |
Source code in adtoolbox/adm.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
|
s
property
Returns the stoichiometric matrix of a model
build_cobra_model(address=None)
This method builds a cobra model from an instance of Model. One particular use of such models is to build an escher map from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address |
str
|
The address to save the model. Defaults to None. |
None
|
Source code in adtoolbox/adm.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
|
copy()
Returns a copy of the model
Source code in adtoolbox/adm.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
csv_report(sol, address)
Converts the results to a pandas data frame then to a csv
Source code in adtoolbox/adm.py
584 585 586 587 588 |
|
dash_app(sol, escher_map=os.path.join(PKG_DATA, 'Modified_ADM_Map.json'), cobra_model=os.path.join(PKG_DATA, 'Modified_ADM_Model.json'), **kwargs)
A method that creates the dash web app for a model based on an ODE solution.
Examples:
>>> import numpy as np
>>> reactions=['rxn1','rxn2']
>>> species=['a','b','c']
>>> initial_conditions={'a':.001,'b':.002,'c':.003}
>>> inlet_conditions={'a_in':.001,'b_in':.002,'c_in':.003}
>>> model_parameters={'k1':0.001,'k2':0.002}
>>> base_parameters={'T':0.1}
>>> feed=Feed(10,20,20,20)
>>> def build_stoiciometric_matrix(base_parameters,model_parameters,reactions,species):
... s = np.zeros((len(species), len(reactions)))
... s[[0,1],0]=[-1,0.001]
... s[[1,2],1]=[-5,1]
... return s
>>> def ode_system(t,c,Model1):
... v = np.zeros((len(Model1.reactions), 1))
... v[0]=Model1.model_parameters['k1']*c[0]*Model1.base_parameters['T']/1000
... v[1]=Model1.model_parameters['k2']*c[1]/1000
... dCdt=np.matmul(Model1.S,v)
... return dCdt[:, 0]
>>> m= Model(model_parameters,base_parameters,initial_conditions,inlet_conditions,reactions,species,ODE_System,Build_Stoiciometric_Matrix)
>>> m.solve_model((0,.1),np.linspace(0,0.1,10),method='RK45')['status']==0
True
>>> m.dash_app(m.solve_model(np.linspace(0,30,1000)))
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sol |
scipy.integrate._ivp.ivp.OdeResult
|
The solution of the ODE system. This should be the output of the solve_model method. |
required |
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This method does not return anything. |
Source code in adtoolbox/adm.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
|
plot(Sol, type='Line')
A function which returns a plot of the solution from the ODE
Source code in adtoolbox/adm.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
solve_model(t_eval, method='BDF')
Function to solve the model.
Examples:
>>> import numpy as np
>>> reactions=['rxn1','rxn2']
>>> species=['a','b','c']
>>> initial_conditions={'a':.001,'b':.002,'c':.003}
>>> inlet_conditions={'a_in':.001,'b_in':.002,'c_in':.003}
>>> model_parameters={'k1':0.001,'k2':0.002}
>>> base_parameters={'T':0.1}
>>> feed=Feed(10,20,20,20)
>>> def build_stoiciometric_matrix(base_parameters,model_parameters,reactions,species):
... s = np.zeros((len(species), len(reactions)))
... s[[0,1],0]=[-1,0.001]
... s[[1,2],1]=[-5,1]
... return s
>>> def ode_system(t,c,Model1):
... v = np.zeros((len(Model1.reactions), 1))
... v[0]=Model1.model_parameters['k1']*c[0]*Model1.base_parameters['T']/1000
... v[1]=Model1.model_parameters['k2']*c[1]/1000
... dCdt=np.matmul(Model1.S,v)
... return dCdt[:, 0]
>>> m= Model(model_parameters,base_parameters,initial_conditions,inlet_conditions,reactions,species,ODE_System,Build_Stoiciometric_Matrix)
>>> m.solve_model((0,.1),np.linspace(0,0.1,10),method='RK45')['status']==0
True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t_eval |
np.ndarray
|
Time points at which the solution is reported |
required |
method |
str
|
The method used to solve the ODE. Defaults to "BDF". |
'BDF'
|
Returns:
Type | Description |
---|---|
scipy.integrate._ivp.ivp.OdeResult
|
scipy.integrate._ivp.ivp.OdeResult: Returns the results of the simulation being run and gives optimized paramters. |
Source code in adtoolbox/adm.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
update_parameters(model_parameters=None, base_parameters=None, initial_conditions=None, inlet_conditions=None)
This method updates the parameters of the model. Each argument can be a dictionary containing the parameters to be updated. NOTE: It is important to note that you have to separate different kind parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_parameters |
dict
|
a dictionary which contains the model parameters to be updated as keys and their values as values. |
None
|
base_parameters |
dict
|
a dictionary which contains the base parameters to be updated as keys and their values as values. |
None
|
initial_conditions |
dict
|
a dictionary containing the initial conditions to be updated as keys and their values as values. |
None
|
inlet_conditions |
dict
|
a dictionary containing the inlet conditions to be updated as keys and their values as values. |
None
|
Returns:
Name | Type | Description |
---|---|---|
None |
None
|
This method does not return anything. |
Source code in adtoolbox/adm.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
adm1_ode_sys(t, c, model)
The ODE system for the original ADM. No testing is done.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
a matrix of zeros to be filled |
required |
c |
np.ndarray
|
an array of concentrations to be filled |
required |
Model |
Model
|
The an instance of Model to calculate ODE with |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: The output is dCdt, the change of concentration with respect to time. |
Source code in adtoolbox/adm.py
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
build_adm1_stoiciometric_matrix(base_parameters, model_parameters, reactons, species, feed, nitrogen_limited=False)
This function builds the stoichiometric matrix for the ADM1 Model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_parameters |
dict
|
a dictionary containing the base parameters |
required |
model_parameters |
dict
|
a dictionary containing the model parameters |
required |
reactons |
list
|
a list containing all reactions |
required |
species |
list
|
a list containing all species |
required |
feed |
Feed
|
a Feed instance which contains the feed information |
required |
nitrogen_limited |
bool
|
A boolean which indicates whether the model is nitrogen limited. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: Returns the stoichiometric matrix of the ADM1 model. |
Source code in adtoolbox/adm.py
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
|
build_e_adm_2_stoichiometric_matrix(base_parameters, model_parameters, reactions, species, feed, nitrogen_limited=False)
This function builds the stoichiometric matrix for e-ADM2 Model.
Model Parameters (dict): a dictionary which contains model parameters
base_parameters (dict): a dictionary which contains base paramters
Initial Conditions (dict): a dictionary containing inlet conditions for all species
Inlet Conditions (dict): a dictionary containing inlet conditions for all species
reactions (list): a list containing all of the reaction names
species (list): a list containing all species
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: Returns an matrix of stochiometic values. |
Source code in adtoolbox/adm.py
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 |
|
build_e_adm_stoiciometric_matrix(base_parameters, model_parameters, reactions, species, feed, nitrogen_limited=False)
This function builds the stoichiometric matrix for the e_ADM Model.
Model Parameters (dict): a dictionary which contains model parameters
base_parameters (dict): a dictionary which contains base paramters
Initial Conditions (dict): a dictionary containing inlet conditions for all species
Inlet Conditions (dict): a dictionary containing inlet conditions for all species
reactions (list): a list containing all of the reaction names
species (list): a list containing all species
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: Returns an matrix of stochiometic values. |
Source code in adtoolbox/adm.py
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 |
|
e_adm_2_ode_sys(t, c, model)
This function is used to build the ODEs of the e-adm2 model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
a matrix of zeros to be filled |
required |
c |
np.ndarray
|
an array of concentrations to be filled |
required |
Model |
Model
|
The model to calculate ODE with |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: The output is dCdt, the change of concentration with respect to time. |
Source code in adtoolbox/adm.py
1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 |
|
e_adm_ode_sys(t, c, model)
This function is used to build the ODEs of the e_adm model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
float
|
a matrix of zeros to be filled |
required |
c |
np.ndarray
|
an array of concentrations to be filled |
required |
Model |
Model
|
The model to calculate ODE with |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: The output is dCdt, the change of concentration with respect to time. |
Source code in adtoolbox/adm.py
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 |
|