import sys
import csv
import os

sys.path.append('../../')
import h_lib
import h_lib_noSeqSearch

in_strFastaFilename = '{!s}/data/protein/18mix/18mix_db_plus_contaminants_20081209.fasta'.format(os.environ.get('HOME'))
in_strPeptideFilename = '{!s}/data/protein/18mix/18_mixtures_peptide_identification.txt'.format(os.environ.get('HOME'))
out_strOutputBaseDir = './sparseData_h'
out_strFile = out_strOutputBaseDir + "/h_noSeqSearch.csv"


YInfo = h_lib.getPeptides(in_strPeptideFilename, "\t", 0, 2)
###assuming proteins are already broken to individual files under in_strProtRefsDir
#XMatchProb = h_lib.getYInfo(YInfo, in_strProtRefsDir, strXMatchProb_filename, True)
XMatchProb = h_lib_noSeqSearch.getXInfo(YInfo, in_strPeptideFilename, "\t", 0, 1)
YMatchProbCount = h_lib.getPeptideProteinMatches(YInfo, XMatchProb)
h_lib.updateXMatchingProbabilities(XMatchProb, YMatchProbCount)
XPred = h_lib.getAccumulatedXMatchingProbabilities(XMatchProb)

XPred.sort()
with open(out_strFile, "w") as bfFile:
    for row in XPred:
        bfFile.write('{!s},{:.6f}\n'.format(row[0], row[1]))

print("result saved in:" + out_strFile)

[((5, 0, 5, 25), 'sys.path.append', 'sys.path.append', ({(5, 16, 5, 24): '"""../../"""'}, {}), "('../../')", False, 'import sys\n'), ((15, 8, 15, 60), 'h_lib.getPeptides', 'h_lib.getPeptides', ({(15, 26, 15, 47): 'in_strPeptideFilename', (15, 49, 15, 53): '"""\t"""', (15, 55, 15, 56): '0', (15, 58, 15, 59): '2'}, {}), "(in_strPeptideFilename, '\\t', 0, 2)", False, 'import h_lib\n'), ((18, 13, 18, 81), 'h_lib_noSeqSearch.getXInfo', 'h_lib_noSeqSearch.getXInfo', ({(18, 40, 18, 45): 'YInfo', (18, 47, 18, 68): 'in_strPeptideFilename', (18, 70, 18, 74): '"""\t"""', (18, 76, 18, 77): '0', (18, 79, 18, 80): '1'}, {}), "(YInfo, in_strPeptideFilename, '\\t', 0, 1)", False, 'import h_lib_noSeqSearch\n'), ((19, 18, 19, 67), 'h_lib.getPeptideProteinMatches', 'h_lib.getPeptideProteinMatches', ({(19, 49, 19, 54): 'YInfo', (19, 56, 19, 66): 'XMatchProb'}, {}), '(YInfo, XMatchProb)', False, 'import h_lib\n'), ((20, 0, 20, 63), 'h_lib.updateXMatchingProbabilities', 'h_lib.updateXMatchingProbabilities', ({(20, 35, 20, 45): 'XMatchProb', (20, 47, 20, 62): 'YMatchProbCount'}, {}), '(XMatchProb, YMatchProbCount)', False, 'import h_lib\n'), ((21, 8, 21, 62), 'h_lib.getAccumulatedXMatchingProbabilities', 'h_lib.getAccumulatedXMatchingProbabilities', ({(21, 51, 21, 61): 'XMatchProb'}, {}), '(XMatchProb)', False, 'import h_lib\n'), ((9, 97, 9, 119), 'os.environ.get', 'os.environ.get', ({(9, 112, 9, 118): '"""HOME"""'}, {}), "('HOME')", False, 'import os\n'), ((10, 96, 10, 118), 'os.environ.get', 'os.environ.get', ({(10, 111, 10, 117): '"""HOME"""'}, {}), "('HOME')", False, 'import os\n')]