# Error creating indices using STAR

I am trying to index wheat genome using STAR through following command

STAR --runMode genomeGenerate --genomeFastaFiles Triticum_aestivum.TGACv1.dna_sm.toplevel.fa --runThreadN 28


But getting following error,

terminate called after throwing an instance of 'std::bad_alloc'
Aborted (core dumped)


The size of the genome is 13.5 GB and the server capacity is 32 cores with 125 GB RAM, how this error can be resolved?

Memory usage:

I have decreased the number of threads to 8 but again getting the same error as shown below:

> STAR   --runMode genomeGenerate   --runThreadN 8   --genomeDir wheat   --genomeFastaFiles wheat.fa
Jun 04 02:13:31 ..... started STAR run
Jun 04 02:13:31 ... starting to generate Genome files
terminate called after throwing an instance of 'std::bad_alloc'
Aborted (core dumped)


Even I have tried to use STAR without any threads but still the same error:

> STAR   --runMode genomeGenerate   --genomeDir wheat   --genomeFastaFiles wheat.fa
Jun 04 02:19:44 ..... started STAR run
Jun 04 02:19:44 ... starting to generate Genome files
terminate called after throwing an instance of 'std::bad_alloc'
Aborted (core dumped)


May there can be an issue in reference of wheat that I am using, I got this reference from here. Here are the first ten lines of the reference using head command:

> head wheat.fa
>Pt dna:chromosome chromosome:TGACv1:Pt:1:135835:1 REF
ACAGAAATACCCAATATCTTGTTCTAGCAAGATATTGGGTATTTCTGTCTTTTCTTTCTT
CAAAAATTCTTATATGTTAGCAGAAAAACCTTATCCATTAATAGATGGAACTTCAACAGC
AGCTAAGTCTAGAGGGAAGTTGTGAGCATTACGTTCGTGCATTACTTCCATACCAAGGTT
AGCACGGTTGATGATATCAGCCCAAGTATTAATAACGCGACCTTGACTATCAACTACAGA
TTGGTTGAAATTGAAACCATTTAGGTTGAAAGCCATAGTACTAATACCTAAAGCAGTGAA
CCAGATTCCTACTACAGGCCAAGCAGCCAAGAAGAAGTGTAAAGAACGAGAGTTGTTGAA
ACTAGCATATTGGAAGATTAATCGGCCAAAATAACCATGAGCAGCCACAATATTATAAGT
TTCTTCCTCTTGACCAAATTTGTAACCCTCATTAGCAGATTCATTTTCAGTAGTTTCCCT
GATCAAACTAGAGGTTACCAAGGAACCATGCATAGCACTGAATAGGGAACCGCCGAATAC


How this problem can be resolved?

• Keep an eye on the memory usage and see if you're actually exceeding what's available. May 23 '18 at 9:48
• The memory does not exceeds 1.6 usage that is normal, May 23 '18 at 9:58
• Here is the link to the memory usage May 23 '18 at 10:14
• Try removing the --sjdbGTF... stuff from your command as it's likely there's an issue either with the GFF3 file or the fasta file. May 23 '18 at 11:51

In addition to the other answer (to reduce the number of threads), you might also need to add a --genomeChrBinNbits argument. Your reference has more than 5000 scaffolds, so you need to adjust the --genomeChrBinNbits argument to reduce RAM consumption. Found here.

They recommend:

--genomeChrBinNbits} = min(18, log2(GenomeLength/NumberOfReferences))

Genome size 17G, number of scaffolds 735945

So --genomeChrBinNbits should be set to log2(17,000,000,000/735,945) = 14.4955, so let's say 14 or 15.

• After your command it gave error to increase ram using limitGenomeGenerateRAM, then I increased the ram using limitGenomeGenerateRAM and finally it worked fine, thanks. Jun 4 '18 at 16:13
• @AmmarSabirCheema, I am glad it finally works! Thanks for your feedback.
– benn
Jun 4 '18 at 16:27

Try reducing the number of threads.

When multithreading the index creation (and other memory bound tasks), the memory usage increases linearly with the number of threads. If you required a 10 GiB working space work with a single thread, then the requirement for 10 threads would be at 100 GiB.

STAR is particularly memory hungry for the index creation to start with, and your genome is exceptionally large. I’ve had STAR require > 32 GiB of memory for the human genome, with a moderate number of threads. I’m not surprised that it fails with a 4× larger genome and many more threads: it would probably require at least 2× as much RAM as your machine has.

• Thanks for your answer but it didn't work. Jun 4 '18 at 9:26
• I have again edited my post to add more details to my problem. Jun 4 '18 at 9:27