int editor_type::command (command_type& ct) { static const std::wstring onemore (L"cdijkmnpstw"); std::wstring doc; if (1 == ct.naddr) line2 = line1; if (line1 > line2 || buffer.dollar () < line1 || buffer.dollar () < line2) return '?'; if (line1 == 0 && onemore.find (ct.command) != std::wstring::npos) return '?'; switch (ct.command) { default: return '?'; case 'a': ct.command = cmd_a (ct); break; case 'c': ct.command = cmd_c (ct); break; case 'd': ct.command = cmd_d (ct); break; case 'e': ct.command = cmd_e (ct); break; case 'f': ct.command = cmd_f (ct); break; case 'i': ct.command = cmd_i (ct); break; case 'j': ct.command = cmd_j (ct); break; case 'k': ct.command = cmd_k (ct); break; case 'm': ct.command = cmd_m (ct); break; case 'n': ct.command = cmd_n (ct); break; case 'p': ct.command = cmd_p (ct); break; case 'r': ct.command = cmd_r (ct); break; case 's': ct.command = cmd_s (ct); break; case 't': ct.command = cmd_t (ct); break; case 'w': ct.command = cmd_w (ct); break; case '=': ct.command = cmd_equal (ct); break; case '\n': ct.command = cmd_p (ct); break; } print_dot (ct); return ct.command; }
int freq_display(void) { extern float freq; extern int trxmode; int x_position = 40; int y_position = 17; int location = 0; char fbuffer[8]; print_space(y_position, x_position); print_space(y_position + 1, x_position); print_space(y_position + 2, x_position); print_space(y_position + 3, x_position); print_space(y_position + 4, x_position); nicebox(16, 39, 5, 35, "TRX"); print_dot(y_position + 4, 28 + x_position + 1); sprintf(fbuffer, "%7.1f", freq); location = 32; if (fbuffer[0] != ' ') print_big_number(fbuffer[0] - 48, y_position, x_position, 4); if (fbuffer[1] != ' ') print_big_number(fbuffer[1] - 48, y_position, x_position, 9); if (fbuffer[2] != ' ') print_big_number(fbuffer[2] - 48, y_position, x_position, 14); if (fbuffer[3] != ' ') print_big_number(fbuffer[3] - 48, y_position, x_position, 19); if (fbuffer[4] != ' ') print_big_number(fbuffer[4] - 48, y_position, x_position, 24); if (fbuffer[6] != ' ') print_big_number(fbuffer[6] - 48, y_position, x_position, 31); attron(COLOR_PAIR(C_HEADER) | A_STANDOUT); if (trxmode == CWMODE) mvprintw(18, 41, "CW"); else if (trxmode == SSBMODE) mvprintw(19, 41, "SSB"); else mvprintw(19, 41, "DIG"); refreshp(); return (0); }
int main(int argc, char *argv[]) { int verbose = 0; bool printBLIF = false; bool printDot = false; bool printStatistics = false; int cycles = 0; int outputstyle = 0; bool testv = false; bool printVerilog = false; std::ifstream testvectors; --argc; ++argv; try { while (argc > 0 && argv[0][0] == '-') { switch (argv[0][1]) { case 'b': printBLIF = true; break; case 'd': printDot = true; break; case 's': printStatistics = true; break; case 'V': --argc; ++argv; if (argc == 0) throw UsageError(); verbose = atoi(argv[0]); break; case 'c': --argc; ++argv; if (argc == 0) throw UsageError(); cycles = atoi(argv[0]); break; case 'o': --argc; ++argv; if (argc == 0) throw UsageError(); outputstyle = atoi(argv[0]); break; case 't': --argc; ++argv; if (argc == 0) throw UsageError(); testv = true; testvectors.open(argv[0]); break; case 'v': printVerilog = true; break; default: throw UsageError(); } --argc; ++argv; } if (argc > 1) throw UsageError(); { BLIF::Netlist *n; if (argc == 1) { std::ifstream i(argv[0]); if (!i.is_open()) { std::cerr << "could not open " << argv[0] << std::endl; return 1; } n = BLIF::read_blif(i); i.close(); } else { n = BLIF::read_blif(std::cin); } if (printBLIF) print_blif(std::cout, *n); if (printDot) print_dot(std::cout, *n); if (printVerilog) print_verilog(std::cout, *n); if (printStatistics) { unsigned int gates = 0; unsigned int inputs = 0; unsigned int outputs = 0; unsigned int latches = 0; for ( std::vector<BLIF::Gate*>::const_iterator i = n->gates.begin() ; i != n->gates.end() ; i++ ) { if ( (*i)->is_input ) inputs++; if ( (*i)->is_output ) outputs++; if ( (*i)->is_latch ) latches++; if ( !( (*i)->is_input || (*i)->is_latch) ) gates++; } std::cerr << "gates: " << gates << " latches: " << latches << " inputs: " << inputs << " outputs: " << outputs << std::endl; } if (cycles > 0 || testv) { // Run simulation BLIF::Simulator sim(*n); sim.debug = verbose & 1; if (outputstyle == 1) { for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << (*j)->name << ' '; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.latches.begin() ; j != sim.latches.end() ; j++ ) std::cout << (*j)->name << ' '; std::cout << '\n'; } for ( int i = 0 ; cycles > 0 ? i < cycles : true ; i++ ) { if ( testv ) { std::string line; getline(testvectors, line); if (testvectors.fail()) break; if ( line.size() < sim.inputs.size() ) { std::cerr << "Not enough inputs (" << line.size() << '<' << sim.inputs.size() << ") in test vector file\n"; break; } std::string::const_iterator j = line.begin(); for ( std::vector<BLIF::Gate*>::const_iterator i = sim.inputs.begin() ; i != sim.inputs.end() ; j++ ) { if ((*j) != ' ') { sim.setInput(*i, (*j) == '1'); i++; } } } sim.simulate(); switch (outputstyle) { case 1: for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << (sim.getOutput(*j) ? '1' : '0'); std::cout << ' '; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.latches.begin() ; j != sim.latches.end() ; j++ ) std::cout << (sim.getLatch(*j) ? '1' : '0'); std::cout << '\n'; break; default: { char buf[5]; sprintf(buf, "%4d", i); std::cout << buf; for ( std::vector<BLIF::Gate*>::const_iterator j = sim.outputs.begin() ; j != sim.outputs.end() ; j++ ) std::cout << ' ' << (*j)->name << '=' << (sim.getOutput(*j) ? '1' : '0'); std::cout << '\n'; } break; } } } } } catch (UsageError &) { std::cerr << "Usage: cec-blifutil [-b] [-d] [-s] [-V <level>] [-c <cycles>] [-o <style>] [-v] [<file.blif>]\n" "-v Print Verilog version of input netlist\n" "-b Print BLIF version of input netlist\n" "-d Print dot version of input\n" "-s Print statistics on the netlist\n" "-c <cycles> Simulate for the given number of cycles\n" "-t <vectorfile> Use this file of test vectors as input stimuli\n" "-o <style> Set the simulation output style to 0, 1, 2, etc.\n" "-V <level> Set verbosity to <level>\n" ; return 1; } return 0; }
int main(int argc, char** argv) { std::int8_t m = 5; std::int8_t n = -4; std::int8_t g = -8; std::int8_t e = -6; std::int8_t q = -10; std::int8_t c = -4; std::uint8_t algorithm = 0; std::uint8_t result = 0; std::string dot_path = ""; char opt; while ((opt = getopt_long(argc, argv, "m:n:g:e:q:c:l:r:d:h", options, nullptr)) != -1) { switch (opt) { case 'm': m = atoi(optarg); break; case 'n': n = atoi(optarg); break; case 'g': g = atoi(optarg); break; case 'e': e = atoi(optarg); break; case 'q': q = atoi(optarg); break; case 'c': c = atoi(optarg); break; case 'l': algorithm = atoi(optarg); break; case 'r': result = atoi(optarg); break; case 'd': dot_path = optarg; break; case 'v': std::cout << version << std::endl; return 0; case 'h': help(); return 0; default: return 1; } } if (optind >= argc) { std::cerr << "[spoa::] error: missing input file!" << std::endl; help(); return 1; } std::string sequences_path = argv[optind]; auto is_suffix = [](const std::string& src, const std::string& suffix) -> bool { if (src.size() < suffix.size()) { return false; } return src.compare(src.size() - suffix.size(), suffix.size(), suffix) == 0; }; std::unique_ptr<bioparser::Parser<spoa::Sequence>> sparser = nullptr; if (is_suffix(sequences_path, ".fasta") || is_suffix(sequences_path, ".fa") || is_suffix(sequences_path, ".fasta.gz") || is_suffix(sequences_path, ".fa.gz")) { sparser = bioparser::createParser<bioparser::FastaParser, spoa::Sequence>( sequences_path); } else if (is_suffix(sequences_path, ".fastq") || is_suffix(sequences_path, ".fq") || is_suffix(sequences_path, ".fastq.gz") || is_suffix(sequences_path, ".fq.gz")) { sparser = bioparser::createParser<bioparser::FastqParser, spoa::Sequence>( sequences_path); } else { std::cerr << "[spoa::] error: file " << sequences_path << " has unsupported format extension (valid extensions: .fasta, " ".fasta.gz, .fa, .fa.gz, .fastq, .fastq.gz, .fq, .fq.gz)!" << std::endl; return 1; } std::unique_ptr<spoa::AlignmentEngine> alignment_engine; try { alignment_engine = spoa::createAlignmentEngine( static_cast<spoa::AlignmentType>(algorithm), m, n, g, e, q, c); } catch(std::invalid_argument& exception) { std::cerr << exception.what() << std::endl; return 1; } auto graph = spoa::createGraph(); std::vector<std::unique_ptr<spoa::Sequence>> sequences; sparser->parse(sequences, -1); std::size_t max_sequence_size = 0; for (const auto& it: sequences) { max_sequence_size = std::max(max_sequence_size, it->data().size()); } alignment_engine->prealloc(max_sequence_size, 4); for (const auto& it: sequences) { auto alignment = alignment_engine->align(it->data(), graph); try { graph->add_alignment(alignment, it->data(), it->quality()); } catch(std::invalid_argument& exception) { std::cerr << exception.what() << std::endl; return 1; } } if (result == 0 || result == 2) { std::string consensus = graph->generate_consensus(); std::cout << "Consensus (" << consensus.size() << ")" << std::endl; std::cout << consensus << std::endl; } if (result == 1 || result == 2) { std::vector<std::string> msa; graph->generate_multiple_sequence_alignment(msa); std::cout << "Multiple sequence alignment" << std::endl; for (const auto& it: msa) { std::cout << it << std::endl; } } graph->print_dot(dot_path); return 0; }
int print_big_number(int number, int y_position, int x_position, int location) { switch (number) { case 1:{ print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position + 3); break; } case 2:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } case 3:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } case 4:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position + 3); break; } case 5:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } case 6:{ print_dot(y_position, location + x_position); print_dot(y_position + 1, location + x_position); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } case 7:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position + 3); break; } case 8:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } case 9:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 1); print_dot(y_position + 2, location + x_position + 2); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position + 3); break; } case 0:{ print_dot(y_position, location + x_position); print_dot(y_position, location + x_position + 1); print_dot(y_position, location + x_position + 2); print_dot(y_position, location + x_position + 3); print_dot(y_position + 1, location + x_position); print_dot(y_position + 1, location + x_position + 3); print_dot(y_position + 2, location + x_position); print_dot(y_position + 2, location + x_position + 3); print_dot(y_position + 3, location + x_position); print_dot(y_position + 3, location + x_position + 3); print_dot(y_position + 4, location + x_position); print_dot(y_position + 4, location + x_position + 1); print_dot(y_position + 4, location + x_position + 2); print_dot(y_position + 4, location + x_position + 3); break; } } refreshp(); return (0); }