diff --git a/modules/seq/alg/pymod/CMakeLists.txt b/modules/seq/alg/pymod/CMakeLists.txt index 22db6f7e887e1b848458c47a004383ae5767d956..93dd1b348e19c104bc5364eb04dbde4238bd5dfa 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 22aa0c8632d507f99b0d8943b0a102a94ecedce2..5d4730f17b92b7eed13cf47fe02d802e3267364b 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 0000000000000000000000000000000000000000..65152f045bf70ef2c50568b3abcbcfd526f38294 --- /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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