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

Prepare the repo for opening #56

Merged
merged 11 commits into from
Feb 16, 2018
Merged
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
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,7 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Files from other sources are redistributed as part of the package in the
vermouth/redistributed directory. See vermouth/redistributed/LICENSE for the
license of these files.
80 changes: 78 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
# Martinize2: The ultimate resolution transformation tool
# Martinize2 and vermouth: The ultimate resolution transformation tools

TODO: documentation
Martinize2 is a rewrite of [Martinize]. It is aimed at producing
coarse-grained structures and topologies from an atomistic structure. Martinize
is primarily developed for the [Martini] coarse-grained force field and the
[Gromacs] simulation engine. However the architecture of the program will
allow us to support a broader range of force fields and simulation engines in
the future.

Vermouth (for VERsatile, MOdular, and Universal Tranformation Helper) is the
python library that powers Martinize2. It allows to describe and apply
transformation on molecular structures and topologies using graph algorithms.

## Disclaimer

**Both Martinize2 and vermouth are at a prototype stage. DO NOT USE IN
PRODUCTION.**

## Installation

Martinize2 and vermouth require python 3.4 or greater. They can be installed
using the `pip` command:

pip install git+https://github.com/jbarnoud/martinize2.git#vermouth

The behavior of the `pip` command can vary depending of the specificity of your
python installation. See the [documentation on installing a python
package][pipdoc] to learn more.

## Basic usage

Installing Martinize2 and vermouth with `pip` adds the `martinize2` program to
the research PATH. You can see the available option of the program by running:

martinize2 -h

At the moment, martinize2 tries to reproduce the interface of the original
Martinize. You can find explanations on how to use Martinize on the [Martini
tutorials]; in most cases, replacing calls to `martinize.py` by calls to
`martinize2` should produce similar results.

The documentation of the vermouth python library will come soon.

## License

Martinize2 and vermouth are distributed under the Apache 2.0 license.

Copyright 2018 University of Groningen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http:https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

The [full text of the license][license] is available in the source repository.

## Contributions

The development of Martinize2 and vermouth is done on [github]. Contributions
are welcome as [bug reports] and [pull requests]. Note however that the
decision of whether or not contributions can give authorship on the resulting
academic paper is left to our sole discretion.

[Martinize]: https://github.com/Tsjerk/Martinize
[Martini]: http:https://cgmartini.nl
[Martini tutorials]: http:https://cgmartini.nl/index.php/tutorials-general-introduction-gmx5
[Gromacs]: http:https://www.gromacs.org
[pipdoc]: https://packaging.python.org/tutorials/installing-packages/#installing-packages
[license]: https://github.com/jbarnoud/martinize2/blob/master/LICENSE
[github]: https://github.com/jbarnoud/martinize2
[bug reports]: https://github.com/jbarnoud/martinize2/issues
[pull requests]: https://github.com/jbarnoud/martinize2/pulls
16 changes: 15 additions & 1 deletion embed_test.py → bin/embed_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 University of Groningen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Created on Wed Aug 30 13:07:14 2017

@author: peterkroon
"""

from martinize2 import *
from vermouth import *
import networkx as nx
import numpy as np
import scipy.sparse.csgraph as ssc
Expand Down
51 changes: 35 additions & 16 deletions entry_api.py → bin/martinize2
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 University of Groningen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
High level API for Martinize2
"""
Expand All @@ -7,9 +22,9 @@
from pathlib import Path
import os
import numpy as np
import martinize2 as m2
from martinize2.forcefield import find_force_fields, FORCE_FIELDS
from martinize2 import DATA_PATH
import vermouth
from vermouth.forcefield import find_force_fields, FORCE_FIELDS
from vermouth import DATA_PATH
import itertools
import operator
import textwrap
Expand Down Expand Up @@ -117,12 +132,12 @@ def read_system(path):

The resulting system does not have a force field and may not have edges.
"""
system = m2.System()
system = vermouth.System()
file_extension = path.suffix.upper()[1:] # We do not keep the dot
if file_extension in ['PDB', 'ENT']:
m2.PDBInput().run_system(system, str(path))
vermouth.PDBInput().run_system(system, str(path))
elif file_extension in ['GRO']:
m2.GROInput().run_system(system, str(path))
vermouth.GROInput().run_system(system, str(path))
else:
raise ValueError('Unknown file extension "{}".'.format(file_extension))
return system
Expand All @@ -142,19 +157,21 @@ def pdb_to_universal(system, delete_unknown=False):
"""
canonicalized = system.copy()
canonicalized.force_field = FORCE_FIELDS['universal']
m2.MakeBonds().run_system(canonicalized)
m2.RepairGraph(delete_unknown=delete_unknown).run_system(canonicalized)
vermouth.MakeBonds().run_system(canonicalized)
vermouth.RepairGraph(delete_unknown=delete_unknown).run_system(canonicalized)
return canonicalized


def martinize(system, mappings, to_ff, delete_unknown=False):
"""
Convert a system from one force field to an other at lower resolution.
"""
m2.DoMapping(mappings=mappings, to_ff=to_ff, delete_unknown=delete_unknown).run_system(system)
m2.DoAverageBead().run_system(system)
m2.ApplyBlocks().run_system(system)
m2.DoLinks().run_system(system)
vermouth.DoMapping(mappings=mappings,
to_ff=to_ff,
delete_unknown=delete_unknown).run_system(system)
vermouth.DoAverageBead().run_system(system)
vermouth.ApplyBlocks().run_system(system)
vermouth.DoLinks().run_system(system)
return system


Expand All @@ -175,7 +192,7 @@ def write_gmx_topology(system, top_path):
for molidx, (molecule_type, _) in enumerate(molecule_types):
molecule_type.moltype = 'molecule_{}'.format(molidx)
with open('molecule_{}.itp'.format(molidx), 'w') as outfile:
m2.gmx.itp.write_molecule_itp(molecule_type, outfile)
vermouth.gmx.itp.write_molecule_itp(molecule_type, outfile)
# Reorganize the molecule type assignment to write the top file.
# The top file "molecules" section lists the molecules in the same order
# as in the structure and group them. To do the grouping, we associate each
Expand Down Expand Up @@ -230,7 +247,9 @@ def entry():
parser.add_argument('-ff', dest='to_ff', default='martini22')
args = parser.parse_args()

known_force_fields = m2.forcefield.find_force_fields(Path(DATA_PATH) / 'force_fields')
known_force_fields = vermouth.forcefield.find_force_fields(
Path(DATA_PATH) / 'force_fields'
)
known_mappings = read_mapping_directory(Path(DATA_PATH) / 'mappings')

from_ff = 'universal'
Expand Down Expand Up @@ -259,10 +278,10 @@ def entry():
if args.posres != 'None':
selectors = {'All': select_all, 'Backbone': select_backbone}
selector = selectors[args.posres]
m2.ApplyPosres(selector, args.posres_fc).run_system(system)
vermouth.ApplyPosres(selector, args.posres_fc).run_system(system)

# Write a PDB file.
m2.pdb.write_pdb(system, str(args.outpath))
vermouth.pdb.write_pdb(system, str(args.outpath))

write_gmx_topology(system, Path('topol.top'))

Expand Down
16 changes: 15 additions & 1 deletion run_martinize2.py → bin/run_martinize2.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2018 University of Groningen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Created on Tue Aug 22 11:48:46 2017

@author: Peter Kroon
"""
#import matplotlib.pyplot as plt
#plt.close('all')
from martinize2 import *
from vermouth import *

import os.path as osp

Expand Down
19 changes: 0 additions & 19 deletions martinize2/__init__.py

This file was deleted.

Loading