Skip to content

Commit

Permalink
object-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
telatin committed May 31, 2024
1 parent 50f3e7d commit 32e31cc
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions first-steps/05-object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -75,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 23,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -107,7 +107,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -142,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 25,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -209,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -263,6 +263,45 @@
" protein.append(self.codon_table.get(codon, 'X')) # 'X' for unknown codons\n",
" return ''.join(protein)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"here we added a custom method **translate** and the equality comparison. Let's try again to compare the sequences:"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sequences are the same, and the protein sequence is DARWIN*\n"
]
}
],
"source": [
"dna1 = DNASequence(\"GATGCGcgctggattaactaa\", \"SampleSeq\", \"Example description\")\n",
"dna2 = DNASequence(\"gatgcgcgctggattaactaa\", \"SampleSeq\")\n",
"\n",
"if (dna1 == dna2):\n",
" print(\"Sequences are the same, and the protein sequence is \", dna1.translate())\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Try yourself\n",
"\n",
"now add a method to return the gc content"
]
}
],
"metadata": {
Expand Down

0 comments on commit 32e31cc

Please sign in to comment.