pubchem-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/bin/pubchem.js +74 -0
- package/package.json +22 -0
- package/vendor/darwin-amd64/pubchem/pubchem +0 -0
- package/vendor/darwin-arm64/pubchem/pubchem +0 -0
- package/vendor/linux-amd64/pubchem/pubchem +0 -0
- package/vendor/linux-arm64/pubchem/pubchem +0 -0
- package/vendor/windows-amd64/pubchem/pubchem.exe +0 -0
- package/vendor/windows-arm64/pubchem/pubchem.exe +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# PubChem CLI
|
|
2
|
+
|
|
3
|
+
PubChem in your terminal.
|
|
4
|
+
|
|
5
|
+
`pubchem` is a JSON-first, agent-friendly CLI for compounds, substances, assays, references, PUG View browsing, raw PubChem/NCBI endpoints, resolution workflows, exports, and batch automation.
|
|
6
|
+
|
|
7
|
+
The npm package ships prebuilt binaries for Linux, macOS, and Windows on `amd64` and `arm64`, so `npx pubchem-cli` works directly on common platforms.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx pubchem-cli --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Global install:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g pubchem-cli
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For local development in this repo:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
go build -o ./pubchem ./cmd/pubchem
|
|
27
|
+
./pubchem --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pubchem <command> [flags]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Root flags:
|
|
37
|
+
|
|
38
|
+
- `--json`: Output JSON to stdout.
|
|
39
|
+
- `--plain`: Output stable plain text to stdout.
|
|
40
|
+
- `--results-only`: In JSON mode, emit only the primary result.
|
|
41
|
+
- `--select`: In JSON mode, select comma-separated fields with dot-path support.
|
|
42
|
+
- `--force`: Skip confirmations for future destructive commands.
|
|
43
|
+
- `--no-input`: Never prompt; fail instead.
|
|
44
|
+
- `--enable-commands`: Comma-separated list of enabled top-level commands.
|
|
45
|
+
- `--version`: Print version and exit.
|
|
46
|
+
- `--help`: Show context-sensitive help.
|
|
47
|
+
|
|
48
|
+
Top-level command families:
|
|
49
|
+
|
|
50
|
+
- `compound`
|
|
51
|
+
- `substance`
|
|
52
|
+
- `assay`
|
|
53
|
+
- `entity`
|
|
54
|
+
- `batch`
|
|
55
|
+
- `refs`
|
|
56
|
+
- `view`
|
|
57
|
+
- `raw`
|
|
58
|
+
- `resolve`
|
|
59
|
+
- `identity`
|
|
60
|
+
- `export`
|
|
61
|
+
- `schema`
|
|
62
|
+
- `agent`
|
|
63
|
+
- `completion`
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
Version:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ pubchem --version
|
|
71
|
+
pubchem dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Compound search:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
$ pubchem compound search aspirin --max 1
|
|
78
|
+
{
|
|
79
|
+
"mode": "name",
|
|
80
|
+
"query": "aspirin",
|
|
81
|
+
"totalFound": 1,
|
|
82
|
+
"returned": 1,
|
|
83
|
+
"pageSize": 1,
|
|
84
|
+
"results": [
|
|
85
|
+
{
|
|
86
|
+
"cid": 2244,
|
|
87
|
+
"properties": {
|
|
88
|
+
"Charge": 0,
|
|
89
|
+
"Complexity": 212,
|
|
90
|
+
"ConnectivitySMILES": "CC(=O)OC1=CC=CC=C1C(=O)O",
|
|
91
|
+
"HBondAcceptorCount": 4,
|
|
92
|
+
"HBondDonorCount": 1,
|
|
93
|
+
"HeavyAtomCount": 13,
|
|
94
|
+
"IUPACName": "2-acetyloxybenzoic acid",
|
|
95
|
+
"InChIKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N",
|
|
96
|
+
"MolecularFormula": "C9H8O4",
|
|
97
|
+
"MolecularWeight": "180.16",
|
|
98
|
+
"RotatableBondCount": 3,
|
|
99
|
+
"SMILES": "CC(=O)OC1=CC=CC=C1C(=O)O",
|
|
100
|
+
"TPSA": 63.6,
|
|
101
|
+
"XLogP": 1.2
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3D structure metadata:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
$ pubchem compound structure 2244 --record-type 3d --format json
|
|
112
|
+
{
|
|
113
|
+
"recordType": "3d",
|
|
114
|
+
"downloadUrl": "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/2244/SDF?record_type=3d",
|
|
115
|
+
"results": [
|
|
116
|
+
{
|
|
117
|
+
"cid": 2244,
|
|
118
|
+
"structure": {
|
|
119
|
+
"title": "Aspirin",
|
|
120
|
+
"molecularFormula": "C9H8O4",
|
|
121
|
+
"molecularWeight": 180.16,
|
|
122
|
+
"inchiKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N",
|
|
123
|
+
"has3d": true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
For the full command tree and machine-readable schema, use:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pubchem --help
|
|
134
|
+
pubchem schema
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
If you want the exact command and flag surface for automation, prefer `pubchem schema <command>` and `pubchem --help` over guessing from memory.
|
package/bin/pubchem.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("node:child_process");
|
|
4
|
+
const { existsSync } = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const TARGETS = {
|
|
8
|
+
linux: {
|
|
9
|
+
x64: "linux-amd64",
|
|
10
|
+
arm64: "linux-arm64",
|
|
11
|
+
},
|
|
12
|
+
darwin: {
|
|
13
|
+
x64: "darwin-amd64",
|
|
14
|
+
arm64: "darwin-arm64",
|
|
15
|
+
},
|
|
16
|
+
win32: {
|
|
17
|
+
x64: "windows-amd64",
|
|
18
|
+
arm64: "windows-arm64",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const platformTargets = TARGETS[process.platform];
|
|
23
|
+
if (!platformTargets) {
|
|
24
|
+
throw new Error(`Unsupported platform: ${process.platform} (${process.arch})`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const target = platformTargets[process.arch];
|
|
28
|
+
if (!target) {
|
|
29
|
+
throw new Error(`Unsupported platform: ${process.platform} (${process.arch})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const binaryName = process.platform === "win32" ? "pubchem.exe" : "pubchem";
|
|
33
|
+
const binaryPath = path.join(__dirname, "..", "vendor", target, "pubchem", binaryName);
|
|
34
|
+
|
|
35
|
+
if (!existsSync(binaryPath)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Missing PubChem binary at ${binaryPath}.\n` +
|
|
38
|
+
"Reinstall with: npm install -g pubchem-cli",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
43
|
+
stdio: "inherit",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
child.on("error", (err) => {
|
|
47
|
+
console.error(err);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const forwardSignal = (signal) => {
|
|
52
|
+
if (child.killed) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
child.kill(signal);
|
|
58
|
+
} catch {
|
|
59
|
+
// Ignore forwarding failures; the child exit handler will still finish cleanly.
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((signal) => {
|
|
64
|
+
process.on(signal, () => forwardSignal(signal));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
child.on("exit", (code, signal) => {
|
|
68
|
+
if (signal) {
|
|
69
|
+
process.kill(process.pid, signal);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
process.exit(code ?? 1);
|
|
74
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pubchem-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PubChem in your terminal.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/siddheshkothadi/pubchem-cli.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"pubchem": "bin/pubchem.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"vendor"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|