export variable unknown location and .sh variable setup

General support questions
Post Reply
ahmadkhalifa
Posts: 13
Joined: 2018/03/21 16:45:10

export variable unknown location and .sh variable setup

Post by ahmadkhalifa » 2019/03/24 07:36:33

1) I think my machine is not set up properly. I can echo certain variables that return a path, but I can't seem to find where that variable is defined.

I looked into ~/.bashrc, ~/.bash_profile, /etc/bashrc and a bunch of other places that people recommended to inspect, I can't seem to find some variables that I could echo in the shell!

2) I'm also having issues running .sh scripts that are supposed to configure variable for me. The only way I can do it, is by opening the script and executing the exports inside manually (temporary) or or copying the content of the .sh and adding it to ~/.bashrc.

If I add the script as ./script.sh or even create an alias in the .bashrc, it doesn't work!

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: export variable unknown location and .sh variable setup

Post by pjsr2 » 2019/03/24 17:12:47

I can echo certain variables that return a path, but I can't seem to find where that variable is defined.
You have to give the names of the environment variables you cannot locate, otherwise nobody in this forum can help you.
If I add the script as ./script.sh or even create an alias in the .bashrc, it doesn't work!
When you add the script as

Code: Select all

./script.sh

you are executing -/script.sh as a command, that is executed in a new process, i.e. in a sub-process of your current shell. The environment variables that you are setting in script.sh are set in this new process. The calling process (your shell) does not get these new environment variables.

Your shell does not execute .bashrc and similar files, but is reads the contents of these scripts as if they are "include"-d files.
The bash shell syntax has two ways to do that:

Code: Select all

source ./script.sh
or

Code: Select all

. ./script.sh
Personally I prefer the first form, as it is easy to miss the "." command in the second form.

If you look carefully at your $HOME/.bashrc file, you will see that its permissions are :

Code: Select all

$ ls -l $HOME/.bash*
-rw-r--r--.  1 pjsr2 pjsr2   18 Oct 30 18:07 .bash_logout
-rw-r--r--.  1 pjsr2 pjsr2  193 Oct 30 18:07 .bash_profile
-rw-r--r--.  1 pjsr2 pjsr2  231 Oct 30 18:07 .bashrc
All these files are readable, but none of them is executable.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: export variable unknown location and .sh variable setup

Post by aks » 2019/03/24 17:14:28

1. I can't seem to find where that variable is defined.
What kind of variables are you talking about? System or your own? Some places I noticed you did not mention was /etc/profile.d/* and /etc/<shell>.login but thtere are others too.
The variables must be defined somewhere (unless they're built into the shell like for example version strings). I guess you could just grep -r for the variable name, which would do a recursive search for the variable name in the filesystem (esp. if you run it from root).
2. I'm also having issues running .sh scripts that are supposed to configure variable for me. The only way I can do it, is by opening the script and executing the exports inside manually (temporary) or or copying the content of the .sh and adding it to ~/.bashrc.
I think you misunderstand what running a script does. It actually runs another shell (aka subshell) and execiutes the commands, then terminates - without changing the calling shell. If you have a bunch of variables in a file you want to "import" into your existing shell, just use source <path_to_script_with_filename>. If you are running bash you can export the variable into other shells. As to .bash_profile and .bashrc they run differently depending on who you login.

You could also have a labelling issue with SELinux. Do the things work as expected if you're running in Permissive mode (setenforce permissive to set)?

ahmadkhalifa
Posts: 13
Joined: 2018/03/21 16:45:10

Re: export variable unknown location and .sh variable setup

Post by ahmadkhalifa » 2019/03/24 23:51:30

The variable is PHENIX_ROSETTA_PATH, it's a user defined variable that I need to set.

I added export PHENIX_ROSETTA_PATH=$PHENIX_ROSETTA_PATH:/home/labusr/rosetta/main to my .bashrc, but when I echo, I got:

/home/labusr/rosetta:/home/labusr/rosetta/main

However, if I remove the PHENIX_ROSETTA_PATH from .bashrc, echo returns /home/labusr/rosetta

Where exactly is PHENIX_ROSETTA_PATH defined as /home/labusr/rosetta, I have no idea! I looked in my etc folder, bashrc, my home .bashrc,.bash_profile, nothing!

I did grep -r PHENIX_ROSETTA_PATH but couldn't find it!

Btw, thanks for clarifying about bashrc, I will try source script.sh

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: export variable unknown location and .sh variable setup

Post by MartinR » 2019/03/25 07:55:29

Have a look at https://www.phenix-online.org/documenta ... stall.html. Under Installation - Using standard Phenix installation there is the paragraph:
The directory containing "main demo tools" is to be called "PHENIX_ROSETTA_PATH". Now you can now set a local environmental variable in your ".profile" (sh or bash shell) or ".cshrc" (c-shell) to mark where rosetta is located: if you are using the bash or sh shells:

% export PHENIX_ROSETTA_PATH=/your-path-to-rosetta-here/

or sh (C-shell):

% setenv PHENIX_ROSETTA_PATH /your-path-to-rosetta-here/
You need to do this before attempting to use $PHENIX_ROSETTA_PATH in setting your $PATH. If you don't then $PHENIX_ROSETTA_PATH will have a null value when you set your $PATH, substitution occurs at once.

ahmadkhalifa
Posts: 13
Joined: 2018/03/21 16:45:10

Re: export variable unknown location and .sh variable setup

Post by ahmadkhalifa » 2019/03/25 17:15:48

MartinR wrote:
2019/03/25 07:55:29
Have a look at https://www.phenix-online.org/documenta ... stall.html. Under Installation - Using standard Phenix installation there is the paragraph:
The directory containing "main demo tools" is to be called "PHENIX_ROSETTA_PATH". Now you can now set a local environmental variable in your ".profile" (sh or bash shell) or ".cshrc" (c-shell) to mark where rosetta is located: if you are using the bash or sh shells:

% export PHENIX_ROSETTA_PATH=/your-path-to-rosetta-here/

or sh (C-shell):

% setenv PHENIX_ROSETTA_PATH /your-path-to-rosetta-here/
You need to do this before attempting to use $PHENIX_ROSETTA_PATH in setting your $PATH. If you don't then $PHENIX_ROSETTA_PATH will have a null value when you set your $PATH, substitution occurs at once.
Well it's not working, and this variable is already defined, according to what you posted defined "correctly", I can't locate where it is defined though!

Code: Select all

(base) [labusr@luxor bin]$ export PHENIX_ROSETTA_PATH=/home/labusr/rosetta
(base) [labusr@luxor bin]$ ls /home/labusr/rosetta
demos  documentation  main  tools
(base) [labusr@luxor bin]$ 
(base) [labusr@luxor bin]$ 
(base) [labusr@luxor bin]$ echo $PHENIX_ROSETTA_PATH
/home/labusr/rosetta
(base) [labusr@luxor bin]$ rosetta.run_tests
Running Rosetta refinement tests
/usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.pdb
/usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz
phenix.rosetta_refine /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.pdb /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz number_of_models=2

============================== Collecting inputs ==============================


                   ----------Processing X-ray data----------                   

F-obs:
  /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz:FOBS_X,SIGFOBS_X
Miller array info: /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz:FOBS_X,SIGFOBS_X
Observation type: xray.amplitude
Type of data: double, size=495
Type of sigmas: double, size=495
Number of Miller indices: 495
Anomalous flag: False
Unit cell: (21.937, 4.866, 23.477, 90, 107.08, 90)
Space group: P 1 21 1 (No. 4)
Systematic absences: 0
Centric reflections: 199
Resolution range: 22.4416 1.80066
Completeness in resolution range: 0.895118
Completeness with d_max=infinity: 0.895118
Wavelength: 1.0000

Number of F-obs in resolution range:                   495
Number of F-obs<0 (these reflections will be rejected): 0
Number of F-obs=0 (these reflections will be used in refinement): 0
Refinement resolution range: d_max =  22.4416
                             d_min =   1.8007

R-free flags:
  /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz:R-free-flags
Miller array info: /usr/local/phenix-1.14-3260/modules/phenix_regression/refinement/data/1yjp.mtz:R-free-flags
Observation type: None
Type of data: int, size=495
Type of sigmas: None
Number of Miller indices: 495
Anomalous flag: False
Unit cell: (21.937, 4.866, 23.477, 90, 107.08, 90)
Space group: P 1 21 1 (No. 4)
Systematic absences: 0
Centric reflections: 199
Resolution range: 22.4416 1.80066
Completeness in resolution range: 0.895118
Completeness with d_max=infinity: 0.895118
Wavelength: 1.0000

Test (R-free flags) flag value: 1

Number of work/free reflections by resolution:
                                    work free  %free
  bin  1: 22.4433 -  3.8734 [61/70]   59    2   3.3%
  bin  2:  3.8734 -  3.0770 [53/58]   49    4   7.5%
  bin  3:  3.0770 -  2.6887 [49/55]   46    3   6.1%
  bin  4:  2.6887 -  2.4432 [37/40]   35    2   5.4%
  bin  5:  2.4432 -  2.2683 [62/66]   60    2   3.2%
  bin  6:  2.2683 -  2.1347 [51/56]   49    2   3.9%
  bin  7:  2.1347 -  2.0278 [50/55]   46    4   8.0%
  bin  8:  2.0278 -  1.9396 [49/56]   49    0   0.0%
  bin  9:  1.9396 -  1.8650 [43/50]   42    1   2.3%
  bin 10:  1.8650 -  1.8007 [40/47]   40    0   0.0%
                            overall  475   20   4.0%

                   ----------Processing PDB file(s)----------                  

  Monomer Library directory:
    "/usr/local/phenix-1.14-3260/modules/chem_data/mon_lib"
  Total number of atoms: 66
  Number of models: 1
  Model: ""
    Number of chains: 2
    Chain: "A"
      Number of atoms: 59
      Number of conformers: 1
      Conformer: ""
        Number of residues, atoms: 7, 59
          Classifications: {'peptide': 7}
          Modifications used: {'COO': 1}
          Link IDs: {'TRANS': 6}
    Chain: " "
      Number of atoms: 7
      Number of conformers: 1
      Conformer: ""
        Number of residues, atoms: 7, 7
          Classifications: {'water': 7}
          Link IDs: {None: 6}
  Time building chain proxies: 0.05, per 1000 atoms: 0.76
  Number of scatterers: 66
  At special positions: 0
  Unit cell: (21.937, 4.866, 23.477, 90, 107.08, 90)
  Space group: P 1 21 1 (No. 4)
  Number of sites at special positions: 0
  Number of scattering types: 3
    Type Number    sf(0)
     O      21      8.00
     N      12      7.00
     C      33      6.00
    sf(0) = scattering factor at diffraction angle 0.

  Number of disulfides: simple=0, symmetry=0
  Custom bonds:
    Warning: Ignoring bond with distance_ideal = None:
      atom_selection_1 = None
      atom_selection_2 = None
    Total number of custom bonds: 0
  Custom angles:
    Warning: Ignoring angle with angle_ideal = None:
      atom_selection_1 = None
      atom_selection_2 = None
      atom_selection_3 = None
    Total number of custom angles: 0
  Custom dihedrals:
    Warning: Ignoring dihedral with angle_ideal = None:
      atom_selection_1 = None
      atom_selection_2 = None
      atom_selection_3 = None
      atom_selection_4 = None
    Total number of custom dihedrals: 0
  Custom planarities:
    Warning: Ignoring planarity with with sigma <= 0:
      atom_selection = None
None
    Total number of custom planarities: 0
  Custom parallelities:
Warning: Ignoring parallelity with empty atom selection.
    Total number of custom parallelities: 0

  Automatic linking
    Parameters for automatic linking
      Linking & cutoffs
        Metal                : False - 3.50
        Amimo acid           : False - 1.90
        Carbohydrate         : True  - 1.99
        Ligands              : True  - 1.99
        Small molecules      : False - 1.98
        Amino acid - RNA/DNA : False
      
  Number of custom bonds: simple=0, symmetry=0
  Time building additional restraints: 0.01
  Conformation dependent library (CDL) restraints added in 1.6 milliseconds
  
  Adding C-beta torsion restraints...
  Number of C-beta restraints generated:  12

  Time building geometry restraints manager: 0.01 seconds

  NOTE: a complete listing of the restraints can be obtained by requesting
        output of .geo file.

  Histogram of bond lengths:
        1.23 -     1.29: 13
        1.29 -     1.36: 11
        1.36 -     1.42: 7
        1.42 -     1.49: 6
        1.49 -     1.55: 22
  Bond restraints: 59
  Sorted by residual:
  bond pdb=" N   GLY A   1 "
       pdb=" CA  GLY A   1 "
    ideal  model  delta    sigma   weight residual
    1.451  1.507 -0.056 1.60e-02 3.91e+03 1.23e+01
  bond pdb=" CA  GLN A   4 "
       pdb=" C   GLN A   4 "
    ideal  model  delta    sigma   weight residual
    1.522  1.553 -0.030 1.18e-02 7.18e+03 6.53e+00
  bond pdb=" N   GLN A   4 "
       pdb=" CA  GLN A   4 "
    ideal  model  delta    sigma   weight residual
    1.460  1.485 -0.025 1.17e-02 7.31e+03 4.40e+00
  bond pdb=" CA  ASN A   2 "
       pdb=" C   ASN A   2 "
    ideal  model  delta    sigma   weight residual
    1.524  1.498  0.025 1.26e-02 6.30e+03 4.00e+00
  bond pdb=" CA  ASN A   6 "
       pdb=" C   ASN A   6 "
    ideal  model  delta    sigma   weight residual
    1.526  1.504  0.022 1.28e-02 6.10e+03 2.85e+00
  ... (remaining 54 not shown)

  Histogram of bond angle deviations from ideal:
      107.05 -   110.59: 8
      110.59 -   114.13: 19
      114.13 -   117.67: 11
      117.67 -   121.21: 23
      121.21 -   124.75: 18
  Bond angle restraints: 79
  Sorted by residual:
  angle pdb=" N   ASN A   3 "
        pdb=" CA  ASN A   3 "
        pdb=" C   ASN A   3 "
      ideal   model   delta    sigma   weight residual
     108.90  113.48   -4.58 1.63e+00 3.76e-01 7.90e+00
  angle pdb=" N   GLN A   4 "
        pdb=" CA  GLN A   4 "
        pdb=" C   GLN A   4 "
      ideal   model   delta    sigma   weight residual
     108.02  111.93   -3.91 1.78e+00 3.16e-01 4.84e+00
  angle pdb=" CA  GLN A   4 "
        pdb=" C   GLN A   4 "
        pdb=" O   GLN A   4 "
      ideal   model   delta    sigma   weight residual
     120.33  122.27   -1.94 1.08e+00 8.57e-01 3.23e+00
  angle pdb=" CA  GLN A   5 "
        pdb=" C   GLN A   5 "
        pdb=" O   GLN A   5 "
      ideal   model   delta    sigma   weight residual
     120.38  122.31   -1.93 1.09e+00 8.42e-01 3.13e+00
  angle pdb=" C   GLN A   4 "
        pdb=" N   GLN A   5 "
        pdb=" CA  GLN A   5 "
      ideal   model   delta    sigma   weight residual
     123.00  120.57    2.43 1.38e+00 5.25e-01 3.09e+00
  ... (remaining 74 not shown)

  Histogram of dihedral angle deviations from ideal:
        0.04 -    14.51: 26
       14.51 -    28.98: 5
       28.98 -    43.45: 1
       43.45 -    57.92: 1
       57.92 -    72.39: 1
  Dihedral angle restraints: 34
    sinusoidal: 15
      harmonic: 19
  Sorted by residual:
  dihedral pdb=" CA  ASN A   3 "
           pdb=" C   ASN A   3 "
           pdb=" N   GLN A   4 "
           pdb=" CA  GLN A   4 "
      ideal   model   delta  harmonic     sigma   weight residual
     180.00  166.21   13.79     0      5.00e+00 4.00e-02 7.60e+00
  dihedral pdb=" CB  GLN A   5 "
           pdb=" CG  GLN A   5 "
           pdb=" CD  GLN A   5 "
           pdb=" OE1 GLN A   5 "
      ideal   model   delta sinusoidal    sigma   weight residual
       0.00  -72.39   72.39     2      3.00e+01 1.11e-03 4.85e+00
  dihedral pdb=" CB  GLN A   4 "
           pdb=" CG  GLN A   4 "
           pdb=" CD  GLN A   4 "
           pdb=" OE1 GLN A   4 "
      ideal   model   delta sinusoidal    sigma   weight residual
       0.00   54.08  -54.08     2      3.00e+01 1.11e-03 3.50e+00
  ... (remaining 31 not shown)

  Histogram of chiral volume deviations from ideal:
       0.000 -    0.024: 1
       0.024 -    0.047: 1
       0.047 -    0.071: 1
       0.071 -    0.094: 1
       0.094 -    0.118: 2
  Chirality restraints: 6
  Sorted by residual:
  chirality pdb=" CA  GLN A   5 "
            pdb=" N   GLN A   5 "
            pdb=" C   GLN A   5 "
            pdb=" CB  GLN A   5 "
    both_signs  ideal   model   delta    sigma   weight residual
      False      2.51    2.39    0.12 2.00e-01 2.50e+01 3.48e-01
  chirality pdb=" CA  ASN A   6 "
            pdb=" N   ASN A   6 "
            pdb=" C   ASN A   6 "
            pdb=" CB  ASN A   6 "
    both_signs  ideal   model   delta    sigma   weight residual
      False      2.51    2.62   -0.11 2.00e-01 2.50e+01 2.86e-01
  chirality pdb=" CA  ASN A   2 "
            pdb=" N   ASN A   2 "
            pdb=" C   ASN A   2 "
            pdb=" CB  ASN A   2 "
    both_signs  ideal   model   delta    sigma   weight residual
      False      2.51    2.43    0.08 2.00e-01 2.50e+01 1.80e-01
  ... (remaining 3 not shown)

  Planarity restraints: 13
  Sorted by residual:
                                 delta    sigma   weight rms_deltas residual
  plane pdb=" CB  TYR A   7 "   -0.006 2.00e-02 2.50e+03   9.66e-03 1.87e+00
        pdb=" CG  TYR A   7 "    0.022 2.00e-02 2.50e+03
        pdb=" CD1 TYR A   7 "   -0.004 2.00e-02 2.50e+03
        pdb=" CD2 TYR A   7 "   -0.008 2.00e-02 2.50e+03
        pdb=" CE1 TYR A   7 "   -0.001 2.00e-02 2.50e+03
        pdb=" CE2 TYR A   7 "    0.002 2.00e-02 2.50e+03
        pdb=" CZ  TYR A   7 "   -0.011 2.00e-02 2.50e+03
        pdb=" OH  TYR A   7 "    0.006 2.00e-02 2.50e+03
                                 delta    sigma   weight rms_deltas residual
  plane pdb=" CB  ASN A   2 "    0.006 2.00e-02 2.50e+03   1.19e-02 1.42e+00
        pdb=" CG  ASN A   2 "   -0.021 2.00e-02 2.50e+03
        pdb=" OD1 ASN A   2 "    0.008 2.00e-02 2.50e+03
        pdb=" ND2 ASN A   2 "    0.007 2.00e-02 2.50e+03
                                 delta    sigma   weight rms_deltas residual
  plane pdb=" CA  GLN A   4 "    0.005 2.00e-02 2.50e+03   1.09e-02 1.18e+00
        pdb=" C   GLN A   4 "   -0.019 2.00e-02 2.50e+03
        pdb=" O   GLN A   4 "    0.007 2.00e-02 2.50e+03
        pdb=" N   GLN A   5 "    0.006 2.00e-02 2.50e+03
  ... (remaining 10 not shown)

  Histogram of nonbonded interaction distances:
        2.53 -     3.00: 50
        3.00 -     3.48: 107
        3.48 -     3.95: 243
        3.95 -     4.42: 255
        4.42 -     4.90: 523
  Nonbonded interactions: 1178
  Sorted by model distance:
  nonbonded pdb=" O   HOH    11 "
            pdb=" OH  TYR A   7 "
     model   vdw sym.op.
     2.525 2.440 -x+1,y+1/2,-z+1
  nonbonded pdb=" OH  TYR A   7 "
            pdb=" O   HOH    11 "
     model   vdw sym.op.
     2.525 2.440 -x+1,y-1/2,-z+1
  nonbonded pdb=" O   HOH    14 "
            pdb=" O   HOH    13 "
     model   vdw sym.op.
     2.634 2.440 x,y-1,z
  nonbonded pdb=" O   HOH    13 "
            pdb=" O   HOH    14 "
     model   vdw sym.op.
     2.634 2.440 x,y+1,z
  nonbonded pdb=" N   GLY A   1 "
            pdb=" O   GLY A   1 "
     model   vdw
     2.665 2.496
  ... (remaining 1173 not shown)

  NOTE: a complete listing of the restraints can be obtained by requesting
        output of .geo file.

============================== Scattering factors =============================


                ----------X-ray scattering dictionary----------                

Number of scattering types: 3
  Type Number    sf(0)   Gaussians
   O      21      7.97       2
   N      12      6.97       2
   C      33      5.97       2
  sf(0) = scattering factor at diffraction angle 0.

Number of scatterers: 66
At special positions: 0
Unit cell: (21.937, 4.866, 23.477, 90, 107.08, 90)
Space group: P 1 21 1 (No. 4)

                  ----------F(model) initialization----------                  

Twinning will be detected automatically.
                   start: r(all,work,free)=0.2072 0.2084 0.1924 n_refl.: 495
       re-set all scales: r(all,work,free)=0.2072 0.2084 0.1924 n_refl.: 495
         remove outliers: r(all,work,free)=0.2103 0.2117 0.1924 n_refl.: 493
bulk-solvent and scaling: r(all,work,free)=0.1755 0.1758 0.1728 n_refl.: 493
         remove outliers: r(all,work,free)=0.1755 0.1758 0.1728 n_refl.: 493
|--(resolution: 1.80 - 22.44 A, n_refl.=493 (all), 4.06  % free)--------------|
|                                                                             |
| r_work= 0.1758 r_free= 0.1728 coordinate error (max.-lik. estimate): -0.00 A|
|                                                                             |
| normalized target function (ml) (work): 2.637727                            |
| target function (ml) not normalized (work): 1247.644901                     |
| target function (ml) not normalized (free): 60.766973                       |
|-----------------------------------------------------------------------------|

End of input processing
Sorry: 
    The RosettaScripts executable could not be located.  Please set the
    environmental variable PHENIX_ROSETTA_PATH or add the appropriate
    directory to your PATH environment variable.
  

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: export variable unknown location and .sh variable setup

Post by pjsr2 » 2019/03/28 08:32:53

Where exactly is PHENIX_ROSETTA_PATH defined as /home/labusr/rosetta, I have no idea! I looked in my etc folder, bashrc, my home .bashrc,.bash_profile, nothing!
When a software package wants to add an environment variable, the usual method is to add a small script that sets the environment variable, in the special directory /etc/profile.d . The name of such a file has to end in ".sh". With this method an installer can add its own settings without having to modify any existing configuration file in your system.

The .sh-scripts in the /etc/profile.d directory are read from the /etc/profile and /etc/bashrc scripts, which are read when a bash shell is starting.

Post Reply