An open API service indexing awesome lists of open source software.

https://github.com/thunderpoot/cliptoe

Command Line Interactive Periodic Table of Elements in multiple languages
https://github.com/thunderpoot/cliptoe

atoms-in-molecules calculator chemistry color colors colour colours command-line command-line-tool education educational golang molecular molecule periodic-elements periodic-table periodic-table-of-elements perl python telebasic

Last synced: about 2 months ago
JSON representation

Command Line Interactive Periodic Table of Elements in multiple languages

Awesome Lists containing this project

README

        

[![Go](https://img.shields.io/badge/go-%2300ADD8.svg?style=for-the-badge&logo=go&logoColor=white)](https://github.com/thunderpoot/cliptoe/tree/main/golang)
[![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)](https://github.com/thunderpoot/cliptoe/tree/main/web)
[![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)](https://github.com/thunderpoot/cliptoe/tree/main/web)
[![Perl](https://img.shields.io/badge/perl-%2339457E.svg?style=for-the-badge&logo=perl&logoColor=white)](https://github.com/thunderpoot/cliptoe/tree/main/perl)
[![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)](https://github.com/thunderpoot/cliptoe/tree/main/python)
[![TeleBASIC](https://raw.githubusercontent.com/telehack-foundation/.github/main/profile/svg/telebasic.svg)](https://github.com/thunderpoot/cliptoe/tree/main/telebasic)

![CLI](https://telehack.com/cmd.svg)

# cliptoe
Command Line Periodic Table of Elements

![example_gif](https://user-images.githubusercontent.com/54200401/146476909-0a99cc8e-73b7-41ee-9ca6-74fe06c93858.gif)

### What is it?

- Highlight elements on Periodic Table
- Parse chemical formulas
- Calculate atomic mass of compounds

Web-UI also available [here](https://underwood.network/ptoe).

## Usage

```
$ cliptoe -h
Command Line Interactive Periodic Table of Elements

Usage:
cliptoe [atom] show details for element by atomic symbol or number
cliptoe [compound] list elements in compound

Options:
cliptoe --animate= scroll through colours, speed is
cliptoe --var= set colour variation
cliptoe --ind= set colour start index
cliptoe --label show period and group labels
cliptoe --compounds show list of example compounds
cliptoe --key show colour key
cliptoe --table show table / highlight elements on table
cliptoe --mono disable colours
```

## Examples

Screenshot

Screenshot

Screenshot


## Concept
The idea was originally a [TeleBASIC](https://github.com/telehack-foundation/.github/blob/main/basic.md) code-golf exercise, then was ported to Perl.
The example screenshots are from the Perl version.

Recreating this program in whatever language has been helpful for me in familiarising myself with syntax,
using the same (fairly naïve) approaches. I plan to add more 'translations' eventually.

In Perl, the `ptoe_parse_input` function turns a chemical formula into its component items:
```perl
sub ptoe_parse_input
{
my ( $query ) = @_;

# Parse chemical formula, input a string and get an array
# e.g 'H2O' => $VAR1 = [ 'H', '2' ]; $VAR2 = [ 'O', '1' ];

my @elem;
while ( $query =~ /([A-Z][a-z]?)([0-9]+)?/g )
{
my $element = $1;
my $many = $2;
$many = '1' if !$many;
push @elem, [ $element, $many ];
}

return @elem;
}
```
```
$ cliptoe -d C21H30O2
$VAR1 = [
[
'C',
'21'
],
[
'H',
'30'
],
[
'O',
'2'
]
];

$ cliptoe -d NaHCO3
$VAR1 = [
[
'Na',
'1'
],
[
'H',
'1'
],
[
'C',
'1'
],
[
'O',
'3'
]
];
$
```

## Caveats / Disclaimer
These programs are only able to handle formulas like `C15H31N3O13P2`, formulas like `Fe2(SO4)3` are not supported (yet).
I'm not a chemist, and there are probably all kinds of bugs / problems that I'm not aware of.
I plan to address any such issues to the best of my ability, but cannot make any promises.

## Thanks
[@telnet23](https://github.com/telnet23)
[@kelturio](https://github.com/Kelturio)