代码如下:
#!/mnt/g/julia
using BioStructures #BioStructures Module to read and write pdb files.
logfilename="splitPDB.log"
log = open(logfilename,"w")
"Module to split a pdb file to many single chain pdb file."
function splitStructure(file::AbstractString,singlechainDB::AbstractString)
filename = split(basename(file),".")[1]
if endswith(file,".pdb")
write(log,file," will be read as pdb file.","\n")
Structure = read(file,PDB)
elseif endswith(file,"cif")
write(log,file," will be read as cif file.","\n")
Structure = read(file,MMCIF)
else
println("Error: Input File Extensions not recognized.",file)
end
for model in Structure
modelname = modelnumber(model)
for chain in model
chainname = chainid(chain)
writepdb("$singlechainDB/$filename-$modelname-$chainname.pdb",chain)
end
end
nothing
end
Threads.@threads for file in readdir("./FullDB")
splitStructure("./FullDB/$file","./SingleChainHumanPDB/")
end
我有很多文件,这段代码想实现的目的是把这些文件读入Julia然后利用BioStructures模块将文件中的信息拆分成几个部分并分别写到特定目录,在成功生成了12W+的文件后程序报错退出,报错如下:
ERROR: LoadError: TaskFailedException:
ArgumentError: Cannot fit value “100000” into 5 space(s)
Stacktrace:
[1] spacestring at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:632 [inlined]
[2] pdbline(::Atom) at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:697
[3] writepdb(::IOStream, ::Chain; expand_disordered::Bool) at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:811
[4] #71 at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:774 [inlined]
[5] open(::BioStructures.var"#71#72"{Bool,Chain,Tuple{}}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:298
[6] open at ./io.jl:296 [inlined]
[7] #writepdb#70 at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:773 [inlined]
[8] writepdb at /home/wanglin/.julia/packages/BioStructures/VSND1/src/pdb.jl:773 [inlined]
[9] splitStructure(::String, ::String) at /mnt/f/6-Molecular-Glue/CRBN-Binding-Motif/HumanPDB/splitStructure.jl:22
[10] macro expansion at /mnt/f/6-Molecular-Glue/CRBN-Binding-Motif/HumanPDB/splitStructure.jl:29 [inlined]
[11] (::var"#4#threadsfor_fun#3"{Array{String,1}})(::Bool) at ./threadingconstructs.jl:61
[12] (::var"#4#threadsfor_fun#3"{Array{String,1}})() at ./threadingconstructs.jl:28
Stacktrace:
[1] wait(::Task) at ./task.jl:267
[2] top-level scope at ./threadingconstructs.jl:69
[3] include(::Module, ::String) at ./Base.jl:377
[4] exec_options(::Base.JLOptions) at ./client.jl:288
[5] _start() at ./client.jl:484
in expression starting at /mnt/f/6-Molecular-Glue/CRBN-Binding-Motif/HumanPDB/splitStructure.jl:28
请问各位大佬这是什么原因呢?(推测是多线程的问题?)
小白刚开始学Julia,各位大佬如果有任何建议欢迎指正!