Trouble with Rdkit when converting to molecular fingerprints - rdkit

When attemping to get the rdkit to work i keep getting an argument error i am unsure of how to solve.
mol_list1 = [Chem.MolFromSmiles(i) for i in tqdm(df_database['Ligand SMILES'], desc='Creating mol objects from database Smiles')]
mol_list2 = [Chem.MolFromSmiles(i) for i in tqdm(df_metabolites['Smiles'].dropna(), desc='And now for the metabolites!')]
mfp1 = [AllChem.GetMorganFingerprint(j, 4) for j in tqdm(mol_list1, desc='Getting fingerprints for database mols')]
ArgumentError: Python argument types in
rdkit.Chem.rdMolDescriptors.GetMorganFingerprint(NoneType, int) did
not match C++ signature: GetMorganFingerprint(class RDKit::ROMol mol,
unsigned int radius, class boost::python::api::object invariants=[],
class boost::python::api::object fromAtoms=[], bool
useChirality=False, bool useBondTypes=True, bool useFeatures=False,
bool useCounts=True, class boost::python::api::object bitInfo=None,
bool includeRedundantEnvironments=False)
This is from the third line GetMorganFingerprint Imports were;
import pandas as pd
import seaborn as sns
import numpy as np
import os
import matplotlib.pyplot as plt
from tqdm import tqdm
from rdkit import Chem
from rdkit.Chem import AllChem,MACCSkeys
from rdkit import DataStructs
from rdkit.Chem import Descriptors
from rdkit.Chem import AllChem
from rdkit import DataStructs
from rdkit.Chem import PandasTools
Please help!

Related

could not convert string to float in linux Debian 11

In DEBIAN11, I write a code for serial display on GUI to plot a graph using dev/ttyACMO but unfortunately an error occurred that string could not convert to float here is the code:
import serial as sr
import matplotlib.pyplot asplt
import numpy as np
s=sr.Serial('/dev/ttyACM0',115200);
plt.close('all')
plt.figure();
plt.ion();
plot.show();
data = np.array([]);
i=0
while i<100
a=s.readline()
a.decode()
b = float(a[0:4])
data = np.append(data,b);
plt.plot(data);
plt.pause(0.01);
i=i+1
s.close()

julia LoadError: UndefVarError: #showprogress not defined

I excute <include("C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl")>,but it reports erro.Here is part of the codes:
function main()
using Images, ImageView, DataFrames, CSV, Statistics, LinearAlgebra
import Glob
import Distributions
import JSON
import ImageMagick
using Logging
import Gtk
import DataStructures
import CSV
import Random
import StatsPlots
import ProgressMeter.#showprogress
## These are const, if you change them while this notebook is running behavior will be undefined.
const ROI_PX = 7; # --> ROI is 7*2+1 x 7*2+1 pixels
const PX_NM = 100; # 1 pixel is 100nm
const FRAMESIZE=64; # x/y dim of frame
rootpath = "../data"
#assert ispath(rootpath)
fpath = joinpath(rootpath, "sequence-MT0.N1.HD-AS-Exp-as-list");
pospath = rootpath
outdir = joinpath(rootpath, "output")
if !ispath(outdir)
mkpath(outdir)
end
#info "Using $(fpath) as inputdirectory, $(outdir) as output"
....
end
**ERROR: LoadError: LoadError: UndefVarError: #showprogress not defined**
Stacktrace:
[1] top-level scope
# :0
[2] include(fname::String)
# Base.MainInclude .\client.jl:444
[3] top-level scope
# none:1
in expression starting at C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl:53
in expression starting at C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl:4
I don't know how to solve this error, could someone help me ? Thanks a lot!
don't put package loading inside function:
julia> function main()
import ProgressMeter.#showprogress
#showprogress for _ = 1:10
end
end
ERROR: LoadError: UndefVarError: #showprogress not defined
in expression starting at REPL[1]:3
julia> import ProgressMeter.#showprogress
julia> function main()
#showprogress for _ = 1:10
end
end
main (generic function with 1 method)
put them outside of your main(). The reason is that macro expansion happens before runtime.

PyQt5 using 2 .show() can't get ride of either one

PyQt5 App, I am building this app and had to use 2 .show(), 2 GUI show up when I run the code. One blank GUI and with with my information. When I remove the first .show() only the blank GUI shows up when I remove the second one nothing shows up any ideas.
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QGridLayout, `enter code here`QLineEdit, QLabel
from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QFormLayout, QPushButton, `enter code here`QTableWidget, QTableWidgetItem
from PyQt5.QtCore import Qt
import sqlite3
class ExerciseTracker(QWidget):
def __init__(self):
super().__init__()
self.myWindow = QWidget()
self.title = 'Exercise Tracker'
self.setWindowTitle(self.title)
self.setGeometry(200, 400, 300, 200)
self.move(60, 15)
self.layout = QFormLayout()
self.layout.addRow(QLabel('<h2>Welcome to the App!</h2>', parent=self.myWindow))
line_edit1 = QLineEdit()
self.layout.addRow('Day of the week: ', line_edit1)
line_edit2 = QLineEdit()
self.layout.addRow('Body Part: ', line_edit2)
line_edit3 = QLineEdit()
self.layout.addRow('Input Exercise: ', line_edit3)
line_edit4 = QLineEdit()
self.layout.addRow('Input Sets: ', line_edit4)
line_edit5 = QLineEdit()
self.layout.addRow('Input Reps: ', line_edit5)
btn1 = QPushButton('Submit')
self.layout.addRow(btn1)
btn2 = QPushButton('Show Records')
self.layout.addRow(btn2)
self.myWindow.setLayout(self.layout)
self.myWindow.show()
def main():
exercise = QApplication(sys.argv)
view = ExerciseTracker()
view.show()
sys.exit(exercise.exec_())
if __name__ =='__main__':
main()

Python Watchdog Custom Event Handler Not Firing Correctly

I'm using Python's watchdog module to listen for created events on a certain directory. Where I do some processing on newly created .csv files. When I test my code with nothing in the handler the watchdog fires correctly for all pasted/created files, but when I add my code/logic inside the handler it fires less than expected (52/60 files for example).
OS used: Windows 10, code is expected to work on a Windows server.
Python version: 3.7.3
Code:
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import pandas as pd
import numpy as np
from error_handling import ErrorHandler
import os
from timeloop import Timeloop
from datetime import timedelta
import json
from fill_data import OnMyWatch2
class OnMyWatch:
# Set the directory on watch
watchDirectory = "."
def __init__(self):
self.observer1 = Observer()
def run(self):
self.observer1.schedule(Handler() , self.watchDirectory, recursive = True)
self.observer1.start()
try:
while True:
time.sleep(1)
except:
self.observer1.stop()
print("Observer Stopped")
self.observer1.join()
class Handler(FileSystemEventHandler):
#staticmethod
def on_any_event(event):
if event.is_directory:
return None
elif event.event_type == 'created':
try:
# Event is created, you can process it now
print("Watchdog received created event - % s." % event.src_path)
pathlower = str(event.src_path).lower()
if ".csv" in pathlower:
print("File is csv file")
# Once any code is added here the problem happens
# Example:
# df = pd.read_csv(event.src_path, names= ALL_INI.columnlistbundle.split("|"), sep="|", encoding='latin-1', engine='python')
# arraySelectedColumnsBundle = ALL_INI.selectedcolumnsbundle.split(",")
# bundle_df = df[np.array(arraySelectedColumnsBundle)]
else:
print("File is not csv file")
except Exception as e:
ErrorHandler(0, 'In Observer ', '-7', 'Exception ' + str(e), '', 1, '')
if __name__ == '__main__':
if os.path.isdir("."):
watch = OnMyWatch()
watch.run()

Python 2.6 run time error

STEPCAFControl which is available in python2.6 but webgl module is not available. So I am trying to run this below program .
from __future__ import print_function
import sys
from OCC.STEPCAFControl import STEPCAFControl_Reader
from OCC.STEPControl import STEPControl_Reader
from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Display.SimpleGui import init_display
#from OCC.Display.WebGl import threejs_renderer
step_reader = STEPControl_Reader()
status = step_reader.ReadFile('./models/screw.step')
if status == IFSelect_RetDone: # check status
failsonly = False
step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)
step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)
ok = step_reader.TransferRoot(1)
_nbs = step_reader.NbShapes()
aResShape = step_reader.Shape(1)
print("Success")
else:
print("Error: can't read file.")
sys.exit(0)
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisplayShape(aResShape, update=True)
start_display()
#my_renderer = threejs_renderer.ThreejsRenderer(background_color="#123345")
#my_renderer.DisplayShape(aResShape)
but getting this error.
How to solve this issue? Any suggestion?

Resources