From 2192b4c9a965a1874fe4523dabb45fcfccb54f91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bertrand=20N=C3=A9ron?= <bneron@pasteur.fr>
Date: Fri, 21 Nov 2014 19:03:19 +0100
Subject: [PATCH] externalise code solutions

it will be easier to maintain and test
it will be easier for student to recover good code
---
 source/_static/code/amplicon_len.py      | 15 +++++++++++++++
 source/_static/code/fasta_to_one_line.py |  7 +++++++
 source/_static/code/gc_percent.py        |  4 ++++
 source/_static/code/vol_of_sphere.py     |  9 +++++++++
 4 files changed, 35 insertions(+)
 create mode 100644 source/_static/code/amplicon_len.py
 create mode 100644 source/_static/code/fasta_to_one_line.py
 create mode 100644 source/_static/code/gc_percent.py
 create mode 100644 source/_static/code/vol_of_sphere.py

diff --git a/source/_static/code/amplicon_len.py b/source/_static/code/amplicon_len.py
new file mode 100644
index 0000000..3e9eeea
--- /dev/null
+++ b/source/_static/code/amplicon_len.py
@@ -0,0 +1,15 @@
+
+def amplicon_len(seq, primer_1, primer_2):
+    """
+    given primer_1 and primer_2 
+    return the lenght of the amplicon
+    primer_1 and primer_2 ar present and in this order 
+    in sequence 
+    """
+    primer_1 = primer_1.upper()
+    primer_2 = primer_2.upper()
+    sequence = sequence.upper()
+    pos_1 = sv40_sequence.find(primer_1)
+    pos_2 = sv40_sequence.find(primer_2)
+    amplicon_len = pos_2 + len(primer_2) - pos_1
+    return amplicon_len
\ No newline at end of file
diff --git a/source/_static/code/fasta_to_one_line.py b/source/_static/code/fasta_to_one_line.py
new file mode 100644
index 0000000..6ef59c0
--- /dev/null
+++ b/source/_static/code/fasta_to_one_line.py
@@ -0,0 +1,7 @@
+
+def fasta_2_one_line(seq):
+    header_end_at = find('\n')
+    seq = seq[:header_end_at + 1]
+    seq = seq.replace('\n', '')
+    return seq
+
diff --git a/source/_static/code/gc_percent.py b/source/_static/code/gc_percent.py
new file mode 100644
index 0000000..b5d988b
--- /dev/null
+++ b/source/_static/code/gc_percent.py
@@ -0,0 +1,4 @@
+
+def gc_percent(seq):
+    gc_pc =  float(seq.count('g') + seq.count('c')) / float(len(seq))
+    return gc_pc
\ No newline at end of file
diff --git a/source/_static/code/vol_of_sphere.py b/source/_static/code/vol_of_sphere.py
new file mode 100644
index 0000000..7288495
--- /dev/null
+++ b/source/_static/code/vol_of_sphere.py
@@ -0,0 +1,9 @@
+import math
+
+def vol_of_sphere(radius):
+    """
+    compute the volume of sphere of a given radius
+    """
+    
+    vol = float(4)/float(3) * float(math.pi) * pow(radius, 3)
+    return vol
-- 
GitLab