Skip to content

Commit

Permalink
add hdb, r2b, tdb, arn
Browse files Browse the repository at this point in the history
  • Loading branch information
gxf1212 committed Dec 12, 2023
1 parent d0a0046 commit 82ce045
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
- fixed mol2,frcmod bugs
- fixed pdb/psf highlight by section (begin/end but keyword cannot be highlighted) problem

### 0.0.6

- add hdb, r2b, tdb, arn

15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# md-highlighter README

`md-highlighter` is a simple extension to highlight files about molecular modeling and molecular dynamics simulation. Specially, it supports NAMD/CHARMM and some of Amber file formats.
`md-highlighter` is a simple extension to highlight the most various file types about molecular modeling and molecular dynamics simulation. This extension provides comprehensive coverage of commonly used file formats under various popular tools, including Gromacs, Amber, AmberTools, NAMD, VMD, and more. It also performs detailed keyword parsing, helping users to locate and edit information within files more quickly. Users can even identify syntax errors quickly based on different display colors. Feel free to download and try it out, and don't hesitate to recommend it to your colleagues!

## Features

Supported format:

- NAMD: rtf, pdb, prm, psf, str, inp
- Amber: in, prmtop, inpcrd, prepin, frcmod
- Gromacs: gro, atp, rtp, mtp (pmx), ...
- Amber: in, prmtop, inpcrd, prepin, frcmod, lib/off, ac, mc
- Gromacs: gro, atp, arn, rtp, hdb, r2b, tdb, mtp (pmx), ...
- small molecule: sdf, mol2 (modified from gromacs helper), ...
- PLUMED: .plumed.dat
- upcoming: (AmberTools leap), lib,...

For gromacs-related files, please install `gromacs-helper`. For VMD, install `TCL`. For Gaussian, install `Gaussian Input File (gjf)`. But maybe I'll make my own syntaxes.
For gromacs `.top`/`.itp` files, you may also install `gromacs-helper`. For VMD, install `TCL`. For Gaussian, install `Gaussian Input File (gjf)`. But maybe I make my own syntaxes.

Tested in theme "Atom One Light".

This extension is created with the help of ChatGPT and New Bing.

## Gallery

Install to explore more file types!
Expand All @@ -42,7 +39,7 @@ Install to explore more file types!
## Conventions

- variable.other.residue-number (except psf,gro)
- entity.name.type.residue-name
- entity.name.type.residue-name (except hdb)
- constant.numeric.atom-number (except gro,lib)
- entity.name.tag.atom-name
- support.type.atom-type
Expand Down Expand Up @@ -79,6 +76,8 @@ TODO:
- add self-defined colors like pink, etc.
- sdf file?

This extension is created with the help of ChatGPT and New Bing in the beginning.

## Release Notes

see CHANGELOG
Expand Down
63 changes: 59 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "md-highlighter",
"displayName": "md-highlighter",
"description": "Highlighting files about molecular modeling and dynamics simulation.",
"version": "0.0.5",
"version": "0.0.6",
"publisher": "gxf1212",
"repository": "https://github.com/gxf1212/md-highlighter",
"engines": {
Expand All @@ -16,7 +16,7 @@
"languages": [{
"id": "rtf",
"aliases": ["NAMD force field", "rtf"],
"extensions": [".rtf", ".str", ".inp", ".prm"],
"extensions": [".rtf", ".str", ".inp", ".prm", ".par"],
"configuration": "./language-configuration.json"
},
{
Expand All @@ -41,13 +41,13 @@
{
"id": "prmtop",
"aliases": ["Amber topology file", "prmtop"],
"extensions": [".prmtop", "parm7"],
"extensions": [".prmtop", ".parm7"],
"configuration": "./language-configuration.json"
},
{
"id": "inpcrd",
"aliases": ["Amber coordinate file", "inpcrd"],
"extensions": [".inpcrd", "rst7"],
"extensions": [".inpcrd", ".rst7"],
"configuration": "./language-configuration.json"
},
{
Expand Down Expand Up @@ -75,6 +75,12 @@
"extensions": [".ac", ".AC"],
"configuration": "./language-configuration.json"
},
{
"id": "mc",
"aliases": ["Antechamber mainchain file"],
"extensions": [".mc"],
"configuration": "./language-configuration.json"
},
{
"id": "gro",
"aliases": ["Gromacs coordinate file"],
Expand All @@ -87,11 +93,35 @@
"extensions": [".atp"],
"configuration": "./language-configuration.json"
},
{
"id": "arn",
"aliases": ["Gromacs atom renaming specification"],
"extensions": [".arn"],
"configuration": "./language-configuration.json"
},
{
"id": "rtp",
"aliases": ["Gromacs residue type file"],
"extensions": [".rtp"],
"configuration": "./language-configuration.json"
},
{
"id": "hdb",
"aliases": ["Gromacs hydrogen database"],
"extensions": [".hdb"],
"configuration": "./language-configuration.json"
},
{
"id": "r2b",
"aliases": ["Gromacs r2b file"],
"extensions": [".r2b"],
"configuration": "./language-configuration.json"
},
{
"id": "tdb",
"aliases": ["Gromacs terminal database"],
"extensions": [".tdb"],
"configuration": "./language-configuration.json"
},
{
"id": "mtp",
Expand Down Expand Up @@ -167,6 +197,11 @@
"scopeName": "source.ac",
"path": "./syntaxes/ac.tmLanguage.json"
},
{
"language": "mc",
"scopeName": "source.mc",
"path": "./syntaxes/mc.tmLanguage.json"
},
{
"language": "gro",
"scopeName": "source.gro",
Expand All @@ -177,11 +212,31 @@
"scopeName": "source.atp",
"path": "./syntaxes/atp.tmLanguage.json"
},
{
"language": "arn",
"scopeName": "source.arn",
"path": "./syntaxes/arn.tmLanguage.json"
},
{
"language": "rtp",
"scopeName": "source.rtp",
"path": "./syntaxes/rtp.tmLanguage.json"
},
{
"language": "hdb",
"scopeName": "source.hdb",
"path": "./syntaxes/hdb.tmLanguage.json"
},
{
"language": "r2b",
"scopeName": "source.r2b",
"path": "./syntaxes/r2b.tmLanguage.json"
},
{
"language": "tdb",
"scopeName": "source.tdb",
"path": "./syntaxes/tdb.tmLanguage.json"
},
{
"language": "mtp",
"scopeName": "source.mtp",
Expand Down
33 changes: 33 additions & 0 deletions syntaxes/arn.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://github.com/raw/martinring/tmlanguage/master/tmlanguage.json",
"name": "arn",
"scopeName": "source.arn",
"fileTypes": [
"arn"
],
"patterns": [
{
"name": "comment.line.semicolon",
"match": ";.*$"
},
{
"name": "constant.numberic.arn",
"match": "-?\\d+\\.\\d*"
},
{
"//": "the word after RESI|PRES",
"name": "entity.name.type.residue-name.rtf",
"match": "(?<=^\\s*)\\S+"
},
{
"//": "add (4/5, after two numbers), improper (4)",
"name": "entity.name.tag.atom-name.tdb",
"match": "(?<=^\\s*\\S+\\s*)[0-9]*[A-Z]+[A-Z0-9_'*]*"
},
{
"//": "all strings made up of capitalized letters and numbers. matching a lot of remaining strings...including dihedral n",
"name": "support.type.atom-type.arn",
"match": "(?<=^\\s*\\S+\\s*[0-9]*[A-Z]+[A-Z0-9_'*]*\\s*)[0-9]*[A-Z]+[A-Z0-9_'*]*"
}
]
}
30 changes: 30 additions & 0 deletions syntaxes/hdb.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://github.com/raw/martinring/tmlanguage/master/tmlanguage.json",
"name": "Gromacs hdb file",
"scopeName": "source.hdb",
"fileTypes": [
"hdb"
],
"patterns": [
{
"name": "comment.line.exclamation",
"match": ";.*$"
},
{
"name": "support.type.residue-name.hdb",
"match": "(?<=^)\\S+(?=\\s*\\d+\\s*$)"
},
{
"name": "string.other.count.hdb",
"match": "(?<=^\\S+\\s*)\\d+(?=\\s*$)"
},
{
"name": "entity.name.tag.atom-name.hdb",
"match": "(?<=^\\d+\\s+\\d+\\s+)\\S+\\s+\\S+(\\s+\\S+\\s+\\S+)?(\\s+\\S+)?(?=\\s*$)"
},
{
"name": "constant.numeric.hdb",
"match": "\\b\\d+\\b|(?<=^\\s*)\\d+|(\\b|\\-)\\d+\\.?\\d*([eE][\\+\\-]?\\d+)?"
}
]
}
30 changes: 30 additions & 0 deletions syntaxes/mc.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://github.com/raw/martinring/tmlanguage/master/tmlanguage.json",
"name": "mc",
"scopeName": "source.mc",
"fileTypes": [
"mc"
],
"patterns": [
{
"match": "HEAD_NAME|TAIL_NAME|PRE_HEAD_TYPE|POST_TAIL_TYPE|CHARGE",
"name": "keyword.other.mc"
},
{
"match": "OMIT_NAME",
"name": "string.other.mc"
},
{
"name": "entity.name.tag.atom-name.mc",
"match": "(?<=NAME\\s*)\\b\\S+\\b"
},
{
"name": "support.type.atomtype.mc",
"match": "(?<=TYPE\\s*)\\b\\S+\\b"
},
{
"name": "constant.numeric.mc",
"match": "\\b(-?\\d*\\.\\d*)\\b|\\b\\d+\\b"
}
]
}
22 changes: 22 additions & 0 deletions syntaxes/r2b.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://github.com/raw/martinring/tmlanguage/master/tmlanguage.json",
"name": "Gromacs r2b file",
"scopeName": "source.r2b",
"fileTypes": [
"r2b"
],
"patterns": [
{
"name": "comment.line.exclamation",
"match": ";.*$"
},
{
"name": "entity.name.type.residue-name.r2b",
"match": "\\S+"
},
{
"name": "constant.numeric.r2b",
"match": "\\b\\d+\\b|(?<=^\\s*)\\d+|(\\b|\\-)\\d+\\.?\\d*([eE][\\+\\-]?\\d+)?"
}
]
}
6 changes: 3 additions & 3 deletions syntaxes/rtf.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
},
{
"name": "keyword.rtf",
"match": "\\b(MASS|RESI|PRES|DELETE|ATOM|BOND|ANGLE(S)?|DIHE(DRAL)?|IMPR|(?i)IC|BILD|ACCE(PTOR)?|DONO(R)?|DOUBLE|DOUB|(?i)PATC(H)?|PATCHING|LONEPAIR|COLI|DIST|SCAL|DECL|DEFA|AUTO|FIRS|LAST|first|last|default)\\b"
"match": "\\b(MASS|RESI|PRES|DELETE|ATOM|BOND|ANGLE(S)?|DIHE(DRAL)?|IMPR|IMPH|(?i)IC|BILD|ACCE(PTOR)?|DONO(R)?|DOUBLE|DOUB|(?i)PATC(H)?|PATCHING|LONEPAIR|COLI|DIST|SCAL|DECL|DEFA|AUTO|FIRS|LAST|first|last|default)\\b"
},
{
"name": "keyword.prm",
"match": "(MASS|ATOMS|BONDS|ANGLES|DIHEDRALS|IMPROPERS|CMAP|NONBONDED|NBFIX|HBOND|CUTHB)"
"match": "(MASS|ATOMS|BONDS|ANGLES|DIHEDRALS|IMPROPER(S)?|CMAP|NONBONDED|NBFIX|HBOND|CUTHB)"
},
{
"name": "entity.name.section.prm",
Expand Down Expand Up @@ -64,7 +64,7 @@
"note": "bond: variable length of pairs; impr: four strings",
"///": "Maybe atom names can be de",
"name": "entity.name.tag.atom.rtf",
"match": "(?<=\\bATOM\\s*)\\S+|(?<=\\bBOND\\s*)(\\S+\\s+\\S+\\s*)+|(?<=\\bANGLE\\s*)((\\S+\\s*){3})+|(?<=\\bIMPR\\s*)((\\S+\\s*){4})+|(?<=\\bCMAP\\s*)((\\S+\\s*){8})+|(?<=\\b\\s*(?i)IC\\s*)(\\S+\\s+){4}|(?<=\\b\\s*BILD\\s*)(\\S+\\s+){4}"
"match": "(?<=\\bATOM\\s*)\\S+|(?<=\\bBOND\\s*)(\\S+\\s+\\S+\\s*)+|(?<=\\bANGLE\\s*)((\\S+\\s*){3})+|(?<=\\bIMPR\\s*)((\\S+\\s*){4})+|(?<=\\bIMPH\\s*)((\\S+\\s*){4})+|(?<=\\bCMAP\\s*)((\\S+\\s*){8})+|(?<=\\b\\s*(?i)IC\\s*)(\\S+\\s+){4}|(?<=\\b\\s*BILD\\s*)(\\S+\\s+){4}"
},
{
"//": "the several words after a keyword.",
Expand Down
47 changes: 47 additions & 0 deletions syntaxes/tdb.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "https://github.com/raw/martinring/tmlanguage/master/tmlanguage.json",
"name": "Gromacs terminal database",
"scopeName": "source.tdb",
"fileTypes": [
"tdb"
],
"patterns": [
{
"name": "comment.line.semicolon",
"match": ";.*$"
},
{
"//": "section",
"match": "\\[.*\\]",
"name": "entity.name.class"
},
{
"//": "deltete (one space); replace (before type mass charge)",
"name": "entity.name.tag.atom-name.tdb",
"match": "(?<=^\\s)[0-9]*[A-Z]+[A-Z0-9_']*|[0-9]*[A-Z]+[A-Z0-9_']*(?=\\s+[0-9]*[A-Z]+[A-Z0-9_'*]*\\s+-?\\d+\\.\\d*)"
},
{
"//": "add (4/5, after two numbers), improper (4)",
"name": "entity.name.tag.atom-name2.tdb",
"match": "(\\s*-?\\+?[0-9]*[A-Z]+[A-Z0-9_'\\+]*){4}(\\s*-?\\+?[0-9]*[A-Z]+[A-Z0-9_'\\+]*)?"
},
{
"//": "after atom name, match any of these strings",
"name": "support.type.atom-type.tdb",
"match": "[0-9]*[A-Z]+[A-Z0-9_'*]*(?=\\s+-?\\d+\\.\\d*)"
},
{
"name": "constant.numeric.atomic-mass.tdb",
"match": "(?<=[0-9]*[A-Z]+[A-Z0-9_'*]*\\s+)-?\\d+\\.\\d*"
},
{
"name": "string.quoted.charge.tdb",
"match": "(?<=[0-9]*[A-Z]+[A-Z0-9_'*]*\\s+-?\\d+\\.\\d*\\s+)-?\\d+\\.\\d*"
},
{
"//": "number",
"match": "(\\b|\\-)\\d+\\.?\\d*([eE][\\+\\-]?\\d+)?",
"name": "constant.language.tdb"
}
]
}

0 comments on commit 82ce045

Please sign in to comment.