Saturday, November 16, 2013

A biopython script to count the sequence identity from aligned sequences input

# A biopython script to calculate sequence identity score
# input is an aligned multiple protein, or DNA, or RNA sequences 
# with identical length including gaps
import sys
import numpy as np
from Bio import AlignIO
alignment = AlignIO.read("seq.faa", "fasta")
align_array = np.array([list(rec) for rec in alignment], np.character)
l=len(alignment)
seq2=np.arange(l)
seq=np.arange(l)
a=np.arange(l*l).reshape(l,l)
b1=a
for m in range(0,len(alignment)):
    seq[m]=0
    for n in range(0,alignment.get_alignment_length()):
        if align_array[m,n]!="-":
           seq[m]=seq[m]+1
        continue
    pass
pass  
#for i in range(0,len(alignment)):   #without parallel running
for i in range(800,1000): #parallel running, give start and finish sequence ID
    for k in range(0,len(alignment)):
        seq2[k]=0
        b1[i,k]=0
        for j in range(0,alignment.get_alignment_length()):
           if align_array[k,j]!="-":
             seq2[k]=seq2[k]+1
             if (align_array[i,j]==align_array[k,j]) and align_array[k,j]!="-":
                  b1[i,k]=b1[i,k]+1
             continue
           continue
        pass
        seq1=seq[i]
        if seq1 < seq2[k]:
           sequ=seq2[k]
        else:
           sequ=seq1
        p=1.0*b1[i,k]/sequ
        print "%3d %3d %3d %3d %3d %3d %9.6f" %(i,k,seq1,seq2[k],sequ,b1[i,k],p)
    pass
pass

Tuesday, September 17, 2013

error while loading shared libraries in Linux

install xmgrace in a SuSE linux system

'more /etc/SuSE-release' gives system info:
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2

'xmgrace' result in one of two errors:

xmgrace: error while loading shared libraries: libpng14.so.14: cannot open shared object file: No such file or directory

or

xmgrace: error while loading shared libraries: libpng14.so.14: wrong ELF class: ELFCLASS32


First error indicate the library is missing
Second error indicate the library is 32bit (not 64bit)

'ldd /usr/bin/xmgrace', part of the output is:
        ...
        libt1.so.5 => /usr/lib64/libt1.so.5 (0x00007f06d0acf000)
        libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x00007f06d08ab000)
        libpng14.so.14 => not found
        libm.so.6 => /lib64/libm.so.6 (0x00007f06d0631000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f06d042d000)
        ...

Solution is to download the right library, google '64 bit libpng14.so.14'
result in a package named "brlcad-7.20.2-0.openSUSE.x86_64.rpm"
which has the needed library and many other libraries also
at rpm.pbone.net

Download the package
and install it by
'sudo zypper install brlcad-7.20.2-0.openSUSE.x86_64.rpm'
Then the library is installed under /usr/brlcad/lib,
copy to /usr/lib64 by 'sudo cp /usr/brlcad/lib/libpng14.so.14 /usr/lib64'

enjoy 'xmgrace' !