bunchastuff

This commit is contained in:
Ziad Arafat committed 2024-04-09 16:18:55 -06:00
1 parent 0a4cbf1e47
commit d05a8c26eb
10 files changed
+227 -29

No files matched your search

+99
View File
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from PyPDF2 import PdfReader, PdfWriter\n",
"\n",
"def append_pdfs(input_pdf1, input_pdf2, output_pdf):\n",
" # Create PdfReader objects for both input PDFs\n",
" pdf1 = PdfReader(input_pdf1)\n",
" pdf2 = PdfReader(input_pdf2)\n",
"\n",
" # Create a PdfFileWriter object for the output PDF\n",
" pdf_writer = PdfWriter()\n",
"\n",
" # Append pages from the first PDF\n",
" for page_num in range(len(pdf1.pages)):\n",
" pdf_writer.add_page(pdf1.pages[page_num])\n",
"\n",
" # Append pages from the second PDF\n",
" for page_num in range(len(pdf2.pages)):\n",
" pdf_writer.add_page(pdf2.pages[page_num])\n",
"\n",
" # Write the combined PDF to the output file\n",
" with open(output_pdf, 'wb') as output_file:\n",
" pdf_writer.write(output_file)\n",
" \n",
"def compile_lab_report(first_page, appendix_a, appendix_b, output_pdf):\n",
" # Create PdfReader objects for all input PDFs\n",
" pdf1 = PdfReader(first_page)\n",
" pdf2 = PdfReader(appendix_a)\n",
" pdf3 = PdfReader(appendix_b)\n",
" \n",
" # Create a PdfFileWriter object for the output PDF\n",
" pdf_writer = PdfWriter()\n",
" \n",
" # Append pages from the first PDF\n",
" for page_num in range(len(pdf1.pages)):\n",
" pdf_writer.add_page(pdf1.pages[page_num])\n",
" \n",
" # Append pages from the second PDF\n",
" for page_num in range(len(pdf2.pages)):\n",
" pdf_writer.add_page(pdf2.pages[page_num])\n",
" \n",
" # Append pages from the third PDF\n",
" for page_num in range(len(pdf3.pages)):\n",
" pdf_writer.add_page(pdf3.pages[page_num])\n",
" \n",
" # Write the combined PDF to the output file\n",
" with open(output_pdf, 'wb') as output_file:\n",
" pdf_writer.write(output_file)\n",
" \n",
" \n",
"def compile_all_pdfs(list_of_pdfs):\n",
" # Create a PdfFileWriter object for the output PDF\n",
" pdf_writer = PdfWriter()\n",
" \n",
" # Iterate over the list of PDFs\n",
" for pdf_file in list_of_pdfs:\n",
" # Create a PdfReader object for the current PDF\n",
" pdf = PdfReader(pdf_file)\n",
" \n",
" # Append each page from the current PDF\n",
" for page_num in range(len(pdf.pages)):\n",
" pdf_writer.add_page(pdf.pages[page_num])\n",
" \n",
" # Write the combined PDF to the output file\n",
" with open('compiled_pdf.pdf', 'wb') as output_file:\n",
" pdf_writer.write(output_file)\n",
" \n",
"\n",
"# # compile lab report\n",
"# compile_lab_report(\n",
"# './Evolution of Resistance to Antibiotics in Bacteria Lab Report.pdf',\n",
"# './AppendixA.pdf',\n",
"# './AppendixB.pdf',\n",
"# 'compiled_lab_report.pdf'\n",
"# )\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file not shown.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.
+79 -29
View File
@@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -150,6 +150,20 @@
" docs.append(create_table(list(products.keys())[key], product))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Subspecies 1|Subspecies 2|Trial 1|Trial 2|Trial 3|Average\n",
"|---|---|---|---|---|---|\n",
"schweinfurthii|schweinfurthii|1.47|1.77|1.77|1.67\n",
"verus|verus|4.41|6.18|7.06|5.88\n",
"troglodytes|troglodytes|1.47|1.18|1.47|1.38\n",
"schweinfurthii|verus|10.59|9.41|9.73|9.91\n",
"schweinfurthii|troglodytes|6.19|4.72|5.6|5.51\n",
"verus|troglodytes|11.47|11.47|11.47|11.47"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -157,19 +171,21 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('schweinfurthii', 'schweinfurthii'): 1.67%\n",
"('verus', 'verus'): 5.88%\n",
"('troglodytes', 'troglodytes'): 1.38%\n",
"('schweinfurthii', 'verus'): 9.91%\n",
"('schweinfurthii', 'troglodytes'): 5.51%\n",
"('verus', 'troglodytes'): 11.47%\n"
"Subspecies 1|Subspecies 2|Trial 1|Trial 2|Trial 3|Average\n",
"|---|---|---|---|---|---|\n",
"schweinfurthii|schweinfurthii|1.47|1.77|1.77|1.67\n",
"verus|verus|4.41|6.18|7.06|5.88\n",
"troglodytes|troglodytes|1.47|1.18|1.47|1.38\n",
"schweinfurthii|verus|10.59|9.41|9.73|9.91\n",
"schweinfurthii|troglodytes|6.19|4.72|5.6|5.51\n",
"verus|troglodytes|11.47|11.47|11.47|11.47\n"
]
}
],
@@ -213,14 +229,41 @@
" }\n",
"}\n",
"\n",
"averages = {}\n",
"def matrix_to_markdown_table(matrix, header):\n",
" table = []\n",
" table.append(\"|\".join(header))\n",
" header_separator = \"|\" + \"|\".join([\"---\" for _ in header]) + \"|\"\n",
" table.append(header_separator)\n",
" for row in matrix:\n",
" table.append(\"|\".join([str(cell) for cell in row]))\n",
" return \"\\n\".join(table)\n",
"\n",
"for subspecies, comparisons in chimp_subspecies_.items():\n",
" averages[subspecies] = sum(comparisons.values()) / len(comparisons)\n",
"def extract_data_into_matrix(data):\n",
" table = []\n",
" for subspecies, comparisons in data.items():\n",
" comparisons_value_list = list(comparisons.values())\n",
" trial_1 = round(comparisons_value_list[0], 2)\n",
" trial_2 = round(comparisons_value_list[1], 2)\n",
" trial_3 = round(comparisons_value_list[2], 2)\n",
" average = round(sum(comparisons_value_list) / len(comparisons_value_list), 2)\n",
" \n",
" table.append([trial_1, trial_2, trial_3, average])\n",
" return table\n",
" \n",
"for key, value in averages.items():\n",
" print(f\"{key}: {value:.2f}%\")\n",
"\n",
"\n",
"\n",
"\n",
"header = [\"Subspecies 1\", \"Subspecies 2\", \"Trial 1\", \"Trial 2\", \"Trial 3\", \"Average\"]\n",
"table = matrix_to_markdown_table(\n",
" extract_data_into_matrix(chimp_subspecies_), \n",
" header\n",
")\n",
"\n",
"print(table)\n",
" \n",
" \n",
"\n",
" "
]
},
@@ -250,19 +293,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('african', 'african'): 2.77%\n",
"('european', 'european'): 2.52%\n",
"('asian', 'asian'): 2.77%\n",
"('african', 'european'): 1.51%\n",
"('african', 'asian'): 1.38%\n",
"('european', 'asian'): 2.26%\n"
"ename": "SyntaxError",
"evalue": "invalid syntax. Perhaps you forgot a comma? (1135939403.py, line 48)",
"output_type": "error",
"traceback": [
"\u001b[0;36m Cell \u001b[0;32mIn[14], line 48\u001b[0;36m\u001b[0m\n\u001b[0;31m extract_data_into_matrix(human_subspecies_)[][2:5]\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax. Perhaps you forgot a comma?\n"
]
}
],
@@ -302,13 +341,24 @@
" }\n",
"}\n",
"\n",
"averages_human = {}\n",
"# convert matrix to output that can be pasted into a Word table\n",
"def matrix_to_flatten_list(matrix):\n",
" return [item for sublist in matrix for item in sublist]\n",
"\n",
"for subspecies, comparisons in human_subspecies_.items():\n",
" averages_human[subspecies] = sum(comparisons.values()) / len(comparisons)\n",
" \n",
"for key, value in averages_human.items():\n",
" print(f\"{key}: {value:.2f}%\")"
"\n",
"header = [\"Trial 1\", \"Trial 2\", \"Trial 3\", \"Average\"]\n",
"table = matrix_to_markdown_table(\n",
" extract_data_into_matrix(human_subspecies_)[2:5],\n",
" header\n",
")\n",
"\n",
"table_word = matrix_to_flatten_list(\n",
" extract_data_into_matrix(human_subspecies_)[2:5]\n",
")\n",
"\n",
"print(table_word)\n",
"\n",
"\n"
]
},
{
+43
View File
@@ -0,0 +1,43 @@
# Human Race Lab Report
## Introduction
### Hypothesis
In humans, there are distinct races or subspecies, that have biological genetic markers.
### Predicted Results
When comparing 3 groups of humans, the genetic differences between individuals in different groups will be greater than the genetic differences between individuals in the same group.
## Results
(see end of document for data)
## Discussion
### Conclusion
According to our lab manual, the hypothesis was that there are distinct, biological genetic markers that separate humans into different races or subspecies (Marion & Preszler 2019). The predicted results were that the genetic differences between individuals in different groups would be greater than the genetic differences between individuals in the same group.
However, the observed results from Table 19-2 and the cladogram of human sequences (Figure 19-2) showed that the genetic differences between individuals in different groups are not significantly greater than the genetic differences between individuals in the same group.
Therefore, the hypothesis that there are distinct genetic markers separating humans into different races is not supported by the data. The evidence from Table 19-2 and Figure 19-2 demonstrates that there is not a genetic basis for the separation of humans into different subspecies as one would expect such as in the case of different subspecies of chimpanzees in table 19-1 and the cladogram of chimpanzee sequences in Figure 19-1. There are even cases where the difference between individuals in the same group is greater than the difference between individuals in different groups.
### Implications
If the division of humans into different races cannot be based on a genetic distinction between different populations, then the basis of "race" must be social, cultural, and historical factors.
With respect to humans, the concept of "race" does not have a useful function in society today and should be eliminated as a method of categorizing people. However, it is still important to recognize that there has been a long history of racial discrimination and inequality based on these social constructs and that these issues need to be addressed through social justice and equity measures.
## References
- Marion, A. L., & Preszler, R. W. (2019). Biology 101 Human Biology & Society Laboratory Manual (9th ed., Vols. 1–9). Harden-McNeil
## Data
Figure 19-2: Cladogram of human sequences
![Human Cladogram](./humangram.png)
Figure 19-1: Cladogram of chimpanzee sequences
![Chimpanzee Cladogram](./chimpgram.png)
Binary file not shown.
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
3.4 0.75 4.15 2.77
1.89 2.26 3.4 2.52
2.64 2.26 3.4 2.77
1.13 2.26 1.13 1.51
0.75 1.89 1.51 1.38
1.89 2.26 2.64 2.26
File renamed without changes.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 127 KiB