retrieve_pdb_file from Bio.PDB.PDBList creates .ent files, not .pdb - biopython

I'm using Biopython to load structures into my code. I then change them into poses, via PyRosetta, because I want to align my theo structure to the PDB website structures. This is my code:
pdbl = PDBList()
native_pdb = pdbl.retrieve_pdb_file('%s' %protein, pdir='/my/directory/path/test_natives', file_format='pdb')
native_pose = pose_from_pdb(native_pdb)
but the retrieve_pdb_file creates .ent files and not pdb files. how do I fix this?
OR how do I load the known PDB structures in order to align them to theo structures and find the rmsd?

If PyRosetta only accepts files with the .pdb extension, simple renaming should do:
from pathlib import Path
native_pose = Path(native_pose)
native_pose.rename(native_pose.with_suffix('.pdb'))

Related

How do you load a file (.csv) into a Beeware/Briefcase application?

I am using kivy as the GUI and Briefcase as a packaging utility. My .kv file is in the appname/project/src/projectName/resources folder. I also need a .csv file, in the same folder, and want to use pandas with it. I have no problem with importing the packages (I added them to the .toml file). I can't use the full path because when I package the app, the path will be different on each computer. Using relative paths to the app.py file does not work, giving me a file not found error. Is there a way to read a file using a relative path (maybe the source parameter in the .toml file)?
kv = Builder.load_file('resources/builder.kv')
df = pd.read_csv('resources/chemdata.csv')
class ChemApp(App):
def build(self):
self.icon = 'resources/elemental.ico'
return kv
I just encountered and solved a similar problem with Briefcase, even though I was using BeeWare's Toga GUI.
In my case, the main Python file app.py had to access a database file resources/data.csv. In the constructor of the class where I create a main window in app.py, I added the following lines (The import line wasn't there, but included here for clarification):
from pathlib import Path
self.resources_folder = Path(__file__).joinpath("../resources").resolve()
self.db_filepath = self.resources_folder.joinpath("data.csv")
Then I used self.db_filepath to successfully open the CSV file on my phone.
__file__ returns the path to the current file on whatever platform or device.

How to use ROS urdf package in Drake?

I'm new to Drake.And I want to use my robot model which is a ROS urdf package converted from SolidWorks plugin.I've tried to use
builder = DiagramBuilder()
plant, scene_graph = AddMultibodySceneGraph(builder,0.0)
parser = Parser(plant)
pkg_map = parser.package_map()
pkg_map.AddPackageXml("myxmlfilepath")
robot_file = "my_urdf_file_path"
robot = parser.AddModelFromFile(robot_file, "robot")
But I got an errorRuntimeError:The WaveFront obj file has no faces in the last line.I try to use ROS to display and it works well. My urdf file has some .stl format mesh file for visual and collision. I see some comments here, so I guess Drake maybe can't deal with .stl in a default way so far.What should I do except manually converting .stl mesh file to .obj file? Thanks in Advance.
As you noted in your comment above, once you converted your STL file to an OBJ file, you were able to load your URDF file.
This is because Drake does not yet support loading STL (or DAE) meshes at runtime; they must be converted (either manually as you had done, or via the build system). For more info, please see:
https://github.com/RobotLocomotion/drake/issues/2941
In that issue, I've referenced your post as a motivator towards adding additional mesh support.
Thanks!

Can an xml file be part of a QT qrc resource file

I built a PyQt application to showcase object detection. The detector was trained using haar classifier, whose ouptut is a cascade.xml file.
I tried to package this application using pyinstaller. However, before this, i made a resources.qrc file which i compiled.
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>cascade.xml</file>
</qresource>
</RCC>
My issue is that when i use this resource, via
:/cascade.xml
the file is not read.
What can i do to fix this.
You first need to create a python module from your .qrc file with pyrcc
pyrcc5 resources.qrc -o resources.py
The output of pyrcc then needs to be imported into your python code
import resources
Then you should be able to access the resource through ':/cascade.xml'. In some cases it may be necessary to use 'qrc:/cascade.xml'
The resource path must still, however, be treated like a file on disk. In order to access its contents you will need to read from the resource. Here's an example of how to read and parse it using lxml
import lxml.etree as etree
from PyQt5 import QtCore
# Import the resource module create by pyrcc
import resources
# QFile knows how to read Qt resources
xml_file = QtCore.QFile(':/cascade.xml')
if xml_file.open(QtCore.QFile.ReadOnly):
# Read the QFile and convert QByteArray output to python string
xml_str = str(xml_file.readAll())
# parse the xml document from string
xml_tree = etree.ElementTree(etree.fromstring(xml_str))
xml_file.close()

ILASM does not set FileVersion

I have an .il file which I can compile without any problems. I can strong name it and so without any issues. But I am not able to set the file version via the attribute as I would expect it. How can I set the FileVersion for an assembly when using ilasm?
If I do a round trip I get always a .res file which does contain only binary data which is not readable. What is inside this res file and can I edit it?
The code does not work
.assembly myAssembly
{
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = { string('1.2.3.4') }
The issue can be solved by using the .res file. It is not sufficient to do a round trip with ildasm and ilasm. The IL file does not reference the .res file. I had to add it to the ilasm call manually. The data in the res file seemed to contain the infos which are written into the PE header which is ok for me.
The final command line needed was
ilasm test.il /dll /res:test.res
I still do not know what exactly is inside the res file but I can exhange it with the meta data information of any other assemlby that I create manually and then decompile it to replace the metadata of the original assembly as I need.
It seems not many people are doing such stuff.

How to read .docx file using F#

How can I read a .docx file using F#. If I use
System.IO.File.ReadAllText("D:/test.docx")
It is returning me some garbage output with beep sounds.
Here is a F# snippet that may give you a jump-start. It successfully extracts all text contents of a Word2010-created .docx file as a string of concatenated lines:
open System
open System.IO
open System.IO.Packaging
open System.Xml
let getDocxContent (path: string) =
use package = Package.Open(path, FileMode.Open)
let stream = package.GetPart(new Uri("/word/document.xml", UriKind.Relative)).GetStream()
stream.Seek(0L, SeekOrigin.Begin) |> ignore
let xmlDoc = new XmlDocument()
xmlDoc.Load(stream)
xmlDoc.DocumentElement.InnerText
printfn "%s" (getDocxContent #"..\..\test.docx")
In order to make it working do not forget to reference WindowsBase.dll in your VS project.
.docx files follow Open Packaging Convention specifications. At the lowest level, they are .ZIP files. To read it programmatically, see example here:
A New Standard For Packaging Your Data
Packages and Parts
Using F#, it's the same story, you'll have to use classes in the System.IO.Packaging Namespace.
System.IO.File.ReadAllText has type of string -> string.
Because a .docx file is a binary file, it's probable that some of the chars in the strings have the bell character. Rather than ReadAllText, look into Word automation, the Packaging, or the OpenXML APIs
Try using the OpenXML SDK from Microsoft.
Also on the linked page is the Microsoft tool that you can use to decompile the office 2007 files. The decompiled code can be quite lengthy even for simple documents though so be warned. There is a big learning curve associated with OpenXML SDK. I'm finding it quite difficult to use.

Resources