Commit b5fbaed8 authored by Lucianna's avatar Lucianna

Protloc pre-pre-alpha

Some basic, untested fileio functionality added. Lots of work to go.
parent a738d017
includes prenylation and farnesylation
# protein_targeting_and_localization
#
# Module for finding protein localization/targeting strings in strings of Amino Acids
# !!PRE-PRE-ALPHA!! Lots of TODO. Currently untested
#
# Author: Lucianna Osucha (email:lucianna@vulpinedesigns.com)
**Contents:**
-*protloc.py* Main end user program
-*modTargetStrings.py* Utility interface. Feed files to this to add to the datfile.
-*example_input.txt* An example of input, ready to feed to modTargetStrings.py
*modTargetStrings.py* comes complete with a helper utility. Use -h or --help to access it.
import os
import sys
mypath = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.abspath(mypath + '/../'))
# modTargetStrings.py
#
# Utility for editing the locStrings.dat file
#
# Author: Lucianna Osucha (email:lucianna@vulpinedesigns.com)
import sys
import os
from __init__ import *
import argparse
from struct import pack, unpack
import util.AminoChain
filename = os.path.abspath(mypath + 'locStrings.dat')
try:
m_file = open(filename,'+b')
except OSError as e:
print("\"" + filename + "\" not found!\n"
+ "Constructing new file...", file=sys.stderr)
m_file = open(filename,'wb')
newfile = 1
parser = argparse.ArgumentParser(description="A helper utility for populating "
+ "the \"" + filename + "\" file"
, epilog="File Formatting Example:\n\nAUG 1000\nCUG 140\nAUC 15.3" #TODO
, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('infile', nargs='*', type=argparse.FileType('r') #TODO
, help="Read strings stored in a file and update \"" + filename + "\" with "
+ "the new data. Leave empty to print out currently stored data")
args = parser.parse_args()
if args.infile == []:
if newfile:
sys.exit()
while m_file.readable():
print(deindexAminoChain(*unpack('<c', m_file.read(8))) + '\n')
sys.exit()
m_file.seek(0, SEEK_END)
for n_file in args.infile:
while n_file.readable():
seq = indexAminoChain(n_file.readline())
for i in seq:
m_file.write(bytearray(pack('<c', i)))
# protloc.py
#
# <TODO: filedescription>
#
# Author: Lucianna Osucha (lucianna@vulpinedesigns.com)
import sys
import os
from __init__ import *
from util.AminoChain import *
from struct import *
filename = os.path.abspath(mypath + 'locStrings.dat')
try:
m_locstrings = open(filename, 'rb')
except OSError as e:
print("[!!FATAL!!] Error opening \"locStrings.dat\"\n", file=sys.stderr)
raise
#TODO
def tagLocStrings(aac:AminoAcidChain) -> AminoAcidChain:
return aac;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment