Giter VIP home page Giter VIP logo

plotting-ribbons's Introduction

Plotting Ribbons

An easy way to use fogleman/ribbon to create ready to plot SVGs like these:

Create SVGs

Install fogleman/ribbon and get the source code.

go get -u github.com/fogleman/ribbon/cmd/rcsb
git clone [email protected]: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.

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 = ['<polyline fill=\"none\" stroke=\"#00f\" points=\"' + ' '.join(line) + '\"/>' for line in lines]
with open('$id.svg','w') as f: f.write('\n'.join(['<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"26.45834cm\" viewBox=\"0 0 1000 1000\" width=\"26.45834cm\">']+polyline_strs+['</svg>']))"; done

Get RCSB Structure IDs

You can go to the Protein Data Bank main page or search 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.

ids=$(cat all_ids_01_2021.txt | cut -c1-50) # get ids from 1-50 (10*5) get the first 10 ids
echo $ids

plotting-ribbons's People

Contributors

piebro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.