Skip to content

Instantly share code, notes, and snippets.

View philipturner's full-sized avatar
🏠
Working from home

Philip Turner philipturner

🏠
Working from home
View GitHub Profile
7739
1 H 6.766 1.065 0.552 1 1
2 C 6.785 1.787 1.402 6 0 3 7 11
3 H 8.877 2.346 1.115 1 3
4 C 7.878 2.834 1.171 6 1 2 4 5
5 H 7.720 3.338 0.192 1 3
6 C 7.873 3.861 2.313 6 3 15 22 28
7 H 4.631 1.655 1.761 1 11
8 C 7.201 1.068 2.685 6 1 8 9 10
9 H 8.232 0.658 2.583 1 7
7739
1 H 0.274 0.274 0.274 1 1
2 C 0.892 0.892 0.892 6 0 3 7 11
3 H 2.401 1.166 -0.618 1 3
4 C 1.783 1.783 0.000 6 1 2 4 5
5 H 1.166 2.401 -0.618 1 3
6 C 2.675 2.675 0.892 6 3 15 22 28
7 H -0.618 1.166 2.401 1 11
8 C 1.783 0.000 1.783 6 1 8 9 10
9 H 2.401 -0.618 1.166 1 7
7739
H 6.766 1.065 0.552
C 6.785 1.787 1.402
H 8.877 2.346 1.115
C 7.878 2.834 1.171
H 7.720 3.338 0.192
C 7.873 3.861 2.313
H 4.631 1.655 1.761
C 7.201 1.068 2.685
7739
H 0.274 0.274 0.274
C 0.892 0.892 0.892
H 2.401 1.166 -0.618
C 1.783 1.783 0.000
H 1.166 2.401 -0.618
C 2.675 2.675 0.892
H -0.618 1.166 2.401
C 1.783 0.000 1.783
4
1 H 0.000 0.000 0.000 1 2
2 C 1.060 0.000 0.000 6 1 3
3 C 2.260 0.000 0.000 6 2 4
4 H 3.320 0.000 0.000 1 3

Molecular Structure Exporting

This is a document about serializing molecules in different file formats.

ARC Files

I am unsure whether these ARC files are formatted correctly. However, they contain a bonding topology.

  • Coordinates: in Å
//
// OfflineRendering.swift
// MolecularRendererApp
//
// Created by Philip Turner on 4/4/24.
//
import CairoGraphics
import Foundation
import GIF
This file has been truncated, but you can view the full file.
// 7739 atoms
// 1.122 megabytes of raw text
//
// Reason this script was created:
// https://x.com/StephaneRedon/status/1781714937200398775
//
// Expected results (if the data is decoded and rendered correctly):
// https://twitter.com/philipturnerar/status/1781098723977683061
// MARK: - Usage Instructions
import Foundation
// This script:
//
// Removes the outliers at 2-theta < 10 degrees, as they mess with the algorithm
// and are omitted from the graphs anyway.
//
// Finds a baseline for the data.
// 1) Locate all the data points within +/-2.5 degrees of the current point.
// 2) Take the minimum of these points.
import Foundation
let data = try! Data(contentsOf: URL(fileURLWithPath: "/Users/philipturner/Desktop/data.txt"))
print(data.count)
let inputString = String(data: data, encoding: .utf8)!
let inputLines = inputString.split(separator: "\n").map(String.init)
for line in inputLines {
let fragments = line.split(separator: " ").map(String.init)
guard fragments.count == 3 else {