Can't get the program to begin; error on line 44

411 views
Skip to first unread message

Konrad Taube

unread,
Feb 26, 2021, 10:54:09 AM2/26/21
to structure-software
Hi, I am sorry if this post is a little long, but I want to be as thorough as I can be! 

I am trying to run fastStructure and am coming across some errors. Before I get into the errors, here is some information to start:

'python --version'
'Python 3.8.5'

GSL is version 2.4

Numpy is version 1.20.0 (I think)

'cython --version
Cython version 0.29.22'

Scipy is version 1.6.0

Hopefully that is helpful, but if not then that's okay! So, here is the code I am using:

python structure.py -K 3 --input=/home/FM/ktaube/Downloads/plink1.09/masters-p1-vmac2.bed --output=home/FM/ktaube/Downloads/fastStructure/vmac2-p1-structureoutput --full --seed=100

Which gives me the following error:

'File "structure.py", line 44
    print "%s prior is not currently implemented, defaulting to the simple prior"
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("%s prior is not currently implemented, defaulting to the simple prior")?'

I go ahead and just give 'python structure.py' a try and get that same error. My guess is maybe I am using a newer version of python or something? Any help would be really appreciated!


Konrad Taube

unread,
Feb 26, 2021, 5:13:38 PM2/26/21
to structure-software
One other attempt I made was with:

`python2 structure.py` 

Just to see if anything would be different. I did get something different, though it was just a new error:

`Traceback (most recent call last):
  File "structure.py", line 2, in <module>
    import numpy as np
ImportError: No module named numpy`

Which is not making sense to me, as my command line tells me I have numpy installed? Maybe this is helpful, I'm not sure.

Vikram Chhatre

unread,
Feb 26, 2021, 5:17:32 PM2/26/21
to structure-software
Start python in interactive mode and check if numpy exists.

python2

import numpy

Keep in mind that Python 2x is now becoming deprecated. 

--
You received this message because you are subscribed to the Google Groups "structure-software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structure-softw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/structure-software/fffc68fd-c338-4410-919d-1de9a450c312n%40googlegroups.com.

Konrad Taube

unread,
Feb 26, 2021, 6:06:54 PM2/26/21
to structure-software
Oh, interesting... I did this and got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy

What do you think I should do to move forward? Thanks for the reply by the way!

Vikram Chhatre

unread,
Feb 26, 2021, 6:10:20 PM2/26/21
to structure-software
Your python2 installation does not have the numpy module installed.  Try installing it.

Also, concerning your original error message on py3, if you look at your commandline options, you are missing a preceding "/" before home for the program output. You might also want to explicitly set the simple prior.  I don't think either of these things should cause the error you got, but start there first.



Konrad Taube

unread,
Feb 27, 2021, 8:41:07 AM2/27/21
to structure...@googlegroups.com
So I kept fiddling around! Here is what I've done:

Since numpy was already installed, I switched to python2 environment and typed:

conda install -c bioconda numpy -f

Forcing it to (re)install numpy. That gave me the following response:

WARNING: The --force flag will be removed in a future conda release.
         See 'conda install --help' for details about the --force-reinstall
         and --clobber flags.


Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/FM/ktaube/miniconda3/envs/ipykernel_py2

  added / updated specs:
    - numpy



Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done


I then did:

python
import numpy

And got no explicit response from the terminal (question: should I have? What am I looking for there?), so I assumed something happened, but again I just don't know how to tell.

Then, I entered the following:

 structure.py -K 3 --input=/home/FM/ktaube/Downloads/plink1.09/masters-p1-vmac2 --output=./output --full --seed=100

And the terminal spits back the following:

File "<stdin>", line 1
    structure.py -K 3 --input=/home/FM/ktaube/Downloads/plink1.09/masters-p1-vmac2 --output=./output --full --seed=100
                             ^
SyntaxError: invalid syntax

I don't know if it is formatted in this response, but on the terminal that little carrot symbol (^) is hovering right below the number 3, for the -K 3 portion. I hope that is helpful!




--
Konrad Taube
B.Sc - Molecular and Cellular Biology, 2015
University of Illinois at Urbana-Champaign
M.Sc - Biological Sciences (Expected graduation: Spring 2021)
DePaul University

If sent by cellphone, please forgive any typos you may have received.

Vikram Chhatre

unread,
Feb 27, 2021, 8:45:26 AM2/27/21
to structure-software
What is the output of ls-l in this directory: /home/FM/ktaube/Downloads/plink1.09/

When you run -K 3, the file names are expected to contain a ".3.EXT" in them.  

You should consider working with example data first to get a handle on the requirements.



Francisco Pina Martins

unread,
Feb 27, 2021, 2:54:49 PM2/27/21
to structure-software
Hi to both of you.

fastStructure was written in python 2 nad was never ported to python 3. The years went by and python 2 is now End of Lifed (EOL). Running things in python 2 will only get harder with time.
In order to avoid the mess of having multiple environments and trying to force install deprecated packages, you can use a pre-built binary. Although the fastStructure repository does not offer one, I have built one that is distributed with Structure_threader.

Just run `pip3 install structure_threader --user` and you should get a copy of the fastStructure binary with the package. If your system's $PATH is already configured to use local directories, all you need to do is type `fastStructure` in your terminal and you are ready to go. Otherwise, you will find the binary under `~/.local/bin` and you can use it from there.

Best of luck!

Francisco

Josh Banta

unread,
Feb 27, 2021, 5:02:36 PM2/27/21
to structure...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages