Skip to content

Commit a2a1401

Browse files
authored
Merge pull request #78 from rasbt/v0.2.8
Version 0.2.8
2 parents 4cc6817 + 63cf800 commit a2a1401

17 files changed

+899
-70
lines changed

biopandas/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
2525
#
2626

27-
__version__ = '0.3.0'
27+
__version__ = '0.2.8'
2828
__author__ = "Sebastian Raschka <[email protected]>"

docs/CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ The CHANGELOG for the current development version is available at
44
[https://github.com/rasbt/biopandas/blob/master/docs/sources/CHANGELOG.md](https://github.com/rasbt/biopandas/blob/master/docs/sources/CHANGELOG.md).
55

66

7-
### 0.3.0 (TBA)
7+
### 0.2.8 (03-30-2021)
88

99
##### Downloads
1010

11-
- [Source code (zip)](https://github.com/rasbt/biopandas/archive/v0.3.0.zip)
12-
- [Source code (tar.gz)](https://github.com/rasbt/biopandas/archive/v0.3.0.tar.gz)
11+
- [Source code (zip)](https://github.com/rasbt/biopandas/archive/v0.2.8.zip)
12+
- [Source code (tar.gz)](https://github.com/rasbt/biopandas/archive/v0.2.8.tar.gz)
1313

1414
##### New Features
1515

docs/ipynb2markdown.py

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# IPython Notebook to Markdown conversion script
2+
#
3+
# Sebastian Raschka 2014-2021
4+
#
5+
# Author: Sebastian Raschka <sebastianraschka.com>
6+
#
7+
# License: BSD 3 clause
8+
9+
import subprocess
10+
import glob
11+
import shutil
12+
import os
13+
import markdown
14+
from markdown.treeprocessors import Treeprocessor
15+
from markdown.extensions import Extension
16+
from nbconvert.exporters import MarkdownExporter
17+
18+
19+
class ImgExtractor(Treeprocessor):
20+
def run(self, doc):
21+
self.markdown.images = []
22+
for image in doc.findall('.//img'):
23+
self.markdown.images.append(image.get('src'))
24+
25+
26+
class ImgExtExtension(Extension):
27+
def extendMarkdown(self, md, md_globals):
28+
img_ext = ImgExtractor(md)
29+
md.treeprocessors.add('imgext', img_ext, '>inline')
30+
31+
32+
def ipynb_to_md(ipynb_path):
33+
orig_path = os.getcwd()
34+
os.chdir(os.path.dirname(ipynb_path))
35+
file_name = os.path.basename(ipynb_path)
36+
subprocess.call(['python', '-m', 'nbconvert',
37+
'--to', 'markdown', file_name])
38+
39+
new_s = []
40+
md_name = file_name.replace('.ipynb', '.md')
41+
with open(md_name, 'r') as f:
42+
for line in f:
43+
if line.startswith('#'):
44+
new_s.append(line)
45+
break
46+
for line in f:
47+
if line.startswith(('## API', '# API')):
48+
new_s.append(line)
49+
new_s.append('\n')
50+
break
51+
new_s.append(line)
52+
for line in f:
53+
if line.lstrip().startswith('#'):
54+
break
55+
for line in f:
56+
new_s.append(line[4:])
57+
58+
with open(md_name, 'w') as f:
59+
f.write(''.join(new_s))
60+
os.chdir(orig_path)
61+
62+
63+
# md = markdown.Markdown(extensions=[ImgExtExtension()])
64+
# html = md.convert(data)
65+
# print(md.images)
66+
67+
68+
if __name__ == "__main__":
69+
70+
import argparse
71+
parser = argparse.ArgumentParser(
72+
description='Convert docstring into a markdown API documentation.',
73+
formatter_class=argparse.RawTextHelpFormatter)
74+
75+
parser.add_argument('-i', '--ipynb',
76+
help='Path to the IPython file')
77+
78+
parser.add_argument('-a', '--all',
79+
help='Path to parse all ipynb recursively')
80+
81+
parser.add_argument('-v', '--version',
82+
action='version',
83+
version='v. 0.1')
84+
85+
args = parser.parse_args()
86+
87+
if args.all and args.ipynb:
88+
raise AttributeError('Conflicting flags --ipynb and --all; choose one')
89+
90+
if args.ipynb:
91+
ipynb_to_md(ipynb_path=args.ipynb)
92+
else:
93+
tree = os.walk(args.all)
94+
for d in tree:
95+
filenames = glob.glob(os.path.join(d[0], '*'))
96+
for f in filenames:
97+
if f.endswith('.ipynb'):
98+
print(f)
99+
100+
ipynb_to_md(ipynb_path=f)

docs/sources/api_subpackages/biopandas.mol2.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
biopandas version: 0.3.0
1+
biopandas version: 0.2.8
2+
23
## PandasMol2
34

45
*PandasMol2()*

docs/sources/api_subpackages/biopandas.pdb.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
biopandas version: 0.3.0
1+
biopandas version: 0.2.8
2+
23
## PandasPdb
34

45
*PandasPdb()*

docs/sources/api_subpackages/biopandas.testutils.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
biopandas version: 0.3.0
1+
biopandas version: 0.2.8
2+
23
## assert_raises
34

45
*assert_raises(exception_type, message, func, *args, **kwargs)*

docs/tutorials/Working_with_MOL2_Structures_in_DataFrames.ipynb

+22-28
Large diffs are not rendered by default.

docs/tutorials/Working_with_MOL2_Structures_in_DataFrames.md

+7-16
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ print('\nRaw MOL2 file contents:\n\n%s\n...' % pmol.mol2_text[:500])
5252
...
5353

5454

55-
The most interesting and useful attribute, however, is the [`PandasMol2.df`](../api_subpackages/biopandas.mol2#pandasmol2df) DataFrame, which contains the ATOM section of the MOL2 structure. Let's print the first 3 lines from the `ATOM` coordinate section to see how it looks like:
55+
The most interesting and useful attribute, however, is the [`PandasMol2.df`](../api/biopandas.mol2#pandasmol2df) DataFrame, which contains the ATOM section of the MOL2 structure. Let's print the first 3 lines from the `ATOM` coordinate section to see how it looks like:
5656

5757

5858
```python
@@ -689,7 +689,9 @@ plt.show()
689689
```
690690

691691

692+
692693
![png](Working_with_MOL2_Structures_in_DataFrames_files/Working_with_MOL2_Structures_in_DataFrames_34_0.png)
694+
693695

694696

695697
If this is too fine-grained for our needs, we could summarize the different atom types by atomic elements:
@@ -705,7 +707,9 @@ plt.show()
705707
```
706708

707709

710+
708711
![png](Working_with_MOL2_Structures_in_DataFrames_files/Working_with_MOL2_Structures_in_DataFrames_36_0.png)
712+
709713

710714

711715
One of the coolest features in pandas is the groupby method. Below is an example plotting the average charge of the different atom types with the standard deviation as error bars:
@@ -719,7 +723,9 @@ plt.show()
719723
```
720724

721725

726+
722727
![png](Working_with_MOL2_Structures_in_DataFrames_files/Working_with_MOL2_Structures_in_DataFrames_38_0.png)
728+
723729

724730

725731
## Computing the Root Mean Square Deviation
@@ -1180,21 +1186,6 @@ from biopandas.mol2 import split_multimol2
11801186
```
11811187

11821188

1183-
---------------------------------------------------------------------------
1184-
1185-
ModuleNotFoundError Traceback (most recent call last)
1186-
1187-
<ipython-input-23-1a655249f2ec> in <module>()
1188-
1 import pandas as pd
1189-
----> 2 from mputil import lazy_imap
1190-
3 from biopandas.mol2 import PandasMol2
1191-
4 from biopandas.mol2 import split_multimol2
1192-
1193-
1194-
ModuleNotFoundError: No module named 'mputil'
1195-
1196-
1197-
11981189
```python
11991190
# Selection strings to capture
12001191
# all molecules that contain at least one sp2 hybridized

0 commit comments

Comments
 (0)