From 4ef6c8990642224d2e17a812cf7e7a44ab135ded Mon Sep 17 00:00:00 2001
From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Thu, 3 Jun 2010 08:17:42 +0000
Subject: [PATCH] added BLOSUM62 matrix

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2325 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/seq/alg/pymod/CMakeLists.txt |  2 +-
 modules/seq/alg/pymod/__init__.py    |  6 +++-
 modules/seq/alg/pymod/mat.py         | 45 ++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 modules/seq/alg/pymod/mat.py

diff --git a/modules/seq/alg/pymod/CMakeLists.txt b/modules/seq/alg/pymod/CMakeLists.txt
index 22db6f7e8..93dd1b348 100644
--- a/modules/seq/alg/pymod/CMakeLists.txt
+++ b/modules/seq/alg/pymod/CMakeLists.txt
@@ -5,4 +5,4 @@ set(OST_SEQ_ALG_PYMOD_SOURCES
 
 pymod(NAME seq_alg OUTPUT_DIR ost/seq/alg 
       CPP ${OST_SEQ_ALG_PYMOD_SOURCES}
-      PY __init__.py)
+      PY __init__.py mat.py)
diff --git a/modules/seq/alg/pymod/__init__.py b/modules/seq/alg/pymod/__init__.py
index 22aa0c863..5d4730f17 100644
--- a/modules/seq/alg/pymod/__init__.py
+++ b/modules/seq/alg/pymod/__init__.py
@@ -1 +1,5 @@
-from _seq_alg import *
\ No newline at end of file
+from _seq_alg import *
+from ost.seq.alg.mat import *
+
+    
+  
\ No newline at end of file
diff --git a/modules/seq/alg/pymod/mat.py b/modules/seq/alg/pymod/mat.py
new file mode 100644
index 000000000..65152f045
--- /dev/null
+++ b/modules/seq/alg/pymod/mat.py
@@ -0,0 +1,45 @@
+from ost.seq.alg import SubstWeightMatrix
+
+def _InitMatrix(data):
+  """
+  Initialise a new substitution weight matrix with the weights in data. data
+  must be a 24x24 array of ints.
+  """
+  mat=SubstWeightMatrix()
+  # string of valid amino acid one letter codes
+  chars='ABCDEFGHIKLMNPQRSTVWXYZ'
+  for i, row in enumerate(data):
+    for j, weight in enumerate(row):
+      mat.SetWeight(chars[i], chars[j], weight)
+  return mat
+      
+  
+_RAW_BLOSUM62_DATA=(  
+  (4,-2,0,-2,-1,-2,0,-2,-1,-1,-1,-1,-2,-1,-1,-1,1,0,0,-3,-1,-2),
+  (-2,6,-3,6,2,-3,-1,-1,-3,-1,-4,-3,1,-1,0,-2,0,-1,-3,-4,-1,-3),
+  (0,-3,9,-3,-4,-2,-3,-3,-1,-3,-1,-1,-3,-3,-3,-3,-1,-1,-1,-2,-1,-2),
+  (-2,6,-3,6,2,-3,-1,-1,-3,-1,-4,-3,1,-1,0,-2,0,-1,-3,-4,-1,-3),
+  (-1,2,-4,2,5,-3,-2,0,-3,1,-3,-2,0,-1,2,0,0,-1,-2,-3,-1,-2),
+  (-2,-3,-2,-3,-3,6,-3,-1,0,-3,0,0,-3,-4,-3,-3,-2,-2,-1,1,-1,3),
+  (0,-1,-3,-1,-2,-3,6,-2,-4,-2,-4,-3,0,-2,-2,-2,0,-2,-3,-2,-1,-3),
+  (-2,-1,-3,-1,0,-1,-2,8,-3,-1,-3,-2,1,-2,0,0,-1,-2,-3,-2,-1,2),
+  (-1,-3,-1,-3,-3,0,-4,-3,4,-3,2,1,-3,-3,-3,-3,-2,-1,3,-3,-1,-1),
+  (-1,-1,-3,-1,1,-3,-2,-1,-3,5,-2,-1,0,-1,1,2,0,-1,-2,-3,-1,-2),
+  (-1,-4,-1,-4,-3,0,-4,-3,2,-2,4,2,-3,-3,-2,-2,-2,-1,1,-2,-1,-1),
+  (-1,-3,-1,-3,-2,0,-3,-2,1,-1,2,5,-2,-2,0,-1,-1,-1,1,-1,-1,-1),
+  (-2,1,-3,1,0,-3,0,1,-3,0,-3,-2,6,-2,0,0,1,0,-3,-4,-1,-2),
+  (-1,-1,-3,-1,-1,-4,-2,-2,-3,-1,-3,-2,-2,7,-1,-2,-1,-1,-2,-4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