Previous changeset 1:acc9922f3eab (2018-10-04) Next changeset 3:4c48f2526697 (2019-08-30) |
Commit message:
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tools/gromacs commit 7ba07c3130a2170e8f91acc4a81f5626563a79eb |
added:
merge_top.py test-data/top_output.top |
b |
diff -r acc9922f3eab -r c124921a9e5f merge_top.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/merge_top.py Thu Mar 28 10:14:26 2019 -0400 |
[ |
@@ -0,0 +1,38 @@ +import re +import sys + + +def combine_tops(top_text, itp_texts): + """ + Search through parent topology top_text and replace + #include lines with the relevant child topologies + from the dictionary itp_texts + """ + for itp in itp_texts: + # split on include string, then rejoin around itp file + spl = re.split('#include ".*{}"\n'.format(itp), top_text) + top_text = itp_texts[itp].join(spl) + return top_text + + +top = sys.argv[1] # parent topology file +itps_file = sys.argv[2] # file with list of child topologies (.itp files) + +with open(itps_file) as f: + itps = f.read().split() + +with open(top, 'r') as f: + top_text = f.read() + +itp_texts = {} # create dictionary of child topologies +for itp in itps: + with open(itp, 'r') as f: + itp_texts[itp] = f.read() + +for itp in itp_texts: + # child tops may also refer to each other; we need to check this + itp_texts[itp] = combine_tops(itp_texts[itp], itp_texts) + +with open('top_output.top', 'w') as f: + # now combine all children into the parent + f.write(combine_tops(top_text, itp_texts)) |
b |
diff -r acc9922f3eab -r c124921a9e5f test-data/top_output.top --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/top_output.top Thu Mar 28 10:14:26 2019 -0400 |
[ |
b'@@ -0,0 +1,19416 @@\n+;\n+;\tFile \'topol.top\' was generated\n+;\tBy user: unknown (1000)\n+;\tOn host: simon-laptop\n+;\tAt date: Thu Aug 16 20:54:28 2018\n+;\n+;\tThis is a standalone topology file\n+;\n+;\tCreated by:\n+;\t :-) GROMACS - gmx pdb2gmx, 2018.2 (-:\n+;\t\n+;\tExecutable: /home/simon/miniconda3/envs/gromacs2/bin/gmx\n+;\tData prefix: /home/simon/miniconda3/envs/gromacs2\n+;\tWorking dir: /home/simon/moldyn-galaxy/protein/test-data\n+;\tCommand line:\n+;\t gmx pdb2gmx -f 1AKI.pdb -o processed.gro -p topol.top -i posres.itp -water spce -ff oplsaa -noignh\n+;\tForce field was read from the standard GROMACS share directory.\n+;\n+\n+; Include forcefield parameters\n+#include "oplsaa.ff/forcefield.itp"\n+\n+[ moleculetype ]\n+; Name nrexcl\n+Protein_chain_A 3\n+\n+[ atoms ]\n+; nr type resnr residue atom cgnr charge mass typeB chargeB massB\n+; residue 1 LYS rtp LYSH q +2.0\n+ 1 opls_287 1 LYS N 1 -0.3 14.0027 ; qtot -0.3\n+ 2 opls_290 1 LYS H1 1 0.33 1.008 ; qtot 0.03\n+ 3 opls_290 1 LYS H2 1 0.33 1.008 ; qtot 0.36\n+ 4 opls_290 1 LYS H3 1 0.33 1.008 ; qtot 0.69\n+ 5 opls_293B 1 LYS CA 1 0.25 12.011 ; qtot 0.94\n+ 6 opls_140 1 LYS HA 1 0.06 1.008 ; qtot 1\n+ 7 opls_136 1 LYS CB 2 -0.12 12.011 ; qtot 0.88\n+ 8 opls_140 1 LYS HB1 2 0.06 1.008 ; qtot 0.94\n+ 9 opls_140 1 LYS HB2 2 0.06 1.008 ; qtot 1\n+ 10 opls_136 1 LYS CG 3 -0.12 12.011 ; qtot 0.88\n+ 11 opls_140 1 LYS HG1 3 0.06 1.008 ; qtot 0.94\n+ 12 opls_140 1 LYS HG2 3 0.06 1.008 ; qtot 1\n+ 13 opls_136 1 LYS CD 4 -0.12 12.011 ; qtot 0.88\n+ 14 opls_140 1 LYS HD1 4 0.06 1.008 ; qtot 0.94\n+ 15 opls_140 1 LYS HD2 4 0.06 1.008 ; qtot 1\n+ 16 opls_292 1 LYS CE 5 0.19 12.011 ; qtot 1.19\n+ 17 opls_140 1 LYS HE1 5 0.06 1.008 ; qtot 1.25\n+ 18 opls_140 1 LYS HE2 5 0.06 1.008 ; qtot 1.31\n+ 19 opls_287 1 LYS NZ 6 -0.3 14.0067 ; qtot 1.01\n+ 20 opls_290 1 LYS HZ1 6 0.33 1.008 ; qtot 1.34\n+ 21 opls_290 1 LYS HZ2 6 0.33 1.008 ; qtot 1.67\n+ 22 opls_290 1 LYS HZ3 6 0.33 1.008 ; qtot 2\n+ 23 opls_235 1 LYS C 7 0.5 12.011 ; qtot 2.5\n+ 24 opls_236 1 LYS O 7 -0.5 15.9994 ; qtot 2\n+; residue 2 VAL rtp VAL q 0.0\n+ 25 opls_238 2 VAL N 8 -0.5 14.0067 ; qtot 1.5\n+ 26 opls_241 2 VAL H 8 0.3 1.008 ; qtot 1.8\n+ 27 opls_224B 2 VAL CA 8 0.14 12.011 ; qtot 1.94\n+ 28 opls_140 2 VAL HA 8 0.06 1.008 ; qtot 2\n+ 29 opls_137 2 VAL CB 9 -0.06 12.011 ; qtot 1.94\n+ 30 opls_140 2 VAL HB 9 0.06 1.008 ; qtot 2\n+ 31 opls_135 2 VAL CG1 10 -0.18 12.011 ; qtot 1.82\n+ 32 opls_140 2 VAL HG11 10 0.06 1.008 ; qtot 1.88\n+ 33 opls_140 2 VAL HG12 10 0.06 1.008 ; qtot 1.94\n+ 34 opls_140 2 VAL HG13 10 0.06 1.008 ; qtot 2\n+ 35 opls_135 2 VAL CG2 11 -0.18 12.011 ; qtot 1.82\n+ 36 opls_140 2 VAL HG21 11 0.06 1.008 ; qtot 1.88\n+ 37 opls_140 2 VAL HG22 11 0.06 1.008 ; qtot 1.9'..b'000 1000\n+ 1737 1 1000 1000 1000\n+ 1739 1 1000 1000 1000\n+ 1742 1 1000 1000 1000\n+ 1745 1 1000 1000 1000\n+ 1748 1 1000 1000 1000\n+ 1751 1 1000 1000 1000\n+ 1755 1 1000 1000 1000\n+ 1756 1 1000 1000 1000\n+ 1757 1 1000 1000 1000\n+ 1759 1 1000 1000 1000\n+ 1762 1 1000 1000 1000\n+ 1763 1 1000 1000 1000\n+ 1764 1 1000 1000 1000\n+ 1766 1 1000 1000 1000\n+ 1768 1 1000 1000 1000\n+ 1770 1 1000 1000 1000\n+ 1772 1 1000 1000 1000\n+ 1776 1 1000 1000 1000\n+ 1777 1 1000 1000 1000\n+ 1778 1 1000 1000 1000\n+ 1780 1 1000 1000 1000\n+ 1782 1 1000 1000 1000\n+ 1785 1 1000 1000 1000\n+ 1786 1 1000 1000 1000\n+ 1787 1 1000 1000 1000\n+ 1788 1 1000 1000 1000\n+ 1789 1 1000 1000 1000\n+ 1790 1 1000 1000 1000\n+ 1792 1 1000 1000 1000\n+ 1794 1 1000 1000 1000\n+ 1796 1 1000 1000 1000\n+ 1800 1 1000 1000 1000\n+ 1804 1 1000 1000 1000\n+ 1805 1 1000 1000 1000\n+ 1806 1 1000 1000 1000\n+ 1808 1 1000 1000 1000\n+ 1810 1 1000 1000 1000\n+ 1813 1 1000 1000 1000\n+ 1816 1 1000 1000 1000\n+ 1817 1 1000 1000 1000\n+ 1818 1 1000 1000 1000\n+ 1821 1 1000 1000 1000\n+ 1822 1 1000 1000 1000\n+ 1823 1 1000 1000 1000\n+ 1825 1 1000 1000 1000\n+ 1827 1 1000 1000 1000\n+ 1831 1 1000 1000 1000\n+ 1832 1 1000 1000 1000\n+ 1833 1 1000 1000 1000\n+ 1835 1 1000 1000 1000\n+ 1837 1 1000 1000 1000\n+ 1840 1 1000 1000 1000\n+ 1841 1 1000 1000 1000\n+ 1843 1 1000 1000 1000\n+ 1844 1 1000 1000 1000\n+ 1846 1 1000 1000 1000\n+ 1847 1 1000 1000 1000\n+ 1849 1 1000 1000 1000\n+ 1851 1 1000 1000 1000\n+ 1853 1 1000 1000 1000\n+ 1855 1 1000 1000 1000\n+ 1856 1 1000 1000 1000\n+ 1857 1 1000 1000 1000\n+ 1859 1 1000 1000 1000\n+ 1861 1 1000 1000 1000\n+ 1863 1 1000 1000 1000\n+ 1866 1 1000 1000 1000\n+ 1870 1 1000 1000 1000\n+ 1874 1 1000 1000 1000\n+ 1875 1 1000 1000 1000\n+ 1876 1 1000 1000 1000\n+ 1878 1 1000 1000 1000\n+ 1880 1 1000 1000 1000\n+ 1883 1 1000 1000 1000\n+ 1886 1 1000 1000 1000\n+ 1889 1 1000 1000 1000\n+ 1891 1 1000 1000 1000\n+ 1892 1 1000 1000 1000\n+ 1895 1 1000 1000 1000\n+ 1898 1 1000 1000 1000\n+ 1899 1 1000 1000 1000\n+ 1900 1 1000 1000 1000\n+ 1902 1 1000 1000 1000\n+ 1905 1 1000 1000 1000\n+ 1906 1 1000 1000 1000\n+ 1907 1 1000 1000 1000\n+ 1909 1 1000 1000 1000\n+ 1911 1 1000 1000 1000\n+ 1914 1 1000 1000 1000\n+ 1915 1 1000 1000 1000\n+ 1916 1 1000 1000 1000\n+ 1917 1 1000 1000 1000\n+ 1919 1 1000 1000 1000\n+ 1921 1 1000 1000 1000\n+ 1924 1 1000 1000 1000\n+ 1927 1 1000 1000 1000\n+ 1930 1 1000 1000 1000\n+ 1932 1 1000 1000 1000\n+ 1933 1 1000 1000 1000\n+ 1936 1 1000 1000 1000\n+ 1939 1 1000 1000 1000\n+ 1940 1 1000 1000 1000\n+ 1941 1 1000 1000 1000\n+ 1943 1 1000 1000 1000\n+ 1945 1 1000 1000 1000\n+ 1948 1 1000 1000 1000\n+ 1950 1 1000 1000 1000\n+ 1954 1 1000 1000 1000\n+ 1958 1 1000 1000 1000\n+ 1959 1 1000 1000 1000\n+ 1960 1 1000 1000 1000\n+#endif\n+\n+; Include water topology\n+#include "oplsaa.ff/spce.itp"\n+\n+#ifdef POSRES_WATER\n+; Position restraint for each water oxygen\n+[ position_restraints ]\n+; i funct fcx fcy fcz\n+ 1 1 1000 1000 1000\n+#endif\n+\n+; Include topology for ions\n+#include "oplsaa.ff/ions.itp"\n+\n+[ system ]\n+; Name\n+LYSOZYME\n+\n+[ molecules ]\n+; Compound #mols\n+Protein_chain_A 1\n+SOL 78\n' |