Fix for NULL feature.gene_order


Due to import hiccups, the gene_order field in the features table could be set to null.


To detect and assess the problem for a specific project, here is the SQL query in the MySQL console:

SELECT, count( FROM organisms o JOIN features f ON JOIN organisms_projects op ON JOIN projects p ON op.project_id = WHERE[PROJECT_ID] AND f.gene_order IS NULL GROUP BY;

To assess such a problem site wide:

SELECT, count( FROM features f JOIN organisms o ON = f.organism_id WHERE f.gene_order IS NULL GROUP BY;


Once you have identify the problem organisms. Get the list of organism ids in comma separated format, and then you can update the gene_order with the following SQL query by replacing [ORGANISM_IDS], ex: 1,2,3,4:
Update features f, (
SELECT @rn:= (IF(@prev_contig=t1.contig_id, @rn+1, 1)) AS row_num,,, AS contig_name,
@prev_contig := t1.contig_id
FROM (features t1, (SELECT @rn:=0) t2, (SELECT @prev_contig := '') t3)
INNER JOIN contigs c ON = t1.contig_id
WHERE t1.organism_id in ([ORGANISM_IDS])
ORDER BY t1.contig_id, t1.`from`
) AS f2
SET f.gene_order = f2.row_num