Debian Codegraph @

help/xtract-examples.txt

raw
1 PUBMED
2
3 Indexed Fields
4
5 einfo -db pubmed |
6 xtract -pattern Field \
7 -if IsDate -equals Y -and IsHidden -equals N \
8 -pfx "[" -sep "]\t" -element Name,FullName |
9 sort -t $'\t' -k 2f
10
11 [CDAT] Date - Completion
12 [CRDT] Date - Create
13 [EDAT] Date - Entrez
14 [MHDA] Date - MeSH
15 [MDAT] Date - Modification
16 [PDAT] Date - Publication
17
18 First Authors
19
20 efetch -db pubmed -id 6271474,5685784,4882854,6243420 -format xml |
21 xtract -pattern PubmedArticle -element MedlineCitation/PMID "#Author" \
22 -block Author -position first -sep " " -element Initials,LastName \
23 -block Article -element ArticleTitle
24
25 6271474 5 MJ Casadaban Tn3: transposition and control.
26 5685784 2 RK Mortimer Suppressors and suppressible mutations in yeast.
27 4882854 2 ED Garber Proteins and enzymes as taxonomic tools.
28 6243420 1 NR Cozzarelli DNA gyrase and the supercoiling of DNA.
29
30 Formatted Authors
31
32 efetch -db pubmed -id 1413997,6301692,781293 -format xml |
33 xtract -pattern PubmedArticle -element MedlineCitation/PMID \
34 -block PubDate -sep "-" -element Year,Month,MedlineDate \
35 -block Author -sep " " -tab "" \
36 -element "&COM" Initials,LastName -COM "(|)" |
37 perl -pe 's/(\t[^\t|]*)\|([^\t|]*)$/$1 and $2/; s/\|([^|]*)$/, and $1/; s/\|/, /g'
38
39 1413997 1992-Oct RK Mortimer, CR Contopoulou, and JS King
40 6301692 1983-Apr MA Krasnow and NR Cozzarelli
41 781293 1976-Jul MJ Casadaban
42
43 PMID in Variable
44
45 efetch -db pubmed -id 3201829,6301692,781293 -format xml |
46 xtract -pattern PubmedArticle -PMID MedlineCitation/PMID \
47 -block Author -element "&PMID" \
48 -sep " " -tab "\n" -element Initials,LastName
49
50 3201829 JR Johnston
51 3201829 CR Contopoulou
52 3201829 RK Mortimer
53 6301692 MA Krasnow
54 6301692 NR Cozzarelli
55 781293 MJ Casadaban
56
57 Medical Subject Headings
58
59 efetch -db pubmed -id 6162838 -format xml |
60 xtract -transform <( echo -e "Y\t*\n" ) \
61 -pattern PubmedArticle -element MedlineCitation/PMID \
62 -block MeshHeading -clr \
63 -subset DescriptorName -plg "\n" -tab "" \
64 -translate "@MajorTopicYN" -element DescriptorName \
65 -subset QualifierName -plg " / " -tab "" \
66 -translate "@MajorTopicYN" -element QualifierName
67
68 6162838
69 Base Sequence
70 *DNA, Recombinant
71 Escherichia coli / genetics
72 ...
73 RNA, Messenger / *genetics
74 Transcription, Genetic
75 beta-Galactosidase / *genetics / metabolism
76
77 Book Authors and Editors
78
79 efetch -db pubmed -id 21433338 -format xml |
80 xtract -pattern PubmedBookArticle \
81 -path BookDocument.AuthorList.Author -element LastName \
82 -path BookDocument.Book.AuthorList.Author -element LastName
83
84 Fauci Desrosiers Coffin Hughes Varmus
85
86 Heterogeneous Data
87
88 efetch -db pubmed -id 21433338,17247418 -format xml |
89 xtract -pattern "PubmedArticleSet/*" \
90 -group "Book/AuthorList" -element LastName \
91 -group "Article/AuthorList" -element LastName
92
93 Coffin Hughes Varmus
94 Lederberg Cavalli Lederberg
95
96 Multiple Links
97
98 esearch -db pubmed -query "conotoxin AND dopamine [MAJR]" |
99 elink -target protein -cmd neighbor |
100 xtract -pattern LinkSet -if Link/Id -element IdList/Id Link/Id
101
102 28666811 17105332 9506485
103 23624852 17105332
104 14657161 27532980 27532978 19424304
105 12944511 31542395 17105332
106
107 Link Counts
108
109 elink -db protein -id NP_000509 -target pubmed |
110 elink -target protein -cmd neighbor |
111 xtract -wrp "Set,Rec" -pattern LinkSet \
112 -wrp "Uid" -element IdList/Id -wrp "Count" -num Link/Id |
113 xtract -pattern Rec -if Count -ge 50 -element Uid Count
114
115 32296183 17997
116 19372376 57
117
118 Markup Correction
119
120 for id in 8475897 8988608 9698410 10194376 15949988 16271163 17282049 \
121 19793852 20968289 21505190 21892341 22106757 22360335 22472775 22785267 \
122 23095895 23095897 25435818 26433210 27672066 28635620 28940123 29547395 \
123 29869631 29869640 29944225
124 do
125 efetch -db pubmed -format xml -id "$id" |
126 xtract -pattern PubmedArticle -plg "\n\n" -sep "\n\n" -tab "\n\n" \
127 -element MedlineCitation/PMID ArticleTitle Abstract/AbstractText
128 done
129
130 XML Normalization
131
132 echo "assembly 443538 Stat biosample 3737421 SampleData gene 5053 Summary medgen 1413 Name" |
133 xargs -n 3 sh -c 'efetch -db "$0" -id "$1" -format docsum |
134 xtract -pattern DocumentSummary -sep " | " -tab " - " -ret "\n\n" -lbl "$0" -element Id "$2"'
135
136 Record Counts
137
138 echo "diphtheria measles pertussis polio tuberculosis" |
139 xargs -n 1 sh -c 'esearch -db pubmed -query "$0 [MESH]" |
140 efilter -days 365 -datetype PDAT |
141 xtract -pattern ENTREZ_DIRECT -lbl "$0" -element Count'
142
143 diphtheria 20
144 measles 213
145 pertussis 69
146 polio 76
147 tuberculosis 1787
148
149 Citation Lookup
150
151 esearch -db pubmed -query "Beadle GW [AUTH] AND Tatum EL [AUTH]" |
152 elink -cited |
153 efilter -days 365 |
154 efetch -format abstract -start 3 -stop 5
155
156 Stopwords and Stemming
157
158 pm=$( efetch -db pubmed -id 2005826 -format xml )
159 echo "$pm" | xtract -pattern PubmedArticle -sep " " -words ArticleTitle
160 echo "$pm" | xtract -stops -pattern PubmedArticle -sep " " -words ArticleTitle
161 echo "$pm" | xtract -stems -pattern PubmedArticle -sep " " -words ArticleTitle
162 echo "$pm" | xtract -stops -stems -pattern PubmedArticle -sep " " -words ArticleTitle
163
164 DOI Extraction
165
166 esearch -db pubmed -query "Rowley JD [AUTH]" |
167 efetch -format xml |
168 xtract -wrp PubmedArticleSet -pattern PubmedArticle -sort MedlineCitation/PMID |
169 xtract -pattern PubmedArticle \
170 -block ArticleId -if @IdType -equals doi \
171 -doi ArticleId |
172 tail -n 25
173
174 Combining Independent Queries
175
176 esearch -db protein -query "amyloid* [PROT]" |
177 elink -target pubmed -label prot_cit |
178 esearch -db gene -query "apo* [GENE]" |
179 elink -target pubmed -label gene_cit |
180 esearch -query "(#prot_cit) AND (#gene_cit)" |
181 efetch -format docsum |
182 xtract -mixed -pattern DocumentSummary -element Id Title |
183 cat -v
184
185 PMC
186
187 Formatting Tag Removal
188
189 efetch -db pmc -id 4729119 -format xml |
190 xtract -mixed -pattern article -group p \
191 -position first -tab "\n\n" -element p -plain p |
192 fold -w 70 -s | awk '{$1=$1};1'
193
194 The intestinal cells of <italic>Caenorhabditis elegans</italic> are
195 filled with heterogeneous granular organelles that are associated
196 with specific organ functions. The best studied of these organelles
197 ...
198
199 The intestinal cells of Caenorhabditis elegans are filled with
200 heterogeneous granular organelles that are associated with specific
201 organ functions. The best studied of these organelles are lipid
202 ...
203
204 SEQUENCE
205
206 Peptide Sequences
207
208 esearch -db protein -query "conotoxin AND mat_peptide [FKEY]" |
209 efetch -format gpc |
210 xtract -insd complete mat_peptide "%peptide" product mol_wt peptide |
211 grep -i conotoxin | sort -t $'\t' -u -k 2,2n | head -n 8
212
213 ADB43131.1 15 conotoxin Cal 1b 1708 LCCKRHHGCHPCGRT
214 ADB43128.1 16 conotoxin Cal 5.1 1829 DPAPCCQHPIETCCRR
215 AIC77105.1 17 conotoxin Lt1.4 1705 GCCSHPACDVNNPDICG
216 ADB43129.1 18 conotoxin Cal 5.2 2008 MIQRSQCCAVKKNCCHVG
217 ADD97803.1 20 conotoxin Cal 1.2 2206 AGCCPTIMYKTGACRTNRCR
218 AIC77085.1 21 conotoxin Bt14.8 2574 NECDNCMRSFCSMIYEKCRLK
219 ADB43125.1 22 conotoxin Cal 14.2 2157 GCPADCPNTCDSSNKCSPGFPG
220 AIC77154.1 23 conotoxin Bt14.19 2578 VREKDCPPHPVPGMHKCVCLKTC
221
222 Vitamin Biosynthesis
223
224 esearch -db pubmed -query "lycopene cyclase" -log |
225 elink -related |
226 elink -target protein |
227 efilter -organism rodents -source refseq |
228 efetch -format docsum |
229 xtract -pattern DocumentSummary -element AccessionVersion Title |
230 grep -i carotene | sort -V
231
232 NP_001346539.1 beta,beta-carotene 9',10'-oxygenase isoform 2 [Mus musculus]
233 NP_573480.1 beta,beta-carotene 9',10'-oxygenase isoform 1 [Mus musculus]
234 NP_446100.2 beta,beta-carotene 15,15'-dioxygenase [Rattus norvegicus]
235 NP_001121184.1 beta,beta-carotene 9',10'-oxygenase [Rattus norvegicus]
236 NP_001156500.1 beta,beta-carotene 15,15'-dioxygenase isoform 2 [Mus musculus]
237 NP_067461.2 beta,beta-carotene 15,15'-dioxygenase isoform 1 [Mus musculus]
238
239 Coding Sequences
240
241 efetch -db nuccore -id J01636.1 -format gbc |
242 xtract -insd CDS gene sub_sequence
243
244 J01636.1 lacI GTGAAACCAGTAACGTTATACGATGTCGCAGAGTATGCCG...
245 J01636.1 lacZ ATGACCATGATTACGGATTCACTGGCCGTCGTTTTACAAC...
246 J01636.1 lacY ATGTACTATTTAAAAAACACAAACTTTTGGATGTTCGGTT...
247 J01636.1 lacA TTGAACATGCCAATGACCGAAAGAATAAGAGCAGGCAAGC...
248
249 Sequence Subregion
250
251 efetch -db nuccore -id U54469 -format gbc |
252 xtract -pattern INSDSeq -nucleic INSDSeq_sequence[2881:1] |
253 fold -w 60
254
255 CCGGTTTTAATGTAGGTTTTTATTAATATACTTTTCCGTCTAATCCATTATTGACAGTGA
256 CTACAAAAAGCGGATAGATTTTATATTATGCCGATTTTTGATAACAAAGGGGGTTCCGTT
257 TCGGTTTCGTTACGCGGGTCTTAGACAATAGTCACGATTAATCGCTACTGTTGCTTATAA
258 ...
259
260 3'UTR Sequences
261
262 #!/bin/bash -norc
263
264 ThreePrimeUTRs() {
265 xtract -pattern INSDSeq -ACC INSDSeq_accession-version -SEQ INSDSeq_sequence \
266 -block INSDFeature -if INSDFeature_key -equals CDS \
267 -pfc "\n" -element "&ACC" -rst -last INSDInterval_to -element "&SEQ" |
268 while read acc pos seq
269 do
270 if [ $pos -lt ${#seq} ]
271 then
272 echo -e ">$acc 3'UTR: $((pos+1))..${#seq}"
273 echo "${seq:$pos}" | fold -w 50
274 elif [ $pos -ge ${#seq} ]
275 then
276 echo -e ">$acc NO 3'UTR"
277 fi
278 done
279 }
280
281 esearch -db nuccore -query "5.5.1.19 [ECNO]" |
282 efilter -molecule mrna -source refseq |
283 efetch -format gbc | ThreePrimeUTRs
284
285 >NM_001328461.1 3'UTR: 1737..1871
286 gatgaatatagagttactgtgttgtaagctaatcatcatactgatgcaag
287 tgcattatcacatttacttctgctgatgattgttcataagattatgagtt
288 agccatttatcaaaaaaaaaaaaaaaaaaaaaaaa
289 >NM_001316759.1 3'UTR: 1628..1690
290 atccgagtaattcggaatcttgtccaattttatatagcctatattaatac
291 ...
292
293 Amino Acid Composition
294
295 #!/bin/bash -norc
296
297 abbrev=( Ala Asx Cys Asp Glu Phe Gly His Ile \
298 Xle Lys Leu Met Asn Pyl Pro Gln Arg \
299 Ser Thr Sec Val Trp Xxx Tyr Glx )
300
301 AminoAcidComp() {
302 local count
303 while read num lttr
304 do
305 idx=$(printf %i "'$lttr'")
306 ofs=$((idx-97))
307 count[$ofs]="$num"
308 done <<< "$1"
309 for i in {0..25}
310 do
311 echo -e "${abbrev[$i]}\t${count[$i]-0}"
312 done |
313 sort
314 }
315
316 AminoAcidJoin() {
317 result=""
318 while read acc seq gene
319 do
320 comp="$(echo "$seq" | tr A-Z a-z | sed 's/[^a-z]//g' | fold -w 1 | sort-uniq-count)"
321 current=$(AminoAcidComp "$comp")
322 current=$(echo -e "GENE\t$gene\n$current")
323 if [ -n "$result" ]
324 then
325 result=$(join -t $'\t' <(echo "$result") <(echo "$current"))
326 else
327 result=$current
328 fi
329 done
330 echo "$result" |
331 grep -e "GENE" -e "[1-9]"
332 }
333
334 ids="NP_001172026,NP_000509,NP_004001,NP_001243779"
335 efetch -db protein -id "$ids" -format gpc |
336 xtract -insd INSDSeq_sequence CDS gene |
337 AminoAcidJoin
338
339 GENE INS HBB DMD TTN
340 Ala 10 15 210 2084
341 Arg 5 3 193 1640
342 Asn 3 6 153 1111
343 Asp 2 7 185 1720
344 Cys 6 2 35 513
345 Gln 7 3 301 942
346 Glu 8 8 379 3193
347 Gly 12 13 104 2066
348 His 2 9 84 478
349 Ile 2 0 165 2062
350 Leu 20 18 438 2117
351 Lys 2 11 282 2943
352 Met 2 2 79 398
353 Phe 3 8 77 908
354 Pro 6 7 130 2517
355 Ser 5 5 239 2463
356 Thr 3 7 194 2546
357 Trp 2 2 67 466
358 Tyr 4 3 61 999
359 Val 6 18 186 3184
360
361 GENE
362
363 Chromosome Assignments
364
365 esearch -db gene -query "calmodulin * [PFN] AND mammalia [ORGN]" |
366 efetch -format docsum |
367 xtract -pattern DocumentSummary \
368 -def "-" -element Id Name MapLocation ScientificName |
369 head -n 30
370
371 801 CALM1 14q32.11 Homo sapiens
372 808 CALM3 19q13.32 Homo sapiens
373 805 CALM2 2p21 Homo sapiens
374 24242 Calm1 6q32 Rattus norvegicus
375 12313 Calm1 12 E Mus musculus
376 326597 CALM - Bos taurus
377 50663 Calm2 6q12 Rattus norvegicus
378 24244 Calm3 1q21 Rattus norvegicus
379 12315 Calm3 7 9.15 cM Mus musculus
380 12314 Calm2 17 E4 Mus musculus
381 617095 CALM1 - Bos taurus
382 396838 CALM3 6 Sus scrofa
383 ...
384
385 Genome Range
386
387 esearch -db gene -query "Homo sapiens [ORGN] AND Y [CHR]" |
388 efilter -status alive | efetch -format docsum |
389 xtract -pattern DocumentSummary -NAME Name -DESC Description \
390 -block GenomicInfoType -if ChrLoc -equals Y \
391 -min ChrStart,ChrStop -element "&NAME" "&DESC" |
392 sort -k 1,1n | cut -f 2- |
393 grep -v pseudogene | grep -v uncharacterized | grep -v '^LOC' |
394 between-two-genes ASMT IL3RA |
395 align-columns -g 4
396
397 IL3RA interleukin 3 receptor subunit alpha
398 SLC25A6 solute carrier family 25 member 6
399 LINC00106 long intergenic non-protein coding RNA 106
400 ASMTL-AS1 ASMTL antisense RNA 1
401 ASMTL acetylserotonin O-methyltransferase-like
402 P2RY8 purinergic receptor P2Y8
403 AKAP17A A-kinase anchoring protein 17A
404 ASMT acetylserotonin O-methyltransferase
405
406 Centromere Position
407
408 nquire -ftp ftp.ncbi.nlm.nih.gov pub/gdp ideogram_9606_GCF_000001305.14_850_V1 |
409 grep acen | cut -f 1,2,6,7 | grep "^X"
410
411 X p 58100001 61000000
412 X q 61000001 63800000
413
414 Gene Regions
415
416 esearch -db gene -query "DDT [GENE] AND mouse [ORGN]" |
417 efetch -format docsum |
418 xtract -pattern GenomicInfoType -element ChrAccVer ChrStart ChrStop |
419 xargs -n 3 sh -c 'efetch -db nuccore -format gb \
420 -id "$0" -chr_start "$1" -chr_stop "$2"'
421
422 LOCUS NC_000076 2142 bp DNA linear CON 09-FEB-2015
423 DEFINITION Mus musculus strain C57BL/6J chromosome 10, GRCm38.p3 C57BL/6J.
424 ACCESSION NC_000076 REGION: complement(75771233..75773374) GPC_000000783
425 VERSION NC_000076.6
426 ...
427 FEATURES Location/Qualifiers
428 source 1..2142
429 /organism="Mus musculus"
430 /mol_type="genomic DNA"
431 /strain="C57BL/6J"
432 /db_xref="taxon:10090"
433 /chromosome="10"
434 gene 1..2142
435 /gene="Ddt"
436 mRNA join(1..159,462..637,1869..2142)
437 /gene="Ddt"
438 /product="D-dopachrome tautomerase"
439 /transcript_id="NM_010027.1"
440 CDS join(52..159,462..637,1869..1941)
441 /gene="Ddt"
442 /codon_start=1
443 /product="D-dopachrome decarboxylase"
444 /protein_id="NP_034157.1"
445 /translation="MPFVELETNLPASRIPAGLENRLCAATATILDKPEDRVSVTIRP
446 GMTLLMNKSTEPCAHLLVSSIGVVGTAEQNRTHSASFFKFLTEELSLDQDRIVIRFFP
447 ...
448
449 Recursive Data
450
451 esearch -db gene -query "rbcL [GENE] AND maize [ORGN]" |
452 efetch -format xml |
453 xtract -pattern Entrezgene -block "**/Gene-commentary" \
454 -if Gene-commentary_type@value -equals genomic \
455 -tab "\n" -element Gene-commentary_accession |
456 sort | uniq
457
458 NC_001666
459 X86563
460 Z11973
461
462 Genes in Pathways
463
464 esearch -db gene -query "PAH [GENE]" -organism human |
465 elink -target biosystems |
466 efilter -pathway wikipathways |
467 elink -target gene |
468 efetch -format docsum |
469 xtract -pattern DocumentSummary -element Name Id Description |
470 grep -v pseudogene | grep -v uncharacterized |
471 sort -f
472
473 AANAT 15 aralkylamine N-acetyltransferase
474 ACADM 34 acyl-CoA dehydrogenase medium chain
475 ACHE 43 acetylcholinesterase (Cartwright blood group)
476 ADCYAP1 116 adenylate cyclase activating polypeptide 1
477 ...
478
479 Gene Products
480
481 for sym in HBB BRCA2 CFTR RAG1
482 do
483 esearch -db gene -query "$sym [GENE] AND human [ORGN]" |
484 efilter -query "alive [PROP]" | efetch -format docsum |
485 xtract -pattern GenomicInfoType \
486 -element ChrAccVer ChrStart ChrStop |
487 while read acc str stp
488 do
489 efetch -db nuccore -format gbc \
490 -id "$acc" -chr_start "$str" -chr_stop "$stp" |
491 xtract -insd CDS,mRNA INSDFeature_key "#INSDInterval" \
492 gene "%transcription" "%translation" \
493 product transcription translation |
494 cut -c 1-250 |
495 grep -i $'\t'"$sym"$'\t'
496 done
497 done
498
499 NC_000011.10 mRNA 3 HBB 626 hemoglobin, beta ACATTTGCTT...
500 NC_000011.10 CDS 3 HBB 147 hemoglobin subunit beta MVHLTPEEKS...
501 NC_000023.11 mRNA 78 DMD 13805 dystrophin, transcript variant X2 AGGAAGATGA...
502 NC_000023.11 mRNA 77 DMD 13794 dystrophin, transcript variant X6 ACTTTCCCCC...
503 NC_000023.11 mRNA 77 DMD 13800 dystrophin, transcript variant X5 ACTTTCCCCC...
504 NC_000023.11 mRNA 77 DMD 13785 dystrophin, transcript variant X7 ACTTTCCCCC...
505 NC_000023.11 mRNA 74 DMD 13593 dystrophin, transcript variant X8 ACTTTCCCCC...
506 NC_000023.11 mRNA 75 DMD 13625 dystrophin, transcript variant X9 ACTTTCCCCC...
507 ...
508
509 Unfiltered Gene Lookup
510
511 for sym in ATP6 ATP7B CBD DMD HFE PAH PRNP TTN
512 do
513 esearch -db gene -query "$sym [GENE]" -organism human |
514 efetch -format docsum |
515 xtract -pattern DocumentSummary -def "-" -lbl "${sym}" \
516 -element NomenclatureSymbol Id Description CommonName
517 done
518
519 ATP6 MT-ATP6 4508 ATP synthase F0 subunit 6 human
520 ATP6 - 6775074 ATP synthase F0 subunit 6 Neandertal
521 ATP6 - 8923188 ATP synthase F0 subunit 6 Denisova hominin
522 CBD OPN1MW 2652 opsin 1, medium wave sensitive human
523 HBB HBB 3043 hemoglobin subunit beta human
524 HBB KRT89P 85344 keratin 89 pseudogene human
525 OPN1MW OPN1MW 2652 opsin 1, medium wave sensitive human
526 OPN1MW OPN1MW3 101060233 opsin 1, medium wave sensitive 3 human
527
528 Protein Coding Genes
529
530 for sym in MT-ATP6 BRCA2 CFTR HBB HFE IL9R OPN1MW PAH
531 do
532 esearch -db gene -query "$sym [PREF]" -organism human |
533 efetch -format docsum |
534 xtract -pattern DocumentSummary -def "-" \
535 -lbl "${sym}" -element Id Chromosome Description
536 done |
537 ...
538
539 MT-ATP6 4508 MT ATP synthase F0 subunit 6
540 BRCA2 675 13 BRCA2 DNA repair associated
541 CFTR 1080 7 CF transmembrane conductance regulator
542 HBB 3043 11 hemoglobin subunit beta
543 HFE 3077 6 homeostatic iron regulator
544 IL9R 3581 X, Y interleukin 9 receptor
545 OPN1MW 2652 X opsin 1, medium wave sensitive
546 PAH 5053 12 phenylalanine hydroxylase
547
548 Common Pathways
549
550 ...
551 while IFS=$'\t' read sym uid chr desc
552 do
553 elink -db gene -id "$uid" -target biosystems |
554 efilter -kind pathway |
555 efetch -format docsum |
556 xtract -pattern DocumentSummary -lbl "${sym}" \
557 -lower source -element externalid biosystemname
558 done |
559 sort -t $'\t' -k 2,2 -k 3,3 -k 1,1 |
560 awk 'a[$3]++{ if(a[$3]==2){ print b }; print $0}; {b=$0}'
561
562 MT-ATP6 kegg hsa01100 Metabolic pathways
563 PAH kegg hsa01100 Metabolic pathways
564 HBB reactome R-HSA-1430728 Metabolism
565 MT-ATP6 reactome R-HSA-1430728 Metabolism
566 PAH reactome R-HSA-1430728 Metabolism
567 CFTR reactome R-HSA-162582 Signal Transduction
568 OPN1MW reactome R-HSA-162582 Signal Transduction
569 ...
570
571 TAXONOMY
572
573 Taxonomic Names
574
575 esearch -db taxonomy -query "txid10090 [SBTR] OR camel [COMN]" |
576 efetch -format docsum |
577 xtract -pattern DocumentSummary -if CommonName \
578 -element Id ScientificName CommonName
579
580 57486 Mus musculus molossinus Japanese wild mouse
581 39442 Mus musculus musculus eastern European house mouse
582 35531 Mus musculus bactrianus southwestern Asian house mouse
583 10092 Mus musculus domesticus western European house mouse
584 10091 Mus musculus castaneus southeastern Asian house mouse
585 10090 Mus musculus house mouse
586 9838 Camelus dromedarius Arabian camel
587 9837 Camelus bactrianus Bactrian camel
588
589 STRUCTURE
590
591 Structural Similarity
592
593 esearch -db structure -query "crotalus [ORGN] AND phospholipase A2" |
594 elink -related |
595 efilter -query "archaea [ORGN]" |
596 efetch -format docsum |
597 xtract -pattern DocumentSummary \
598 -if PdbClass -equals Hydrolase \
599 -element PdbAcc PdbDescr
600
601 3WIV Crystal Structure Of Pro-s324a/d356a
602 3WIU Crystal Structure Of Pro-s324a/l349a
603 3VV2 Crystal Structure Of Complex Form Between S324a-subtilisin And Mutant Tkpro
604 3VHQ Crystal Structure Of The Ca6 Site Mutant Of Pro-Sa-Subtilisin
605 2ZWP Crystal Structure Of Ca3 Site Mutant Of Pro-S324a
606 ...
607
608 SNP
609
610 Amino Acid Substitutions
611
612 esearch -db gene -query "OPN1MW [PREF] AND human [ORGN]" |
613 elink -target snp | efilter -class missense |
614 efetch -format docsum |
615 xtract -rec HGVS -pattern DocumentSummary \
616 -wrp Id -element Id -rst -hgvs DOCSUM |
617 hgvs2spdi |
618 xtract -pattern SPDI -pfx "rs" -RSID Id \
619 -group Variant -if Class -equals Protein -and Type -equals Missense \
620 -element "&RSID" Accession Deleted Inserted Position -deq "\n" |
621 sort-table -k 2,2 -k 5,5n -k 4,4f -k 1.3n | uniq |
622 while read rsid accn del ins ofs
623 do
624 if [ "$accn" != "$last" ]
625 then
626 seq=$( efetch -db protein -id "$accn" -format gpc < /dev/null |
627 xtract -pattern INSDSeq -lower INSDSeq_sequence )
628 last="$accn"
629 fi
630 pos=$((ofs + 1))
631 echo ">$rsid [$accn $ins@$pos]"
632 echo "$seq" |
633 transmute -replace -offset "$ofs" -delete "$del" -insert "$ins" -lower |
634 fold -w 50
635 done
636
637 >rs1238141906 [NP_000504.1 K@41]
638 maqqwslqrlagrhpqdsyedstqssiftytnsnstrgpfKgpnyhiapr
639 wvyhltsvwmifvviasvftnglvlaatmkfkklrhplnwilvnlavadl
640 aetviastisvvnqvygyfvlghpmcvlegytvslcgitglwslaiiswe
641 ...
642
643 Sequences Flanking SNPs
644
645 #!/bin/bash -norc
646
647 efetch -db snp -id 268 -format json |
648 transmute -j2x -set - -rec RS |
649 xtract -pattern RS -pfx "rs" -RSID RS/refsnp_id \
650 -group placements_with_allele \
651 -block allele -if seq_id -starts-with "NC_" \
652 -and inserted_sequence -differs-from deleted_sequence \
653 -element "&RSID" seq_id deleted_sequence \
654 inserted_sequence -tab "\n" -inc position |
655 sort -t $'\t' -k 2,2 -k 5,5n -k 4,4f -k 1.3n | uniq |
656 while read rsid accn del ins pos
657 do
658 lft=$(efetch -db nuccore -format fasta -id "$accn" \
659 -seq_start "$((pos-50))" -seq_stop "$((pos-1))" < /dev/null |
660 grep -v '>' | tr -d '\n')
661
662 ad=${#ins}
663 sb=${#del}
664 rgt=$(efetch -db nuccore -format fasta -id "$accn" \
665 -seq_start "$((pos+ad-sb+1))" -seq_stop "$((pos+ad-sb+50))" < /dev/null |
666 grep -v '>' | tr -d '\n')
667
668 echo "$rsid $accn $pos $del->$ins"
669 echo "5': $lft"
670 echo "3': $rgt"
671 echo ""
672 done
673
674 rs268 NC_000008.10 19813529 A->G
675 5': CTGCTTGAGTTGTAGAAAGAACCGCTGCAACAATCTGGGCTATGAGATCA
676 3': TAAAGTCAGAGCCAAAAGAAGCAGCAAAATGTACCTGAAGACTCGTTCTC
677
678 rs268 NC_000008.11 19956018 A->G
679 5': CTGCTTGAGTTGTAGAAAGAACCGCTGCAACAATCTGGGCTATGAGATCA
680 3': TAAAGTCAGAGCCAAAAGAAGCAGCAAAATGTACCTGAAGACTCGTTCTC
681
682 EXTERNAL
683
684 JSON Nested Array Expansion
685
686 JS=$( nquire -get "http://mygene.info/v3" gene 3043 )
687 echo "$JS" | transmute -j2p | grep '"position":' -A 14 | head -n 15
688 for ns in flat recurse plural depth element
689 do
690 echo
691 echo " $ns"
692 echo
693 echo "$JS" |
694 transmute -j2x -nest "$ns" |
695 grep position | head -n 4
696 done
697
698 "position": [
699 [
700 5225463,
701 5225726
702 ],
703 [
704 5226576,
705 5226799
706 ],
707 [
708 5226929,
709 5227071
710 ]
711 ],
712 "strand": -1,
713
714 flat
715
716 <position>5225463</position>
717 <position>5225726</position>
718 <position>5226576</position>
719 <position>5226799</position>
720
721 recurse
722
723 <position>
724 <position>5225463</position>
725 <position>5225726</position>
726 </position>
727
728 plural
729
730 <positions>
731 <position>5225463</position>
732 <position>5225726</position>
733 </positions>
734
735 depth
736
737 <position>
738 <position_1>5225463</position_1>
739 <position_1>5225726</position_1>
740 </position>
741
742 element
743
744 <position>
745 <position_E>5225463</position_E>
746 <position_E>5225726</position_E>
747 </position>
748
749 Exon Interval Sets
750
751 nquire -get "http://mygene.info/v3/gene/2652" |
752 transmute -j2x -set - -rec GeneRec -nest plural |
753 xtract -pattern GeneRec -group exons -lbl "" -clr \
754 -block positions -pfc "\n" -sep ".." -tab "\n" -element position
755
756 154182595..154182789
757 154187769..154188066
758 154190053..154190222
759 154191687..154191853
760 154193407..154193647
761 154195929..154196861
762
763 154219733..154219927
764 154224907..154225204
765 ...
766
767 Heterogeneous Object Names
768
769 nquire -get "http://mygene.info/v3/gene/2652" |
770 xtract -pattern opt -group "pathway/*" -deq "\n" -element "?,name,id"
771
772 <pathway>
773 <reactome>
774 <id>R-HSA-162582</id>
775 <name>Signal Transduction</name>
776 </reactome>
777 ...
778 <wikipathways>
779 <id>WP455</id>
780 <name>GPCRs, Class A Rhodopsin-like</name>
781 </wikipathways>
782 </pathway>
783
784 reactome Signal Transduction R-HSA-162582
785 reactome Disease R-HSA-1643685
786 reactome The retinoid cycle in cones (daylight vision) R-HSA-2187335
787 reactome Visual phototransduction R-HSA-2187338
788 reactome Retinoid cycle disease events R-HSA-2453864
789 reactome Diseases associated with visual transduction R-HSA-2474795
790 reactome Signaling by GPCR R-HSA-372790
791 reactome Class A/1 (Rhodopsin-like receptors) R-HSA-373076
792 reactome GPCR downstream signalling R-HSA-388396
793 reactome G alpha (i) signalling events R-HSA-418594
794 reactome Opsins R-HSA-419771
795 reactome GPCR ligand binding R-HSA-500792
796 reactome Diseases of signal transduction R-HSA-5663202
797 wikipathways GPCRs, Class A Rhodopsin-like WP455
798
799 XML Namespace Prefixes
800
801 nquire -url "http://webservice.wikipathways.org" getPathway -pwId WP455 |
802 xtract -pattern "ns1:getPathwayResponse" -decode ":gpml" |
803 xtract -pattern Pathway -block Xref \
804 -if @Database -equals "Entrez Gene" \
805 -tab "\n" -element @ID |
806 sort -n
807
808 134
809 135
810 136
811 140
812 146
813 ...
814
815 LOCAL ARCHIVE
816
817 Entrez Indexing
818
819 efetch -db pubmed -id 12857958,2981625 -format xml |
820 rchive -e2index |
821 xtract -pattern IdxDocument -UID IdxUid \
822 -block TIAB -pfc "\n" -element "&UID",TIAB,"@pos"
823
824 12857958 allow 205
825 12857958 assays 147
826 12857958 binding 146
827 12857958 braid 187,215
828 12857958 braiding 153
829 ...
830
831 Author Frequency
832
833 esearch -db pubmed -query "rattlesnake phospholipase" |
834 efetch -format uid | fetch-pubmed |
835 xtract -pattern PubmedArticle -block Author \
836 -sep " " -tab "\n" -element LastName,Initials |
837 sort-uniq-count-rank
838
839 40 Marangoni S
840 33 Toyama MH
841 28 Soares AM
842 25 Bon C
843 ...
844
845 Author Counts
846
847 esearch -db pubmed -query "conotoxin" |
848 efetch -format uid | fetch-pubmed |
849 xtract -pattern PubmedArticle -num Author |
850 sort-uniq-count -n |
851 reorder-columns 2 1 |
852 head -n 15 |
853 tee /dev/tty |
854 xy-plot auth.png
855
856 0 11
857 1 193
858 2 854
859 3 844
860 4 699
861 5 588
862 6 439
863 7 291
864 8 187
865 9 124
866 10 122
867 11 58
868 12 33
869 13 18
870
871 900 +
872 | ********
873 800 + * **
874 | * *
875 700 + * ***
876 | * **
877 600 + * *
878 | * ***
879 500 + * **
880 | * ***
881 400 + * **
882 | * *
883 300 + * ***
884 | * *
885 200 + * ******
886 | * *********
887 100 + ** *
888 | * **********
889 0 + * ******
890 +---------+---------+---------+---------+---------+---------+---------+
891 0 2 4 6 8 10 12 14
892
893 Title and Abstract Word Counts
894
895 esearch -db pubmed -query "conotoxin" -pub structured |
896 efetch -format uid | fetch-pubmed |
897 xtract -stops -wrp "Set,Rec" \
898 -pattern PubmedArticle -wrp "PMID" -element MedlineCitation/PMID \
899 -wrp "Titl" -words ArticleTitle \
900 -block Abstract/AbstractText -wrp "Grp,Abst" -words AbstractText |
901 xtract -pattern Rec -element PMID -num Titl -block Grp -tab ", " -num Abst
902
903 29194563 21 63, 84, 89, 26
904 28882644 23 87, 34, 115, 25
905 28877214 10 12, 42, 315, 94
906 28825343 15 169
907 28482835 9 75, 123, 42, 37
908 28479398 15 170, 130
909 ...
910
911 Verbosity Per Year
912
913 esearch -db pubmed -query "PNAS [JOUR]" -pub abstract |
914 efetch -format uid | stream-pubmed | gunzip -c |
915 xtract -stops -wrp Set,Rec -pattern PubmedArticle \
916 -wrp "Year" -year "PubDate/*" \
917 -wrp "Abst" -words Abstract/AbstractText |
918 xtract -wrp Set,Pub -pattern Rec \
919 -wrp "Year" -element Year \
920 -wrp "Num" -num Abst > countsByYear.xml
921 for yr in {1960..2020}
922 do
923 cat countsByYear.xml |
924 xtract -wrp Raw -pattern Pub -select Year -eq "$yr" |
925 xtract -pattern Raw -lbl "$yr" -avg Num
926 done |
927 tee /dev/tty |
928 xy-plot verbosity.png
929 rm countsByYear.xml
930
931 Appending Metadata
932
933 esearch -db pubmed -query "PNAS [JOUR]" -pub abstract |
934 efetch -format uid | fetch-pubmed > pnas.xml
935
936 cat pnas.xml |
937 xtract -stops -wrp Set,Rec -pattern PubmedArticle \
938 -wrp ID -element MedlineCitation/PMID \
939 -wrp Abst -words Abstract/AbstractText |
940
941 <Set>
942 <Rec><ID>31822623</ID> <Abst>foxp3</Abst><Abst>cd4</Abst><Abst>regulatory...</Abst></Rec>
943 ...
944
945 xtract -pattern Rec -element ID -wrp Num -num Abst > counts.txt
946
947 31822623 <Num>243</Num>
948 31822622 <Num>132</Num>
949 31822621 <Num>252</Num>
950 31822620 <Num>238</Num>
951 ...
952
953 xtract -input pnas.xml -wrp PubmedArticleSet -pattern PubmedArticle \
954 -select MedlineCitation/PMID -appending counts.txt > merged.xml
955
956 LOCAL INDEX
957
958 Histogram Shortcut
959
960 cat $EDIRECT_PUBMED_MASTER/Current/*.xml |
961 xtract -timer -pattern PubmedArticle -histogram PubDate/Month
962
963 26 8
964 37 9
965 121475 01
966 114579 02
967 111137 03
968 109794 04
969 120169 05
970 130062 06
971 125107 07
972 126246 08
973 123191 09
974 120957 10
975 109657 11
976 110854 12
977 1958892 Apr
978 1809730 Aug
979 2086169 Dec
980 1844717 Feb
981 1851803 Jan
982 1784258 Jul
983 2015942 Jun
984 1943325 Mar
985 1815691 May
986 1889194 Nov
987 2035632 Oct
988 1 October
989 1956569 Sep
990
991 Month Format Per Year
992
993 cat $EDIRECT_PUBMED_MASTER/Current/*.xml |
994 xtract -wrp Set,Rec -pattern PubmedArticle \
995 -if PubDate/Month -wrp YR -year "PubDate/*" -wrp MN -len PubDate/Month |
996 xtract -wrp Set,Rec -pattern Rec \
997 -pfx "<DT>" -sep "+-" -sfx "-</DT>" -element YR,MN |
998 xtract -pattern Rec -histogram DT |
999 reorder-columns 2 1 | tr '+' '\t' |
1000 sed -e 's/-3-/1/g' -e 's/-2-/2/g' -e 's/-1-/3/g' -e 's/-[0-9]-/4/g' |
1001 sort -k 1,1n -k 2,2n > rawMonthCounts.txt
1002
1003 result=$( cat rawMonthCounts.txt | cut -f 1 | uniq )
1004 for i in {1..4}
1005 do
1006 current=$( cat rawMonthCounts.txt | grep "\t$i\t" | cut -f 1,3 )
1007 result=$(join -a 1 -t $'\t' <(echo "$result") <(echo "$current"))
1008 done
1009 echo "$result" > plotme.txt
1010
1011 cat plotme.txt | xy-plot
1012
1013 Phrase Query Automation
1014
1015 ascend_mesh_tree() {
1016 var="${1%\*}"
1017 target=""
1018 ev=$( rchive -local pubmed )
1019 if [ -n "$ev" ]
1020 then
1021 # only care about master volume and its Data subfolder
1022 target="${ev%:*}"
1023 target=${target%/}
1024 fi
1025 while :
1026 do
1027 frst=$( phrase-search -count "$var* [TREE]" )
1028 scnd=$( cat "${target}/Data/meshconv.xml" |
1029 xtract -pattern Rec -if Tree -equals "$var" -first Code Name )
1030 printf "${frst}\t${scnd}\n"
1031 case "$var" in
1032 *.* ) var="${var%????}" ;;
1033 * ) break ;;
1034 esac
1035 done |
1036 align-columns -g 4
1037 }
1038
1039 ascend_mesh_tree "C01.925.782.417.415"
1040
1041 5598 c01 925 782 417 415*
1042 28400 c01 925 782 417*
1043 658188 c01 925 782*
1044 928201 c01 925*
1045 2639368 c01*
1046
1047 Medical Subject Heading Code Viewers
1048
1049 https://meshb.nlm.nih.gov/treeView
1050 https://meshb-prev.nlm.nih.gov/treeView
1051
1052 MISCELLANEOUS
1053
1054 Index Classification
1055
1056 efetch -db pubmed -id 2539356 -format xml |
1057 xtract -aliases <( echo -e "transposition\tFILT:tnp\nimmunity\tFILT:imm\n" ) \
1058 -set IdxDocumentSet -rec IdxDocument -pattern PubmedArticle \
1059 -wrp IdxUid -element MedlineCitation/PMID -clr -rst -tab "" \
1060 -group PubmedArticle -pkg IdxSearchFields \
1061 -block Abstract -classify AbstractText |
1062 transmute -format
1063
1064 Underscore Protection
1065
1066 esearch -db biosample -query "package metagenome or environmental version 1 0 [PROP]" |
1067 xtract -pattern ENTREZ_DIRECT -element Count
1068
1069 esearch -db assembly -query "algae [ORGN] AND complete genome [FILT]" |
1070 efilter -query "refseq has annotation [PROP] NOT anomalous [FILT]" |
1071 xtract -pattern ENTREZ_DIRECT -element Count
1072
1073 Mitochondrial Mistranslation
1074
1075 efetch -db nuccore -id NC_012920 -format gb |
1076 transmute -g2x |
1077 xtract -insd CDS gene product protein_id translation sub_sequence |
1078 while IFS=$'\t' read acc gene prod prid prot seq
1079 do
1080 mito=$( echo "$seq" | transmute -cds2prot -code 2 -stop )
1081 norm=$( echo "$seq" | transmute -cds2prot -code 1 -stop )
1082 if [ "$mito" != "$norm" ]
1083 then
1084 echo ">$acc $gene $prid $prod"
1085 transmute -diff <( echo "$mito" ) <( echo "$norm" )
1086 echo ""
1087 fi
1088 done
1089
1090 Variation Extraction
1091
1092 echo "NP_000504.1:p.Glu41Lys,NP_000504.1:p.P43Leu,NP_000504.1:p.Trp142Ter" |
1093 transmute -hgvs | transmute -format
1094
1095 Pseudocode Prototype
1096
1097 for each PubmedArticle {
1098 for each Author {
1099 print Initials LastName
1100 }
1101 for each MeshHeading {
1102 print DescriptorName
1103 for each QualifierName {
1104 print QualifierName
1105 }
1106 }
1107 }
1108
1109 xtract -pattern PubmedArticle \
1110 -block Author -element Initials LastName \
1111 -block MeshHeading -element DescriptorName \
1112 -subset QualifierName -element QualifierName
1113
1114 Processing in Groups
1115
1116 ...
1117 efetch -format acc |
1118 join-into-groups-of 200 |
1119 xargs -n 1 sh -c 'epost -db nuccore -format acc -id "$0" |
1120 efetch -format gb'