Entering edit mode
3.6 years ago
marongiu.luigi
▴
730
Hello
I am using ensembl to extract taxonomic data of some sequences. I tried to save the output into a bash variable with three columns and then extract the three columns afterwards:
hit=$(efetch -db taxonomy -id $tax -format native -mode xml | xtract -pattern TaxaSet -element ScientificName | head -1 | cut -f 1,3,7)
fam=$(echo $hit | awk '{print $(NF)})
kin=$(echo $hit | awk '{print $(NF-1)})
but fam and kin are empty. This thing works by running xtract each time:
hit=$(efetch -db taxonomy -id $tax -format native -mode xml | xtract -pattern TaxaSet -element ScientificName | head -1 | cut -f 1)
fam=$(efetch -db taxonomy -id $tax -format native -mode xml | xtract -pattern TaxaSet -element ScientificName | head -1 | cut -f 3)
kin=$(efetch -db taxonomy -id $tax -format native -mode xml | xtract -pattern TaxaSet -element ScientificName | head -1 | cut -f 7)
Is there a way to export efetch/xtract in comma-delimited so cutting the results is easier?
Thank you