jeudi 25 juin 2020

postgresql query to generate 5 random DNA sequences that are each about 20 bases, and show the count of each base (A, C, G, T)

query to generate 5 random DNA sequences that are each about 20 bases, and show the count of each base (A, C, G, T). enter image description here

so far I got the query in the bottom which generated the table blow, but its missing the count for the per base as well as the rest of the rows prepare dna_length(int) as with t1 as (select chr(65) as s union select chr(67) union select chr(71) union select chr(84) ) , t2 as ( select s, row_number() over() as rn from t1) , t3 as ( select generate_series(1,$1) as i,round(random() * 4 + 0.5) as rn ) , t4 as ( select t2.s from t2 join t3 on (t2.rn=t3.rn)) select array_to_string(array(select s from t4),'') as dna ; enter image description here




Aucun commentaire:

Enregistrer un commentaire