if currentFASTAChecksum != originalFASTAChecksum: print('MD5 of FASTA used to create chains file: ' + str(originalFASTAChecksum)) print('MD5 of the given FASTA: ' + str(currentFASTAChecksum)) print('These are not the same. Exiting') assert(False) assert(args.length == chainCollection.peptideLength) chainHash = chainCollection.checksum() bindingScoreTableFile = None bindingScoreTable = None if os.path.isfile(args.bindingScoreTable): bindingScoreTableFile = open(args.bindingScoreTable, 'rb+') bindingScoreTable = ScoreTable.readExisting(bindingScoreTableFile) if bindingScoreTable.chainHash != chainHash: print('checksum for chains used to create binding score table: ' + bindingScoreTable.chainHash.hex()) print('checksum for these chains: ' + chainHash.hex()) print('These are not the same. Exiting') assert(False) else: bindingScoreTableFile = open(args.bindingScoreTable, 'wb+') bindingScoreTable = ScoreTable.empty(bindingScoreTableFile, ScoreCategory.PAN_AFF, 'H', 1, ' ', args.length, chainHash) assert(bindingScoreTable.peptideLength == chainCollection.peptideLength)
parser.add_argument('chains') parser.add_argument('scoreTable') parser.add_argument('allele') parser.add_argument('k', type=int) args = parser.parse_args() assert (os.path.isfile(args.chains)) assert (os.path.isfile(args.fasta)) assert (os.path.isfile(args.scoreTable)) assert (args.k > 0) chainCollection = None with open(args.chains, 'rb') as f: chainCollection = pickle.load(f) f = open(args.scoreTable, 'rb') st = ScoreTable.readExisting(f) print('alleles: ') print(st.getAlleles()) assert (args.allele in st.getAlleles()) length = st.peptideLength n = st.numPeptides assert (args.k <= n) print('num peptides: ' + str(n)) pepGen = peptideGenerator(chainCollection, args.fasta, length) selection = sorted(random.sample(range(0, n), args.k)) scoreIter = st.scoreIter(args.allele) pepAndScores = extractPeptidesAndScores(scoreIter, pepGen, selection) for pep, score in pepAndScores: print(str(pep) + '\t' + str(score))
str(x), str(THREADS) ] proc = subprocess.Popen(precomputeCommand, stdout=subprocess.DEVNULL) outs, errors = proc.communicate() additionalScoreFile = None if allele[2] == 'elute': additionalScoreFile = open( additionalPanEluteScoreTablePath, 'rb') elif allele[2] == 'ba': additionalScoreFile = open(additionalPanBAScoreTablePath, 'rb') else: assert (0) additionalScoreTable = ScoreTable.readExisting( additionalScoreFile) baseScoreTable = None baseChains = None baseFasta = None if usingBase: baseChainPath = os.path.join(args.baseDirectory, str(x) + '.chains') with open(baseChainPath, 'rb') as f: baseChains = pickle.load(f) baseScoreFile = None baseFasta = os.path.join(args.baseDirectory, args.baseFasta) if allele[0] == 'netmhcPanPrecompute': if allele[2] == 'elute': baseScoreFile = open( os.path.join(args.baseDirectory, args.netmhcPanScoreDir,
else: break """ """pepIter = peptideGenerator(chainCollection, fastaPath, pepLen) for pep in pepIter: print('>' + ' @ '.join(pep.getHeaders())) print(pep.getPeptideSequence()) """ #os.remove('scores.bin') scorePath = 'scores.bin' scoreFileObj = None scoreTable = None if os.path.isfile(scorePath): scoreFileObj = open(scorePath, 'rb+') scoreTable = ScoreTable.readExisting(scoreFileObj) else: scoreFileObj = open(scorePath, 'wb+') scoreTable = ScoreTable.empty(scoreFileObj, 'H', 1, ' ') """first_scorer = DummyScorer(0) second_scorer = DummyScorer(1) third_scorer = DummyScorer(2) scoreTable.addAllele(first_scorer, 'A', map(lambda x: x.getPeptideSequence(), peptideGenerator(chainCollection, 'test.fasta', 3))) scoreTable.addAllele(second_scorer, 'B', map(lambda x: x.getPeptideSequence(), peptideGenerator(chainCollection, 'test.fasta', 3))) scoreTable.addAllele(third_scorer, 'C', map(lambda x: x.getPeptideSequence(), peptideGenerator(chainCollection, 'test.fasta', 3))) for peptide, row in itertools.zip_longest(map(lambda x: x.getPeptideSequence(), peptideGenerator(chainCollection, 'test.fasta', 3)), scoreTable): print('peptide: ' + peptide) print('row') print(row) """
originalFASTAChecksum = chainCollection.md5 currentFASTAChecksum = fileMD5(args.fasta) if currentFASTAChecksum != originalFASTAChecksum: print('MD5 of FASTA used to create chains file: ' + str(originalFASTAChecksum)) print('MD5 of the given FASTA: ' + str(currentFASTAChecksum)) print('These are not the same. Exiting') assert (False) chainHash = chainCollection.checksum() scoreTableFile = None scoreTable = None if os.path.isfile(args.scoreTable): scoreTableFile = open(args.scoreTable, 'rb+') scoreTable = ScoreTable.readExisting(scoreTableFile) if scoreTable.chainHash != chainHash: print('checksum for chains used to create score table: ' + scoreTable.chainHash.hex()) print('checksum for these chains: ' + chainHash.hex()) print('These are not the same. Exiting') assert (False) else: scoreTableFile = open(args.scoreTable, 'wb+') scoreTable = ScoreTable.empty(scoreTableFile, ScoreCategory.AFFINITY, 'H', 1, ' ', args.length, chainHash) assert (args.length == chainCollection.peptideLength) assert (scoreTable.peptideLength == chainCollection.peptideLength) if args.allele in scoreTable.getAlleles():