Closed mjmcleod64 closed 7 months ago
Hey, thanks so much for reaching out and for raising this error!
First, the quick fix: this error should be resolved by adding the --output-dir
option to your matchmaps
call, e.g.:
matchmaps --mtzoff 2qew_phases.mtz FP SIGFP --mtzon 3dt2_phases.mtz FP SIGFP --pdboff 2qew.pdb --output-dir matchmaps_files
matchmaps
is designed to work as much as possible in the output directory, and interfere minimally with the input directory. As such, early in the program, various input files are copied to the output directory. However, this behavior does not account for the possibility that the input and output directories are the same!
Specifically, if it is true that both:
./
).pdb
formatthen the above error will always occur.
Regretfully, as this situation was not foreseen, the error message above is quite unhelpful.
shutil.copy
call ignore the errorReplacing
shutil.copy(input_file, output_file)
with
try:
shutil.copy(input_file, output_file)
except shutil.SameFileError:
pass
in line 1016 of _utils.py
would solve this issue.
It would be important to further test this solution to ensure that it does not cause unexpected errors downstream!
--output-dir
is not provided, use a default value other than ./
I don't really like this option, because it has the potential to create an unexpected directory structure for the user. I would also have to handle the case where a directory with the default name already exists; do you use it then? Or do you slap a _1
on the end?
--output-dir
a required parameterThe downside of this approach is that adding another required parameter makes matchmaps
calls necessarily longer and clunkier. The advantage is that the user maintains full control over the resulting directory structure. Outputs could still be directed to the current directory by supplying --output-dir ./
, for example.
Change 3 would require making change 1 as well; otherwise, supplying --output-dir ./
would just recreate the original error!
If change 2 were made, change 1 should not be made. Instead, the SameFileError
should be raised with an informative error message that explains what has happened and how to fix it.
I will consider the above options and push an appropriate fix in the immediate future.
source /usr/local/phenix-1.21rc1-5170/phenix_env.sh /opt/xtal/ccp4-8.0/start
This error shows: This script is to be run in subshell, not sourced.
I just realized that I didn't respond to this part. Confusingly, the phenix environment is activated with the source
command:
source /usr/local/phenix-1.21rc1-5170/phenix_env.sh
whereas ccp4 comes with its own executable that should just be run as:
/opt/xtal/ccp4-8.0/start
with no source
command out front.
Given the subsequent error you described above, which comes later in the program, it seems that you were able to get CCP4 sourced successfully. In any case, I'm adding this here for the sake of completeness.
This bug is fixed as of PyPI version 0.6.2
. Now, when the input and output directories match, a warning message is printed out to the user, and the program proceeds.
Description
I am pretty unversed in linux in conda installations. I am trying to create my first difference maps after installation. Receving program with sourcing ccp4 and phenix as well as running program.
What I Did
I did the installation as specific conda create -n my-matchmaps-env python=3.9 conda activate my-matchmaps-env pip install matchmaps
source /usr/local/phenix-1.21rc1-5170/phenix_env.sh /opt/xtal/ccp4-8.0/start
This error shows: This script is to be run in subshell, not sourced.
I continued forward and attempted to run the program using: matchmaps --mtzoff 2qew_phases.mtz FP SIGFP --mtzon 3dt2_phases.mtz FP SIGFP --pdboff 2qew.pdb where the files are present in the directory I am in
I receive this error: Traceback (most recent call last): File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/bin/matchmaps", line 8, in
sys.exit(main())
File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/lib/python3.9/site-packages/matchmaps/_compute_realspace_diff.py", line 450, in main
compute_realspace_difference_map(
File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/lib/python3.9/site-packages/matchmaps/_compute_realspace_diff.py", line 109, in compute_realspace_difference_map
pdboff = _cif_or_pdb_to_pdb(pdboff, output_dir)
File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/lib/python3.9/site-packages/matchmaps/_utils.py", line 979, in _cif_or_pdb_to_pdb
shutil.copy(input_file, output_file)
File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/lib/python3.9/shutil.py", line 427, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/home/mjmcleod/eman2-sphire-sparx/envs/my-matchmaps-env/lib/python3.9/shutil.py", line 244, in copyfile
raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: PosixPath('2qew.pdb') and PosixPath('2qew.pdb') are the same file
And am now stuck. Any help would be appreciate