From 75a047e9cf73abf7467fd8fc2d1d5f961ee55505 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 19 Nov 2020 17:30:47 +0100 Subject: [PATCH] Allow to create PDB specific filters --- app/main.f90 | 18 ++++++++++++++---- fpm.toml | 2 +- man/mctc-rmsd.1.adoc | 9 +++++++++ meson.build | 2 +- src/rmsd/filter.f90 | 26 +++++++++++++++++++++++--- src/rmsd/version.f90 | 4 ++-- 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/app/main.f90 b/app/main.f90 index 3c63a80..e3f1457 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -58,13 +58,14 @@ program rmsd_main call get_value(opts, "help", show_help, size(args) <= 1 .and. .not.show_rc) call opts%destroy - if (show_help) then - call help(output_unit) + if (show_version) then + call version(output_unit) stop end if - if (show_version) then - call version(output_unit) + if (show_help) then + call help(output_unit) + if (size(args) <= 1) error stop stop end if @@ -212,6 +213,15 @@ subroutine help(unit) "", & "Note that this approach will still consider deuterium labeled as D,", & "which would be excluded as well when using the atomic number instead.", & + "", & + "To create a PDB specific filter use the four character PDB identifier", & + "of the atoms and enable the PDB functionality.", & + "To match only the proteine backbone use", & + "", & + " c-alpha.include = ["" CA "", "" N "", "" C "", "" O ""]", & + " c-alpha.pdb = true", & + "", & + "Atomic numbers and element symbols can be included here as well.", & "" end subroutine help diff --git a/fpm.toml b/fpm.toml index 7448e04..4dc6e7e 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "mctc-rmsd" -version = "0.1.0" +version = "0.1.1" license = "LGPL-3.0-or-later" [dependencies] diff --git a/man/mctc-rmsd.1.adoc b/man/mctc-rmsd.1.adoc index a6761d3..0ba0ac4 100644 --- a/man/mctc-rmsd.1.adoc +++ b/man/mctc-rmsd.1.adoc @@ -54,3 +54,12 @@ excluding hydrogen with standard symbols, use: Note that this approach will still consider deuterium labeled as D, which would be excluded as well when using the atomic number instead. + +To create a PDB specific filter use the four character PDB identifier +of the atoms and enable the PDB functionality. +To match only the proteine backbone use + + backbone.include = [" CA ", " N ", " C ", " O "] + backbone.pdb = true + +Atomic numbers and element symbols can be included here as well. diff --git a/meson.build b/meson.build index 6cea90e..df8ad48 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,7 @@ project( 'mctc-rmsd', 'fortran', - version: '0.1.0', + version: '0.1.1', license: 'LGPL-3.0-or-later', meson_version: '>=0.53', default_options: [ diff --git a/src/rmsd/filter.f90 b/src/rmsd/filter.f90 index 665cd50..e63291d 100644 --- a/src/rmsd/filter.f90 +++ b/src/rmsd/filter.f90 @@ -42,6 +42,9 @@ module rmsd_filter !> Whether the filter contains an allow or a deny list logical :: allow + !> Use PDB identifiers for filtering + logical :: pdb + contains !> Create mask from filter and structure @@ -112,10 +115,11 @@ subroutine new_rmsd_filter_tbl(self, table, error) character(symbol_length), allocatable :: sym(:) character(len=:), allocatable :: name, cval integer :: ndim, inum, isym, ival, i, stat - logical :: allow + logical :: allow, pdb call table%get_key(name) + call get_value(table, "pdb", pdb, .false.) call get_value(table, "include", array, requested=.false.) allow = associated(array) if (.not.allow) then @@ -159,13 +163,13 @@ subroutine new_rmsd_filter_tbl(self, table, error) if (allocated(error)) return call new_rmsd_filter(self, name=name, num=num(:inum), sym=sym(:isym), & - & allow=allow) + & allow=allow, pdb=pdb) end subroutine new_rmsd_filter_tbl !> Create a new RMSD filter from parts -subroutine new_rmsd_filter_one(self, name, num, sym, allow) +subroutine new_rmsd_filter_one(self, name, num, sym, allow, pdb) !> Instance of species filter type(rmsd_filter_type), intent(out) :: self @@ -176,6 +180,9 @@ subroutine new_rmsd_filter_one(self, name, num, sym, allow) !> Whether the filter contains an allow or a deny list logical, intent(in) :: allow + !> Filter is specific for PDB identifiers + logical, intent(in) :: pdb + !> Atomic number integer, intent(in) :: num(:) @@ -186,6 +193,7 @@ subroutine new_rmsd_filter_one(self, name, num, sym, allow) self%sym = sym self%num = num self%allow = allow + self%pdb = pdb end subroutine new_rmsd_filter_one @@ -224,6 +232,18 @@ subroutine get_mask(self, mol, mask) izp = mol%id(iat) mask(iat) = tmp(izp) end do + + if (self%pdb .and. allocated(mol%pdb)) then + if (self%allow) then + do iat = 1, mol%nat + mask(iat) = mask(iat) .or. any(mol%pdb(iat)%name == self%sym) + end do + else + do iat = 1, mol%nat + mask(iat) = mask(iat) .and. all(mol%pdb(iat)%name /= self%sym) + end do + end if + end if end subroutine get_mask diff --git a/src/rmsd/version.f90 b/src/rmsd/version.f90 index b37c68e..cf11c91 100644 --- a/src/rmsd/version.f90 +++ b/src/rmsd/version.f90 @@ -23,10 +23,10 @@ module rmsd_version !> String representation of the mctc-rmsd version - character(len=*), parameter :: rmsd_version_string = "0.1.0" + character(len=*), parameter :: rmsd_version_string = "0.1.1" !> Numeric representation of the mctc-rmsd version - integer, parameter :: rmsd_version_compact(3) = [0, 1, 0] + integer, parameter :: rmsd_version_compact(3) = [0, 1, 1] contains