In [115]:
#!/usr/bin/python
# example of input file of frog fingerprint for dna(15bit),protein(22bit),variations(18bit) , like this
#10101***10111*11*101*1010111*111111111*101*1010111*1000
#10101***10111*11*101*1010111*111111111*101*1010111*1001
#10101***10111*11*101*1010111*111111111*101*1010111*1010
#10101***10111*11*101*1010111*111111111*101*1010111*1011
# the convert into FROG header encoded fingerprint, like this
# 0101101101110010110110111011111101111101011011111101101011111111111110110101111000

In [116]:
# Import other print function for new line elimination and sys for input arguments for 'fpbits' is fingerprint bits
#
from __future__ import print_function
import sys
#ifile=sys.argv[-1]
#ifile="/Users/rakesh/Research_Work/ipython_program/genetics/FP_ipython/dna4.bin"
ifile="/Users/rakesh/Research_Work/ipython_program/genetics/FP_ipython/dna1.bin"
fpbits=[]
with open(ifile,"r") as f:
        for l in f:
                fpbits.append(l)
                #print ("first loop", l)
# strip newline character from fingerprint bits string
fpbits=map(str.rstrip,fpbits)
#

In [117]:
print (fpbits)


['0101101101110010110110111011111101111101011011111101101011111111111110110101111000']

In [118]:
# inportant: for sample checking, provide FROG input sample values to functions FP=["0","DNA","0","PROT","VARI","0"], FPLH is "Fingerprint Level Header" for showing which bit is calculcated and which is not
FPLH="010110"
# example bits=['10101***10111*11*101*1010111*111111111*101*1010111*1001']
# check the input bits in a single line
# print ("bits are:",fpbits)
## important : create a FROG LEVEL array for comparision values
## FPL=["CHR","DNA","RNA","PROT","VARI","INTR"]
#
# important:  create a FROG ATTRIBUTE array 'FPA?' for FROG LEVELS
FPAC=[2,3,1,4,3]
FPAD=[3,2,3,1,1,3,2]
FPAR=[3,2,3,3,3,3,3,1,2]
FPAP=[2,1,4,2,3,5,3,2]
FPAV=[2,1,1,1,1,2,2,1,1,1,1,1,1,1,1]
FPAI=[2,4,3,2]

In [119]:
# create a array of array for attribute values
FPA = [FPAC,FPAD,FPAR,FPAP,FPAV,FPAI]
#

In [120]:
# check condition of LEVEL and set FPA? for print
print ("fpbits: ", fpbits)
for bits in fpbits:
    print ("2nd loop:", bits)
    AHR=''
    FPLB=''
    count=0
    bc='01'
    flag=0


fpbits:  ['0101101101110010110110111011111101111101011011111101101011111111111110110101111000']
2nd loop: 0101101101110010110110111011111101111101011011111101101011111111111110110101111000

In [121]:
# take range for 6 LEVELS indexing 'level' for FPL 
for level in range(0,6):
    for i in FPA[level]:
        if ( bc[0] == FPLH[level] ):
            break
        FPAB=''
        j=0
        while j < i:
            bit=bits[count]
            if (bit == bc[0] or bit == bc[1]):
                FPAB+=bit
                j+=1
                count+=1
            else:
                flag=1
                j+=1
                count+=1
        FPLB+=FPAB
        if flag == 1:
            AHR+='0'
            flag=0
        else:
            AHR+='1'
        #print ('FPLH:AHR:FPLB', FPLH,AHR,FPLB)
        #print ('level', level)
        print ('%s %s %s' %(FPLH,AHR,FPLB))


010110 1 010
010110 11 01011
010110 111 01011011
010110 1111 010110110
010110 11111 0101101101
010110 111111 0101101101110
010110 1111111 010110110111001
010110 11111111 01011011011100101
010110 111111111 010110110111001011
010110 1111111111 0101101101110010110110
010110 11111111111 010110110111001011011011
010110 111111111111 010110110111001011011011101
010110 1111111111111 01011011011100101101101110111111
010110 11111111111111 01011011011100101101101110111111011
010110 111111111111111 0101101101110010110110111011111101111
010110 1111111111111111 010110110111001011011011101111110111110
010110 11111111111111111 0101101101110010110110111011111101111101
010110 111111111111111111 01011011011100101101101110111111011111010
010110 1111111111111111111 010110110111001011011011101111110111110101
010110 11111111111111111111 0101101101110010110110111011111101111101011
010110 111111111111111111111 010110110111001011011011101111110111110101101
010110 1111111111111111111111 01011011011100101101101110111111011111010110111
010110 11111111111111111111111 010110110111001011011011101111110111110101101111
010110 111111111111111111111111 0101101101110010110110111011111101111101011011111
010110 1111111111111111111111111 01011011011100101101101110111111011111010110111111
010110 11111111111111111111111111 010110110111001011011011101111110111110101101111110
010110 111111111111111111111111111 0101101101110010110110111011111101111101011011111101
010110 1111111111111111111111111111 01011011011100101101101110111111011111010110111111011
010110 11111111111111111111111111111 010110110111001011011011101111110111110101101111110110
010110 111111111111111111111111111111 0101101101110010110110111011111101111101011011111101101

In [ ]:


In [ ]: