def main(self): appcli.load(self) library = Library() entry = library.find_entry(self.protocol) cmd = os.environ['EDITOR'], entry.path subp.run(cmd)
def main(self): appcli.load(self) library = Library() entries = library.find_entries(self.protocol) for entry in entries: print(entry.path)
def main(self): appcli.load(self) try: if self.command in self.commands: app = self.commands[self.command] app.quiet = self.quiet app.force_text = self.force_text # Remove top-level options (e.g. --quiet) from the command # line, so the subcommand doesn't have to deal with them. sys.argv = [sys.argv[0], self.command, *self.args] app.main() else: io_cli = ProtocolIO() if self.command: io_cli = ProtocolIO.from_library(self.command, self.args) if self.quiet and not io_cli.errors: io_cli.protocol.clear_footnotes() # It's more performant to load the protocol specified on the CLI # before trying to read a protocol from stdin. The reason is # subtle, and has to do with the way pipes work. For example, # consider the following pipeline: # # sw pcr ... | sw kld ... # # Although the output from `sw pcr` is input for `sw kld`, the two # commands are started by the shell at the same time and run # concurrently. However, `sw kld` will be forced to wait if it # tries to read from stdin before `sw pcr` has written to stdout. # With this in mind, it make sense for `sw kld` to do as much work # as possible before reading from stdin. io_stdin = ProtocolIO.from_stdin() io_stdout = ProtocolIO.merge(io_stdin, io_cli) io_stdout.to_stdout(self.force_text) sys.exit(io_stdout.errors) except KeyboardInterrupt: print() except StepwiseError as err: err.terminate()
def main(cls): self = cls.from_params() appcli.load(self) if not self.output: if os.fork() != 0: sys.exit() df, extras = self.load() fig = self.plot(df, extras) if self.output: out = self.output.replace('$', self.layout_toml.stem) plt.savefig(out) plt.close() else: plt.show()
def main(self): appcli.load(self) library = Library() entries = library.find_entries(self.protocol) indent = ' ' if self.organize_by_dir else '' for collection, entry_group in groupby(entries, lambda x: x.collection): if self.organize_by_dir: print(collection.name) if self.dirs_only: continue for entry in entry_group: print(indent + entry.name) if self.organize_by_dir: print()
def main(self): appcli.load(self) print("""\ yotta Y 10²⁴ zetta Z 10²¹ exa E 10¹⁸ peta P 10¹⁵ tera T 10¹² giga G 10⁹ mega M 10⁶ kilo k 10³ 10⁰ milli m 10⁻³ micro μ 10⁻⁶ nano n 10⁻⁹ pico p 10⁻¹² femto f 10⁻¹⁵ atto a 10⁻¹⁸ zepto z 10⁻²¹ yocto y 10⁻²⁴""")
def main(self): appcli.load(self) io = ProtocolIO.from_stdin() if io.errors: fatal("protocol has errors, not adding footnote.") if not io.protocol: fatal("no protocol specified.") p = io.protocol footnote = self.text if self.wrap else pre(self.text) pattern = re.compile(self.where or '(?=[.:])') try: p.insert_footnotes(footnote, pattern=pattern) except ValueError: fatal(f"pattern {pattern!r} not found in protocol.") p.merge_footnotes() io.to_stdout(self.force_text)
default=100, ) def get_protocol(self): p = stepwise.Protocol() p += pl( "Remove unligated linker by ultrafiltration:", s := ul( "Bring reaction to 500 µL with 8M urea.", f"Load onto a {self.mwco_kDa} kDa MWCO spin-filter [1].", "Spin 14000g, 15 min.", "Wash with 500 µL 8M urea.", "Wash with 500 µL nuclease-free water.", "Wash with water again.", "Wash with water again, but spin for 30 min.", "Invert the filter into a clean tube and spin 1000g, 2 min to collect ligated product in a volume of ≈15 µL.", ), ) if self.volume_uL > 15: s += f"Dilute to {self.volume_uL:g} µL with nuclease-free water" p.footnotes[1] = 'https://tinyurl.com/4ffxu8zb' p.footnotes[2] = 'Final urea concentration: ≈200 µM' return p if __name__ == '__main__': app = WashBarendt.from_params() appcli.load(app) app.protocol.print()
def main(self): appcli.load(self) # Defer importing `sqlalchemy`. from . import model with model.open_db() as db: if self.ls: model.list_protocols( db, categories=self.categories, dependencies=self.dependencies, include_dependents=self.show_dependents, include_complete=self.show_all, ) elif self.edit: model.edit_protocol( db, self.id, protocol=protocol_from_stdin(), message=self.message, categories=self.categories, dependencies=self.dependencies, explicit=self.explicit, ) elif self.peek: model.peek_protocol( db, self.id, quiet=self.quiet, force_text=self.force_text, ) elif self.pop: model.pop_protocol( db, self.id, quiet=self.quiet, force_text=self.force_text, ) elif self.drop: model.drop_protocols(db, self.ids) elif self.restore: model.restore_protocols(db, self.ids) elif self.clear: model.clear_protocols(db) elif self.reset: model.reset_protocols(db) else: protocol = protocol_from_stdin() if not protocol: if self.add: fatal("no protocol specified.") model.list_protocols( db, categories=self.categories, dependencies=self.dependencies, include_dependents=self.show_dependents, include_complete=self.show_all, ) else: model.add_protocol( db, protocol, message=self.message, categories=self.categories, dependencies=self.dependencies, )