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)
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)
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))
In [ ]:
In [ ]: