def generateFingerprint(molecule, numInts=32, pathLength=7): """(molecule, numInts=32)->Fingerprint given a molecule and the number of integers to use to generate the fingerprint, return the fingerprint of the molecule)""" paths = LinearPaths.generatePaths(molecule, maxdepth=pathLength) fp = Fingerprint.Fingerprint(numIntegers=numInts) for path in paths: fp.addPath(path) return fp
def add_chords(self): for chord in Chord.all(): #if fingerprint exists, get current fingerprint to modify if self.fingerprint(chord.id): fingerprint = self.fingerprints[chord.id] fingerprint.add_chord(chord) #else create new fingerprint else: self.fingerprints[chord.id] = Fingerprint(chord.stamp) self.fingerprints[chord.id].add_chord(chord)
def add_scales(self): for scale in Scale.all(): #if fingerprint exists, get current fingerprint to modify #print(scale.stamp) if self.fingerprint(scale.id): fingerprint = self.fingerprints[scale.id] fingerprint.add_scale(scale) #else create new fingerprint else: self.fingerprints[scale.id] = Fingerprint(scale.stamp) self.fingerprints[scale.id].add_scale(scale)
# RunTests.py # Run the Fingerprint program on the test cases. import os import csv import Fingerprint # Instantiate the Fingerprint class. f = Fingerprint.Fingerprint() # Loop over all the test cases in the test directory. test_directory = '../tests' for test_file in os.listdir(test_directory): if (test_file.endswith('.dat')): #print (test_file) # Evaluate the full path to the file. test_file_path = test_directory + '/' + test_file #print(test_file_path) # Open the test file with open(test_file_path, 'r') as tf: reader = csv.reader(tf) fp_data = list(reader) # Process the input and identify the grouping. #print(fp_data[0]) #print(fp_data[1]) # Get the expected result. exp_result = [int(x) for x in fp_data[1]]