I'm using efetch to dig out a middle "envelope" protein within a viral genome specifically within fasta format. The code below works but may not be robust for an entire database. Thus I want to replace the two "perl" lines with formal code within the Entrez package. I tried using efilter -query
but couldn't get it to work. Genome positions are one approach but are not absolute from one virus to another. Rewriting this may be the best option.
ncbi2=NC_002021
efetch -db protein -format gpc -id "$ncbi2" |\
xtract -pattern INSDSeq -element INSDQualifier_value |\
perl -p -e 's/^(.+?)\s+taxon.*.*\s+\b([A-Z]{300}[A-Z]+).*/>$1\n$2/'|\
perl -p -e "s/[\t \;\/]+/_/g"
Output
>InfluenzaAvirus_A_PuertoRico_8_1934
MDVNPTLLFLKVPAQNAISTTFPYTGD.....
I will provide a more detailed explanation shortly. Any ideas welcome.
| perl -pe 's/^(.+?)\s+taxon.*envelope protein.*\s+\b([A-Z]{300}[A-Z]+).*nonstructural protein 1.*/>$1\n$2/; s/[\t ;\/]+/_/g
. There's no need to process the file twice and you also don't need to escape the;
inside a character class. $\endgroup$efetch -db protein -format gpc -id "$ncbi2" | xtract -pattern INSDSeq_feature-table -group INSDFeature -if INSDFeature_key -equals 'mat_peptide' -tab '\n' -element INSDFeature_location,INSDQualifier_value | grep 'envelope'
$\endgroup$