pyphyschemtools 0.1.5__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyphyschemtools/.ipynb_checkpoints/Chem3D-checkpoint.py +61 -17
- pyphyschemtools/.visualID_Eng.py.swp +0 -0
- pyphyschemtools/Chem3D.py +61 -17
- pyphyschemtools/__init__.py +2 -2
- pyphyschemtools/resources/svg/pyPC_LPCNO_Banner.png +0 -0
- pyphyschemtools/resources/svg/{pyPCBanner.svg → pyPC_LPCNO_Banner.svg} +4 -4
- pyphyschemtools/resources/svg/tools4pyPC_banner.png +0 -0
- pyphyschemtools/resources/svg/tools4pyPC_banner.svg +193 -0
- pyphyschemtools/visualID_Eng.py +7 -2
- {pyphyschemtools-0.1.5.dist-info → pyphyschemtools-0.3.2.dist-info}/METADATA +9 -7
- {pyphyschemtools-0.1.5.dist-info → pyphyschemtools-0.3.2.dist-info}/RECORD +14 -10
- {pyphyschemtools-0.1.5.dist-info → pyphyschemtools-0.3.2.dist-info}/WHEEL +0 -0
- {pyphyschemtools-0.1.5.dist-info → pyphyschemtools-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {pyphyschemtools-0.1.5.dist-info → pyphyschemtools-0.3.2.dist-info}/top_level.txt +0 -0
|
@@ -283,10 +283,15 @@ class molView:
|
|
|
283
283
|
and bond orders (detects double/triple bonds).
|
|
284
284
|
Requires the `rdkit` library. If False, fallback to standard 3Dmol
|
|
285
285
|
distance-based single bonds.
|
|
286
|
+
display_now : bool, optional
|
|
287
|
+
If True (default), renders the molecule immediately.
|
|
288
|
+
Set to False to prevent immediate display when you plan to call
|
|
289
|
+
further visualization methods provided by the molView class
|
|
286
290
|
viewer : bool, optional
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
If True (default), initializes the py3Dmol engine and prepares the 3D model.
|
|
292
|
+
If False, operates in 'headless' mode: only geometric data is processed
|
|
293
|
+
for analysis (volume, CM, etc.), saving significant memory for
|
|
294
|
+
high-throughput processing.
|
|
290
295
|
zoom : None, optional
|
|
291
296
|
scaling factor
|
|
292
297
|
|
|
@@ -311,10 +316,12 @@ class molView:
|
|
|
311
316
|
>>> vol = mv.data.get_cage_volume()
|
|
312
317
|
"""
|
|
313
318
|
|
|
314
|
-
def __init__(self, mol, source=
|
|
319
|
+
def __init__(self, mol, source=None, style='bs', displayHbonds=True, cpk_scale=0.6, w=600, h=400,\
|
|
315
320
|
supercell=(1, 1, 1), display_now=True, detect_BondOrders=True, viewer=True, zoom=None):
|
|
321
|
+
# For the automatic detection or source validation
|
|
322
|
+
valid_sources = ['file', 'mol', 'cif', 'cid', 'rscb', 'cod', 'ase']
|
|
323
|
+
|
|
316
324
|
self.mol = mol
|
|
317
|
-
self.source = source
|
|
318
325
|
self.style = style
|
|
319
326
|
self.cpk_scale = cpk_scale
|
|
320
327
|
self.displayHbonds = displayHbonds
|
|
@@ -324,6 +331,19 @@ class molView:
|
|
|
324
331
|
self.supercell = supercell
|
|
325
332
|
self.viewer = viewer
|
|
326
333
|
self.zoom = zoom
|
|
334
|
+
if source is None and os.path.exists(str(mol)):
|
|
335
|
+
self.source = 'file'
|
|
336
|
+
elif source in valid_sources:
|
|
337
|
+
self.source = source
|
|
338
|
+
else:
|
|
339
|
+
# Clear error message and early exit if the source is unrecognized
|
|
340
|
+
error_msg = f"❌ Invalid source: '{source}'. \nAllowed sources are: {', '.join(valid_sources)}"
|
|
341
|
+
print(error_msg)
|
|
342
|
+
self.data = None
|
|
343
|
+
self.v = None
|
|
344
|
+
return
|
|
345
|
+
# Viewer initialization and data loading
|
|
346
|
+
# We only proceed if the source is valid
|
|
327
347
|
self.v = py3Dmol.view(width=self.w, height=self.h) # Création du viewer une seule fois
|
|
328
348
|
self._load_and_display(show=display_now)
|
|
329
349
|
|
|
@@ -615,7 +635,9 @@ class molView:
|
|
|
615
635
|
response = requests.get(url)
|
|
616
636
|
if response.status_code == 200:
|
|
617
637
|
content = response.text
|
|
618
|
-
fmt = "
|
|
638
|
+
fmt = "proteindatabank"
|
|
639
|
+
else:
|
|
640
|
+
raise ValueError(f"Could not find PDB ID: {self.mol} on RSCB")
|
|
619
641
|
|
|
620
642
|
elif self.source == 'cod':
|
|
621
643
|
url = f"https://www.crystallography.net/cod/{self.mol}.cif"
|
|
@@ -634,8 +656,21 @@ class molView:
|
|
|
634
656
|
if self.source == 'file':
|
|
635
657
|
if not os.path.exists(self.mol):
|
|
636
658
|
raise FileNotFoundError(f"File not found: {self.mol}")
|
|
659
|
+
|
|
660
|
+
# Extraction de l'extension sans le point
|
|
637
661
|
ext = os.path.splitext(self.mol)[1].lower().replace('.', '')
|
|
638
|
-
|
|
662
|
+
|
|
663
|
+
# Mapping explicite pour ASE
|
|
664
|
+
if ext == 'pdb':
|
|
665
|
+
fmt = 'proteindatabank'
|
|
666
|
+
elif ext == 'xyz':
|
|
667
|
+
fmt = 'xyz'
|
|
668
|
+
elif ext == 'cif':
|
|
669
|
+
fmt = 'cif'
|
|
670
|
+
else:
|
|
671
|
+
# Fallback sur l'extension si format exotique
|
|
672
|
+
fmt = ext
|
|
673
|
+
|
|
639
674
|
with open(self.mol, 'r') as f:
|
|
640
675
|
content = f.read()
|
|
641
676
|
|
|
@@ -649,19 +684,28 @@ class molView:
|
|
|
649
684
|
|
|
650
685
|
# --- EXTRACTION XYZData (Interne) ---
|
|
651
686
|
# On extrait les données ici avant toute modification (RDKit ou Supercell)
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
687
|
+
if self.source == 'ase':
|
|
688
|
+
atoms = self.mol
|
|
689
|
+
else:
|
|
690
|
+
try:
|
|
691
|
+
# On utilise l'alias long d'ASE pour PDB, sinon le format détecté
|
|
692
|
+
atoms = read(io.StringIO(content), format=fmt)
|
|
693
|
+
except (Exception, StopIteration):
|
|
694
|
+
# Si l'extraction échoue, on tente une dernière fois sans format forcé
|
|
695
|
+
try:
|
|
696
|
+
atoms = read(io.StringIO(content))
|
|
697
|
+
except:
|
|
698
|
+
print(f"❌ Extraction of coordinates is impossible for source {self.source}")
|
|
699
|
+
self.data = None
|
|
700
|
+
# --- CRUCIAL : On arrête tout ici si on n'a pas d'atomes ---
|
|
701
|
+
if self.viewer:
|
|
702
|
+
self.v.show() # On montre au moins le viewer vide ou l'erreur
|
|
703
|
+
return
|
|
657
704
|
|
|
658
705
|
self.data = XYZData(
|
|
659
|
-
symbols=
|
|
660
|
-
positions=
|
|
706
|
+
symbols=atoms.get_chemical_symbols(),
|
|
707
|
+
positions=atoms.get_positions()
|
|
661
708
|
)
|
|
662
|
-
except Exception as e:
|
|
663
|
-
print(f"Note: Extraction des coordonnées impossible ({e})")
|
|
664
|
-
self.data = None
|
|
665
709
|
|
|
666
710
|
# --- Modern Bond Perception with RDKit ---
|
|
667
711
|
if self.detect_bonds and self.source in ['file', 'mol', 'xyz'] and fmt == 'xyz':
|
|
Binary file
|
pyphyschemtools/Chem3D.py
CHANGED
|
@@ -283,10 +283,15 @@ class molView:
|
|
|
283
283
|
and bond orders (detects double/triple bonds).
|
|
284
284
|
Requires the `rdkit` library. If False, fallback to standard 3Dmol
|
|
285
285
|
distance-based single bonds.
|
|
286
|
+
display_now : bool, optional
|
|
287
|
+
If True (default), renders the molecule immediately.
|
|
288
|
+
Set to False to prevent immediate display when you plan to call
|
|
289
|
+
further visualization methods provided by the molView class
|
|
286
290
|
viewer : bool, optional
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
If True (default), initializes the py3Dmol engine and prepares the 3D model.
|
|
292
|
+
If False, operates in 'headless' mode: only geometric data is processed
|
|
293
|
+
for analysis (volume, CM, etc.), saving significant memory for
|
|
294
|
+
high-throughput processing.
|
|
290
295
|
zoom : None, optional
|
|
291
296
|
scaling factor
|
|
292
297
|
|
|
@@ -311,10 +316,12 @@ class molView:
|
|
|
311
316
|
>>> vol = mv.data.get_cage_volume()
|
|
312
317
|
"""
|
|
313
318
|
|
|
314
|
-
def __init__(self, mol, source=
|
|
319
|
+
def __init__(self, mol, source=None, style='bs', displayHbonds=True, cpk_scale=0.6, w=600, h=400,\
|
|
315
320
|
supercell=(1, 1, 1), display_now=True, detect_BondOrders=True, viewer=True, zoom=None):
|
|
321
|
+
# For the automatic detection or source validation
|
|
322
|
+
valid_sources = ['file', 'mol', 'cif', 'cid', 'rscb', 'cod', 'ase']
|
|
323
|
+
|
|
316
324
|
self.mol = mol
|
|
317
|
-
self.source = source
|
|
318
325
|
self.style = style
|
|
319
326
|
self.cpk_scale = cpk_scale
|
|
320
327
|
self.displayHbonds = displayHbonds
|
|
@@ -324,6 +331,19 @@ class molView:
|
|
|
324
331
|
self.supercell = supercell
|
|
325
332
|
self.viewer = viewer
|
|
326
333
|
self.zoom = zoom
|
|
334
|
+
if source is None and os.path.exists(str(mol)):
|
|
335
|
+
self.source = 'file'
|
|
336
|
+
elif source in valid_sources:
|
|
337
|
+
self.source = source
|
|
338
|
+
else:
|
|
339
|
+
# Clear error message and early exit if the source is unrecognized
|
|
340
|
+
error_msg = f"❌ Invalid source: '{source}'. \nAllowed sources are: {', '.join(valid_sources)}"
|
|
341
|
+
print(error_msg)
|
|
342
|
+
self.data = None
|
|
343
|
+
self.v = None
|
|
344
|
+
return
|
|
345
|
+
# Viewer initialization and data loading
|
|
346
|
+
# We only proceed if the source is valid
|
|
327
347
|
self.v = py3Dmol.view(width=self.w, height=self.h) # Création du viewer une seule fois
|
|
328
348
|
self._load_and_display(show=display_now)
|
|
329
349
|
|
|
@@ -615,7 +635,9 @@ class molView:
|
|
|
615
635
|
response = requests.get(url)
|
|
616
636
|
if response.status_code == 200:
|
|
617
637
|
content = response.text
|
|
618
|
-
fmt = "
|
|
638
|
+
fmt = "proteindatabank"
|
|
639
|
+
else:
|
|
640
|
+
raise ValueError(f"Could not find PDB ID: {self.mol} on RSCB")
|
|
619
641
|
|
|
620
642
|
elif self.source == 'cod':
|
|
621
643
|
url = f"https://www.crystallography.net/cod/{self.mol}.cif"
|
|
@@ -634,8 +656,21 @@ class molView:
|
|
|
634
656
|
if self.source == 'file':
|
|
635
657
|
if not os.path.exists(self.mol):
|
|
636
658
|
raise FileNotFoundError(f"File not found: {self.mol}")
|
|
659
|
+
|
|
660
|
+
# Extraction de l'extension sans le point
|
|
637
661
|
ext = os.path.splitext(self.mol)[1].lower().replace('.', '')
|
|
638
|
-
|
|
662
|
+
|
|
663
|
+
# Mapping explicite pour ASE
|
|
664
|
+
if ext == 'pdb':
|
|
665
|
+
fmt = 'proteindatabank'
|
|
666
|
+
elif ext == 'xyz':
|
|
667
|
+
fmt = 'xyz'
|
|
668
|
+
elif ext == 'cif':
|
|
669
|
+
fmt = 'cif'
|
|
670
|
+
else:
|
|
671
|
+
# Fallback sur l'extension si format exotique
|
|
672
|
+
fmt = ext
|
|
673
|
+
|
|
639
674
|
with open(self.mol, 'r') as f:
|
|
640
675
|
content = f.read()
|
|
641
676
|
|
|
@@ -649,19 +684,28 @@ class molView:
|
|
|
649
684
|
|
|
650
685
|
# --- EXTRACTION XYZData (Interne) ---
|
|
651
686
|
# On extrait les données ici avant toute modification (RDKit ou Supercell)
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
687
|
+
if self.source == 'ase':
|
|
688
|
+
atoms = self.mol
|
|
689
|
+
else:
|
|
690
|
+
try:
|
|
691
|
+
# On utilise l'alias long d'ASE pour PDB, sinon le format détecté
|
|
692
|
+
atoms = read(io.StringIO(content), format=fmt)
|
|
693
|
+
except (Exception, StopIteration):
|
|
694
|
+
# Si l'extraction échoue, on tente une dernière fois sans format forcé
|
|
695
|
+
try:
|
|
696
|
+
atoms = read(io.StringIO(content))
|
|
697
|
+
except:
|
|
698
|
+
print(f"❌ Extraction of coordinates is impossible for source {self.source}")
|
|
699
|
+
self.data = None
|
|
700
|
+
# --- CRUCIAL : On arrête tout ici si on n'a pas d'atomes ---
|
|
701
|
+
if self.viewer:
|
|
702
|
+
self.v.show() # On montre au moins le viewer vide ou l'erreur
|
|
703
|
+
return
|
|
657
704
|
|
|
658
705
|
self.data = XYZData(
|
|
659
|
-
symbols=
|
|
660
|
-
positions=
|
|
706
|
+
symbols=atoms.get_chemical_symbols(),
|
|
707
|
+
positions=atoms.get_positions()
|
|
661
708
|
)
|
|
662
|
-
except Exception as e:
|
|
663
|
-
print(f"Note: Extraction des coordonnées impossible ({e})")
|
|
664
|
-
self.data = None
|
|
665
709
|
|
|
666
710
|
# --- Modern Bond Perception with RDKit ---
|
|
667
711
|
if self.detect_bonds and self.source in ['file', 'mol', 'xyz'] and fmt == 'xyz':
|
pyphyschemtools/__init__.py
CHANGED
|
Binary file
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
viewBox="0 0 178.01071 29.131533"
|
|
8
8
|
version="1.1"
|
|
9
9
|
id="svg5"
|
|
10
|
-
inkscape:version="1.4.
|
|
11
|
-
sodipodi:docname="
|
|
12
|
-
inkscape:export-filename="
|
|
10
|
+
inkscape:version="1.4.3 (unknown)"
|
|
11
|
+
sodipodi:docname="pyPC_LPCNO_Banner.svg"
|
|
12
|
+
inkscape:export-filename="pyPC_LPCNO_Banner.png"
|
|
13
13
|
inkscape:export-xdpi="300.008"
|
|
14
14
|
inkscape:export-ydpi="300.008"
|
|
15
15
|
xml:space="preserve"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
inkscape:document-units="mm"
|
|
31
31
|
showgrid="false"
|
|
32
32
|
inkscape:zoom="2.1549693"
|
|
33
|
-
inkscape:cx="154.
|
|
33
|
+
inkscape:cx="154.75859"
|
|
34
34
|
inkscape:cy="88.168309"
|
|
35
35
|
inkscape:window-width="2544"
|
|
36
36
|
inkscape:window-height="1344"
|
|
Binary file
|