mysql query output
2
1
Entering edit mode
6.3 years ago
kani.kanchan ▴ 10

Hi Everyone,

I am trying to run a mysql query and save output into a text file. The command works fine for 10 SNPs and the output file has entries for all 10 SNPs, however when I try to run the same for large list (100 K) of SNPs the output file only contains the entry for the last SNP only.

My command -

for i in $(cat /path/to/directory/listofSNPs.txt); do echo "select chrom,chromStart+1,name,alleles from snp150 where (name= \"$i\")" | mysql -N --user=genome --host=genome-mysql.cse.ucsc.edu -A -P 3306 -D hg38 done > '/path/to/directory/output.txt'

I would appreciate any advice on how can I do this?

Thanks, Kanika

SNP • 1.1k views
ADD COMMENT
1
Entering edit mode

, however when I try to run the same for large list (100 K) of SNPs

why don't you use A: Need help with getting chromosomal positions of SNPs (your previous question...)

ADD REPLY
0
Entering edit mode

I tried to run this command for some SNPs and the code works well. But when I ran it for larger list it run indefinitely.

ADD REPLY
0
Entering edit mode

If you have 100K queries then you need to account for that number. Surely your patience ran out before the queries completed.

ADD REPLY
3
Entering edit mode
6.3 years ago

faster:

awk '{printf("select chrom,chromStart+1,name,alleles from snp150 where name= \"%s\";\n",$1);}' listofSNPs.txt | \
mysql -N --user=genome --host=genome-mysql.cse.ucsc.edu -A -P 3306 -D hg38 > /path/to/directory/output.txt
ADD COMMENT
3
Entering edit mode
6.3 years ago
GenoMax 148k

Use append which is designated by >> instead of a single > when writing the file out.

ADD COMMENT

Login before adding your answer.

Traffic: 1165 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6