Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CIF parser #357

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions io/pdbx/cif/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Package cif provides utilities to read and write CIF v1.1 files.

See https://www.iucr.org/resources/cif/spec/version1.1 for a full
description of the CIF v1.1 syntax.
*/
package cif
22 changes: 22 additions & 0 deletions io/pdbx/cif/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cif

import "fmt"

// A CIFSyntaxError is a syntax error produced while parsing a CIF file.
type CIFSyntaxError struct {
Line int
Msg string
}

// Wrap creates a new CIFSyntaxError wrapped with msg.
func (s CIFSyntaxError) Wrap(format string, a ...any) error {
return CIFSyntaxError{
Line: s.Line,
Msg: fmt.Sprintf("%s: %s", fmt.Sprintf(format, a...), s.Msg),
}
}

// Error returns the formatted error message.
func (s CIFSyntaxError) Error() string {
return fmt.Sprintf("CIF syntax error at line %v: %s", s.Line, s.Msg)
}
Loading
Loading