read in mol2 file

I'm trying to use the bio3d package to read in my .mol2 file. I have it stored on the desktop so I tried

mol <- read.mol2(C:/Users/Siri/Desktop/6T0C/test.mol2)

but no mol2 file is found. The example from the help file

mol <- read.mol2(system.file("test", package="bio3d"))

works just fine. How can I read in my own mol2 file ?

you want to pass a string to read.mol2 , so that would require some quote marks, whether single or double.

mol <- read.mol2("C:/Users/Siri/Desktop/6T0C/test.mol2")
1 Like

That's right! I still get the error "error in[,3]: subscribt out of bounds.

my mol2 file is quite large (when I read it in with read_csv I get almost 100'000 obersvations of 1 variable). Could this maybe cause problems?

If there are no errors, your file has been imported. To read it, you have to use

view ("mol2")

Could you share the first few lines of your mol2 file? They should look like that (from the aspirin example):

   20    20     0     0     0

If I understand the error message correctly, one of the molecules in your file looks like that:

   20    20 

so the third field (substructure) is missing. If that is indeed the case, I suspect you have not installed the latest version of bio3d, which automatically fills in the missing fields. The one on CRAN should do it, try running update.packages("bio3d").

You could try with the option maxlines if this worries you. Check your file first to avoid cutting in the middle of a molecule.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.