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 [145]:
# check condition of LEVEL and set FPA? for print
print ("fpbits: ", fpbits)
for bits in fpbits:
    print ("2nd loop:", bits)


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

In [146]:
# attribute header
AHR=''
# fingerprint level bits
FPLB=''
# LEVEL bit counter
count=0
# compare array
bc='01'
# flag for delete * while compare
flag=0
for level in range(0,6):
    print ('FROG level check', level)
    for i in FPA[level]:
        print ('FROG Attribute check', i)
        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))


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

In [ ]:


In [ ]: