def __init__(self): self.sequencer = sequencer.Sequencer() self.joiner = joiner.Joiner() monotonicity_operators_file = join(dirname(__file__), '../resources/monotonicity_operators_list.txt') with open(monotonicity_operators_file) as f: monotonicity_operators = f.readlines() self.mon_operators = [l.rstrip() for l in monotonicity_operators] self.classifier = classifier.Classifier() self.marker = marker_interface.Marker_interface() self.arg_types_projector = arg_types_projector.Arg_type_projector()
All text above must be included in any redistribution. """ import os import parser import sequencer import synth import adafruit_trellism4 trellis = adafruit_trellism4.TrellisM4Express(rotation=0) trellis.pixels.brightness = 0.1 trellis.pixels.fill(0) syn = synth.Synth() seq = sequencer.Sequencer(syn) p = parser.MidiParser() voices = sorted([ f.split('.')[0] for f in os.listdir('/samples') if f.endswith('.txt') and not f.startswith('.') ]) print('Voices found: ', voices) tunes = sorted([ f for f in os.listdir('/midi') if f.endswith('.mid') and not f.startswith('.') ]) print('Midi files found: ', tunes) selected_voice = None
path = os.path.abspath(os.path.dirname(__file__)) # Load config configfile = os.path.join(path, "../config.ini") config = config.Config(configfile) # Set root folder as search path for modules root = os.path.join(path, "..") sys.path.append(root) # Setup logging logging.basicConfig(format="%(message)s", level=logging.DEBUG, datefmt="%H:%M:%S") # Create sequencer seq = sequencer.Sequencer(config) NOTE_LENGTH = L4 # Console command to play a file def play(): seq.start() exec(open(sys.argv[1]).read()) seq.stop() ################# # Set variables # ################# def setBpm(bpm): seq.setBpm(bpm)
np.dtype('int64').type(16), np.dtype('int64').type(32), np.dtype('int64').type(64) ], [ np.dtype('int64').type(1), np.dtype('int64').type(2), np.dtype('int64').type(4), np.dtype('int64').type(8), np.dtype('int64').type(16), np.dtype('int64').type(32), np.dtype('int64').type(64) ]] # define the sequencer object with default parameters seq = sequencer.Sequencer(grid, objects_list_shuffled, estimator_list, scale_list=scale_list) print('-------- calculating --------') # outputs will be saved output_path = "." final_elongation, final_sequence = seq.execute( output_path, to_print_progress=False, to_average_N_best_estimators=True, number_of_best_estimators=1) bar() # print the final elongation print("The MST elongation: ", final_elongation) # print the resulting sequence print("The resulting sequence: ", final_sequence)
def test_sequencer(): seq = sequencer.Sequencer() seq.play()
def test_sequencer(window): seq = sequencer.Sequencer(curses_window=window) seq.play()
window.addstr(0, 0, seq.to_string()) if curses.keyname(c) == "q": break ### test using curses window = curses.initscr() #use cbreak to not require a return key press curses.cbreak() # don't echo back the user's commands curses.noecho() #window.keypad(1) curses.start_color() curses.curs_set(0) seq = sequencer.Sequencer(curses_window=window) while 1: c = window.getch() if curses.keyname(c) == "s": seq.stop() if curses.keyname(c) == "a": seq.play() if curses.keyname(c) == "q": seq.stop() curses.nocbreak() window.keypad(0) curses.echo() curses.endwin() #break #while 1:
def main(self): ''' purpose: main function to run shortstack Runs in the following order: - parse_input.py: parse input files - encoder.py: match basecalls with sequences from encoding file - align.py: run first round of FTM ''' ######################### #### Parse Input #### ######################### # instantiate parsing class from parse_input.py parse = parse_input.Parse_files(self.input_s6, self.output_dir, self.target_fa, self.mutation_vcf, self.encoding_file, self.qc_threshold, self.num_cores) s6_df, qc_df, mutation_df, encoding_df, fasta_df = parse.main_parser() ######################## #### Encode S6 #### ######################## log.info("Reads encoded using file:\n {}".format(self.encoding_file)) # instantiate encoder class from encoder.py encode = encoder.Encode_files(s6_df, encoding_df) # return dataframe of targets found for each molecule encoded_df, parity_df = encode.main(encoding_df, s6_df) # add parity check information to qc_df # qc_df comes from parse_input.py # parity_df comes from encoder.py qc_df = pd.concat([qc_df, parity_df], axis=0) qc_df.set_index("FeatureID", inplace=True, drop=True) ################################### #### Assemble Mutations ##### ################################### ## Supervised mode only ## # if mutations are provided, assemble mutation seqs from mutation_vcf if self.mutation_vcf != "none": print("Assembling input variants.\n") log.info("Mutations assembled from:\n {}".format( self.mutation_vcf)) # instantiate aligner module mutations = mut.AssembleMutations(fasta_df, mutation_df, self.run_info_file, s6_df) # add mutated reference sequences to fasta_df mutant_fasta = mutations.main() # no mutations provided = unsupervised mode and mutant_fasta is empty else: mut_message = "No mutations provided. Entering unsupervised mode." print(mut_message) log.info(mut_message) mutant_fasta = "" ############### ### FTM ### ############### align_message = "Running FTM...\n" print(align_message) log.info(align_message) # instantiate FTM module from ftm.py run_ftm = ftm.FTM(fasta_df, encoded_df, mutant_fasta, self.covg_threshold, self.kmer_length, self.max_hamming_dist, self.output_dir, self.diversity_threshold, self.qc_out_file, self.run_info_file, self.num_cores, self.hamming_weight) # run FTM ftm_df, no_calls, hamming_df = run_ftm.main() #################### ### Sequence ### #################### seq_message = "Determining consensus sequence...\n" print(seq_message) log.info(seq_message) # instantiate sequencing module from sequencer.py sequence = seq.Sequencer(ftm_df, no_calls, hamming_df, fasta_df, self.output_dir) sequence.main()