fastStructure: tuple index out of range

1,434 views
Skip to first unread message

Vikram Chhatre

unread,
Jul 21, 2014, 4:43:45 PM7/21/14
to structure-software
fastStructure experts:

I have hit the 'tuple out of range'  problem again with one of my data sets.  The set runs properly with original Structure program, but I am getting following error with fastStructure:

-------------------------------------------------------------------------------------------
$> python structure.py -K 2 --input=data1 --output=data1out --prior=simple

Traceback (most recent call last):
  File "~/fastSTRUCTURE/structure.py", line 165, in <module>
    G = parse_str.load(params['inputfile'])
  File "parse_str.pyx", line 10, in parse_str.load (parse_str.c:1460)
    L = loci.shape[1]
IndexError: tuple index out of range
-------------------------------------------------------------------------------------------

If any of you experienced this problem, I am interested in hearing how you solved it.

Thanks
V

Vikram Chhatre

unread,
Jul 22, 2014, 10:36:42 PM7/22/14
to structure-software
One reason for this error is the presence of header in the data file, e.g. first row with names of loci.  This header should be removed for fastSTRUCTURE to work. 

V

Simey

unread,
Aug 12, 2014, 4:26:33 PM8/12/14
to structure...@googlegroups.com
Hi Vikram,
Yes, removing the first row with locus names fixed this issue. My input file was a Stacks populations output, which also includes a commented header that causes problem in both Structure and fastStructure. For e.g. 
# Stacks v1.20; Structure 2.3; August 12, 2014
this too must be removed from files generated by Stacks.

xiaowei yang

unread,
May 7, 2015, 9:48:18 PM5/7/15
to structure...@googlegroups.com
Thank you!
It works.

aruna nandety

unread,
Oct 22, 2015, 7:39:43 PM10/22/15
to structure-software
Hi Vikram,

I am having the same problem. I have a text file from which I created an .str file. I left the first 4 columns empty, 5th column is individual ID, 6th column is population ID and then follows 3194 SNP marker data represented by 2 digits each. I left first row empty as suggested and then 372 individuals (2 rows per ID), but I still get the same error. I am pasting few rows and columns here.

1_1 1 22 11 11
1_1 1 22 22 11
1_10 1 11 11 22
1_10 1 22 11 22
1_11 1 11 22 22
1_11 1 22 22 22

$> python structure.py -K 2 --input=snp --format=str --output=out

Traceback (most recent call last):
File "structure.py", line 172, in <module>
G = parse_str.load(params['inputfile'])
File "parse_str.pyx", line 10, in parse_str.load (parse_str.c:1468)
L = loci.shape[1]
IndexError: tuple index out of range

Any help is highly appreciated. I am pretty sure that none of the individuals have 100% monomorphism.

Thank you
Aruna

Alicia Talavera

unread,
Feb 28, 2018, 10:07:42 AM2/28/18
to structure-software
Hello, 

I have the same bug: 

Traceback (most recent call last):

  File "structure.py", line 172, in <module>

    G = parse_str.load(params['inputfile'])

  File "parse_str.pyx", line 10, in parse_str.load (parse_str.c:1455)

    L = loci.shape[1]

IndexError: tuple index out of range


And I have read: "One reason for this error is the presence of header in the data file, e.g. first row with names of loci.  This header should be removed for fastSTRUCTURE to work. "

But I haven't got header in my data file.

 Have you found another solution? 

Thank you!

f.pina...@gmail.com

unread,
Mar 1, 2018, 5:07:09 AM3/1/18
to structure-software
Hello Alicia,

Can you please provide us with the command line you used that generated the error?

Also, take a look at your input file. Do you see anything obviously unusual? (such as lines with different lengths)
If all else fails, try a different input format (the error show you are using the "str" format, you can try using the "bed" format).

Francisco

brian simison

unread,
Mar 5, 2021, 1:20:07 PM3/5/21
to structure-software
Another source of this error, for me, has been the coding for missing data. Stacks outputs "0" for missing data, FastStructure is looking for "-9". I use a simple awk command to convert "0" to "-9" (My samples have numbers in them):
cat populations.str | awk '{gsub(/\t0\t/,"\t-9\t");}1' > populationsFS.str

Edgar Caballero

unread,
May 19, 2022, 9:23:33 AM5/19/22
to structure-software
Good morning faststructure commnunity I am new using the software in linux. I face the same problem as my  peers. I had an stacks populations structure format file which I edited on excel.  I Removed the comments headers row (#), loci headers row, added 4 columns with "#" and replaced "0" with  "-9".When I upload my file I transform it from txt to str format. Here I provide my commands :

structure.py -K $SGE_TASK_ID \
--input=/scratch/genomics/caballeroeg/FasSTRUCTURE/example_name \
--output=/scratch/genomics/caballeroeg/FasSTRUCTURE/K_$SGE_TASK_ID \
--tol=10e-6 \
--format=str \
--full

I have the same error as peers
My error: 
 Traceback (most recent call last):
File "/share/apps/bioinformatics/faststructure/conda/envs/faststructure/bin/structure.py", line 173, in <module>
G = parse_str.load(params['inputfile'])
File "parse_str.pyx", line 10, in parse_str.load
IndexError: tuple index out of range 

Given that the exmaples like headers or values does not apply here, what type of solution would you suggest to solve the problema

I would also like to ask if the output path refers a path to a folder, or an empty file (the empty file can be in .txt format?),

I would very much appreciate your advise and suggestions,
thanks in advance,

Edgar

Edgar Caballero

unread,
May 19, 2022, 2:51:50 PM5/19/22
to structure...@googlegroups.com
Hello Structure community
I solved it, it turns out that I created an extra row of "#" at the end of the .str file, I removed it and my analysis  ran well. I would recommend to check any malicious command or sintaxis error like this. Also I work in a linux environment so the endline command should be in LF or Linux. If you process an stacks output file after running populations I suggest copy the structure file with the extension .xls (in that way you can open it in excel) and modified the file. In excel I added the first 4 columns of "#", deleted the headers (including the ones with the names of the locis), and replaced the 0 with -9 .
I hope you guys can solve your issue.

--
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/23f22d1a-5cea-40b3-89d4-44dd701d810an%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages