https://github.com/piebro/plotting-ribbons
https://github.com/piebro/plotting-ribbons
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/piebro/plotting-ribbons
- Owner: piebro
- Created: 2020-11-30T19:22:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-09T18:13:05.000Z (over 5 years ago)
- Last Synced: 2025-01-18T04:43:33.089Z (over 1 year ago)
- Size: 3.69 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Plotting Ribbons
An easy way to use [fogleman/ribbon](https://github.com/fogleman/ribbon) to create ready to plot SVGs like these:


## Create SVGs
Install [fogleman/ribbon](https://github.com/fogleman/ribbon) and get the source code.
```bash
go get -u github.com/fogleman/ribbon/cmd/rcsb
git clone git@github.com:fogleman/ribbon.git
```
Run the lines cmd with `go run ribbon/cmd/lines/main.go` with a 4-digit RCSB Structure ID to print all lines to the console. With the following cmd you can save all 4-digit RCSB Structure IDs in `ids` and as SVGs. You can set IDs for example with `ids="1A08 6UFW"` and run the following cmd to create the SVGs.
```bash
for id in $ids; do echo $id; go run ribbon/cmd/lines/main.go $id | python -c "import sys
points = [str(round((float(num)+1)*500*1e6)/1e6) for num in sys.stdin.read()[:-1].replace('\n',',').replace(';',',').split(',')]
lines = [points[:4]]
for i in range(4,len(points), 4):
if lines[-1][-2:] == points[i:i+2]: lines[-1].extend(points[i+2:i+4])
else: lines.append(points[i:i+4])
polyline_strs = ['' for line in lines]
with open('$id.svg','w') as f: f.write('\n'.join(['']+polyline_strs+['']))"; done
```
## Get RCSB Structure IDs
You can go to the [Protein Data Bank](http://www.rcsb.org) main page or [search](http://www.rcsb.org/search?q=*) to find a structure.
All IDs up to the end of 2020 are in `all_ids_01_2021.txt`. Run the following cmd to get all ids in a certain range and save it to ids.
```bash
ids=$(cat all_ids_01_2021.txt | cut -c1-50) # get ids from 1-50 (10*5) get the first 10 ids
echo $ids
```