XTRACT(1)
๐ XTRACT(1) ๐
NCBI Entrez Direct User's Manual
๐ธ NAME ๐ธ
xtract โ NCBI Entrez Direct XML conversion and transformation tool. bestie, it is literally the XML-to-table glow-up station. ๐
๐ SYNOPSIS ๐
okay so here is the whole command-line vibe, no cap:
xtract [-help] [-strict] [-mixed] [-self] [-accent] [-ascii] [-compress]
[-stops] [-input filename] [-transform filename] [-aliases filename]
[-pattern expr] [-group expr] [-block expr] [-subset expr] [-path path]
[-if expr [constraint]] [-unless expr [constraint]] [-and condition]
[-or condition] [-else] [-position pos] [-equals str]
[-contains str] [-mimics str] [-excludes str] [-includes str]
[-is-within str] [-starts-with str] [-ends-with str] [-is-not str]
[-is-before str] [-is-after str] [-consists-of str] [-matches str]
[-resembles str] [-is-equal-to expr] [-differs-from expr] [-gt N] [-ge N]
[-lt N] [-le N] [-eq N] [-ne N] [-ret str] [-tab str] [-sep str]
[-pfx str] [-sfx str] [-rst] [-clr] [-pfc str] [-deq str] [-def str]
[-lbl str] [-set tag] [-rec tag] [-wrp tag] [-enc tag] [-plg str]
[-elg str] [-pkg tag] [-fwd str] [-awd str] [-tag tag] [-att key str]
[-atr key element] [-cls] [-slf] [-end tag] [-bkt] [-element element]
[-first element] [-last element] [-first element] [-last element]
[-backward element] [-NAME] [--STATS] [-num element] [-len element]
[-sum element] [-acc element] [-min element] [-max element] [-inc element]
[-dec element] [-sub element] [-avg element] [-dev element] [-med element]
[-mul element] [-div element] [-mod element] [-geo element] [-hrm element]
[-rms element] [-sqt element] [-lge element] [-lg2 element] [-log element]
[-bin element] [-oct element] [-hex element] [-bit element] [-pad element]
[-encode element] [-decode element] [-upper element] [-lower element]
[-chain element] [-title element] [-mirror element] [-alpha element]
[-alnum element] [-basic element] [-plain element] [-simple element]
[-author element] [-journal element] [-prose element] [-terms element]
[-words element] [-pairs element] [-split element -with str]
[-order element] [-reverse element] [-letters element] [-clauses element]
[-pentamers element] [-year element] [-month element] [-date element]
[-page element] [-auth element] [-initials element] [-trim element]
[-wct element] [-doi element] [-accession element] [-numeric element]
[-translate element] [-classify element] [-replace
-reg target -exp replacement] [-fasta] [-revcomp] [-nucleic] [-ncbi2na]
[-ncbi4na] [-cds2prot [-gcode N] [-frame N]] [-molwt] [-molwt-m]
[-molwt-f] [-pept] [-0-based element] [-1-based element]
[-ucsc-based element] [-insd arg ...] [-insdx] [-histogram]
[-indexer element] [-head str] [-tail str] [-hd str] [-tl str]
[-select condition] [-in filename] [-sort[-fwd] element]
[-sort-rev element] [-format fmt [-unicode style]] [-verify] [-test]
[-outline] [-synopsis] [-contour [delimiter]] [-examples] [-unix]
[-version]
๐ DESCRIPTION ๐
xtract converts an XML document into a table of data values according to user-specified rules. that is the whole assignment, bestie. iconic behavior only. โจ
๐ OPTIONS ๐
โจ Processing Flags โจ
-strictโ Remove HTML and MathML tags. ๐งผ-mixedโ Allow mixed content XML. ๐-selfโ Allow detection of empty self-closing tags. ๐ช-accentโ Delete Unicode accents and diacritical marks. ๐-asciiโ Convert Unicode to numeric HTML character entities. ๐ข-compressโ Compress runs of spaces. ๐ซง-stopsโ Retain stop words in selected phrases. ๐
๐ Data Source ๐
-input filenameโ Read XML from file instead of standard input. ๐ฅ-transform filenameโ File of substitutions for-translate. ๐-aliases filenameโ Mappings file for-classifyoperation. ๐๏ธ
๐งญ Exploration Argument Hierarchy ๐งญ
-pattern exprโ Name of record within set. Use of different argument names allows command-line control of nested looping. ๐ช-group exprโ Name of record within set. Use of different argument names allows command-line control of nested looping. ๐ช-block exprโ Name of record within set. Use of different argument names allows command-line control of nested looping. ๐ช-subset exprโ Name of record within set. Use of different argument names allows command-line control of nested looping. ๐ช
๐ค๏ธ Path Navigation ๐ค๏ธ
-path pathโ Explore by list of adjacent object names. ๐งญ
๐งช Exploration Constructs ๐งช
- Object โ
DateRevised - Parent/Child โ
Book/AuthorList - Path โ
MedlineCitation/Article/Journal/JournalIssue/PubDate - Heterogeneous โ
"PubmedArticleSet/*" - Exhaustive โ
"History/**" - Nested โ
"*/Taxon"
๐ฆ Conditional Execution ๐ฆ
-if expr [constraint]โ Element (or@attribute) must exist and satisfy any specified constraint. โ-unless expr [constraint]โ Skip if element matches. ๐ซ-and conditionโ Preceding and following tests must both pass. ๐ค-or conditionโ Any passing test suffices. ๐ฏ-elseโ Execute if conditional test failed. โฉ๏ธ-position posโfirst/last/outer/inner/even/odd/all. ๐
๐ค String Constraints ๐ค
-equals strโ String must match exactly. ๐ฏ-contains strโ Substring must be present. ๐-mimics strโ Containment test after converting punctuation to space. ๐ญ-excludes strโ Substring must be absent. ๐ซ-includes strโ Substring must match at word boundaries. ๐งฑ-is-within strโ String must be present. ๐-starts-with strโ Substring must be at beginning. ๐-ends-with strโ Substring must be at end. ๐-is-not strโ String must not match. ๐-is-before strโ First string<second string. โช-is-after strโ First string>second string. โฉ-consists-of strโ String must only contain specified characters. ๐งฉ-matches strโ Matches without commas or semicolons. โ๏ธ-resembles strโ Requires all words, but in any order. ๐
๐งฉ Object Constraints ๐งฉ
-is-equal-to exprโ Object values must match. ๐ฐ-differs-from exprโ Object values must differ. โ๏ธ
๐ข Numeric Constraints ๐ข
-gt Nโ Greater than. โฌ๏ธ-ge Nโ Greater than or equal to. โซ-lt Nโ Less than to. โฌ๏ธ-le Nโ Less than or equal to. โฌ-eq Nโ Equal to. ๐ฐ-ne Nโ Not equal to. ๐ซ
๐จ Format Customization ๐จ
-ret strโ Override line break between patterns. โฉ๏ธ-tab strโ Replace tab character between fields. ๐-sep strโ Separator between group members. โ-pfx strโ Prefix to print before group. ๐-sfx strโ Suffix to print after group. ๐-rstโ Reset-septhrough-elg. ๐-clrโ Clear queued tab separator. ๐งฝ-pfc strโ Preface combines-clrand-pfx. ๐งฌ-deq strโ Delete and replace queued tab separator. ๐-def strโ Default placeholder for missing fields. ๐ซฅ-lbl strโ Insert arbitrary text. โ๏ธ
๐ท๏ธ XML Generation ๐ท๏ธ
-set tagโ XML tag for entire set. ๐งบ-rec tagโ XML tag for each record. ๐ซ-wrp tagโ Wrap elements in XML object. ๐-enc tagโ Encase instance in XML object. ๐ฆ-plg strโ Prologue to print before instance. ๐ฌ-elg strโ Epilogue to print after instance. ๐ฌ-pkg tagโ Package subset in XML object. ๐ฆ-fwd strโ Foreword to print before subset. โฎ๏ธ-awd strโ Afterword to print after subset. โญ๏ธ
๐ Tag and Attribute Construction ๐
-tag tagโ Start with<tag. ๐-att key strโ Attribute key and literal string. ๐-att key elementโ Attribute key and element name. ๐-clsโ Close with>. ๐-slfโ Self-close with/>. ๐ช-end tagโ End contents with</tag>. ๐
๐งฌ FASTA Parsable Fields ๐งฌ
-bktโ Wrap elements in bracketed fields. ๐งซ
๐ฏ Element Selection ๐ฏ
-element elementโ Print all items that match tag name. ๐จ๏ธ-first elementโ Only print value of first item. ๐ฅ-last elementโ Only print value of last item. ๐ฅ-even elementโ Only print value of even items. 2๏ธโฃ-odd elementโ Only print value of odd items. 1๏ธโฃ-backward elementโ Print values in reverse order. ๐-NAMEโ Record value in named variable. ๐ท๏ธ--STATSโ Accumulate values into variable. ๐
๐งฑ -element Constructs ๐งฑ
- Tag โ
Caption - Group โ
Initials,LastName - Parent/Child โ
MedlineCitation/PMID - Recursive โ
"**/Gene-commentary_accession" - Unrestricted โ
PubDate/* - Attribute โ
DescriptorName@MajorTopicYN - Range โ
MedlineDate[1:4] - Substring โ
"Title[phospholipase | rattlesnake]" - Alternative โ
"[can contain ^ vertical bar]" - Object Count โ
#Author - Item Length โ
%Title - Element Depth โ
^PMID - Variable โ
"&NAME"
๐ช Special -element Operations ๐ช
- Parent Index โ
+ - Object Name โ
? - Object Value โ
~ - XML Subtree โ
* - Children โ
$ - Attributes โ
@ - ASN.1 Record โ
. - JSON Record โ
%
โ Numeric (Integer) Processing โ
-num elementโ Count. ๐ข-len elementโ Length. ๐-sum elementโ Sum. โ-acc elementโ Accumulator. ๐งฎ-min elementโ Minimum. ๐ฝ-max elementโ Maximum. ๐ผ-inc elementโ Increment. โซ-dec elementโ Decrement. โฌ-sub elementโ Difference. โ-avg elementโ Arithmetic mean. โ๏ธ-dev elementโ Deviation. ๐-med elementโ Median. ๐ฏ-mul elementโ Product. โ๏ธ-div elementโ Quotient. โ-mod elementโ Remainder. ๐งฉ-geo elementโ Geometric mean. ๐-hrm elementโ Harmonic mean. ๐ต-rms elementโ Root mean square. ๐งฎ-sqt elementโ Square root. โ-lge elementโ Natural logarithm. ๐ฟ-lg2 elementโ Logarithm base two. 2๏ธโฃ-log elementโ Logarithm base ten. ๐-bin elementโ Binary. 0๏ธโฃ1๏ธโฃ-oct elementโ Octal. 8๏ธโฃ-hex elementโ Hexadecimal. ๐ข-bit elementโ Number of bits set. ๐งฎ
0๏ธโฃ Leading Zero Padding 0๏ธโฃ
-pad elementโ Zero-pad to eight digits. 0๏ธโฃ0๏ธโฃ0๏ธโฃ0๏ธโฃ0๏ธโฃ0๏ธโฃ0๏ธโฃ0๏ธโฃ
๐ก Character Processing ๐ก
-encode elementโ XML-encode<,>,&,", and'characters. ๐-decode elementโ Base64-decode object embedded in XML. ๐-upper elementโ Convert text to uppercase. ๐-lower elementโ Convert text to lowercase. ๐ก-chain elementโ Change spaces to underscores. ๐-title elementโ Capitalize initial letters of words. ๐-mirror elementโ Reverse order of letters. ๐ช-alnum elementโ Non-alphabetic characters to space. ๐ค-alnum elementโ Non-alphanumeric characters to space. ๐ค
bestie, yes, -alnum shows up twice in the original manpage. we respect the lore. ๐
๐ String Processing ๐
-basic elementโ Convert superscripts and subscripts. ๐ข-plain elementโ Remove embedded mixed-content markup tags. ๐งฝ-simple elementโ Normalize accented letters; spell Greek letters. ๐ฌ๐ท-author elementโ Multi-step author cleanup. โ๏ธ-jour elementโ Journal capitalization and punctuation punctuation. ๐-prose elementโ Text conversion to ASCII. ๐ค
๐ Text Processing ๐
-terms elementโ Partition text at spaces. โ๏ธ-words elementโ Split at punctuation marks. ๐ค-pairs elementโ Adjacent informative words. ๐ฏ-split elementโ Split using-withfor delimiter. ๐ช-order elementโ Rearrange words in sorted order. ๐ค-reverse elementโ Reverse words in string. ๐-letters elementโ Separate individual letters. ๐ก-clauses elementโ Break at phrase separators. โ๏ธ-pentamers elementโ Sliding window of pentamers. 5๏ธโฃ
๐ Citation Functions ๐
-year elementโ Extract first 4-digit year from string. ๐-month elementโ Match first month name and return a corresponding integer. ๐๏ธ-date elementโYYYY/MM/DDfrom-unit "PubDate" -date "*"๐-page elementโ Get digits (and letters) of first page number. ๐-auth elementโ Change GenBank authors to Medline form. โ๏ธ-initials elementโ Parse initials from forename or given name. ๐ค-trimelement โ strips out the extra spaces and the leading zeros. glow-up for your strings โจ-wctelement โ counts how many-wordsare in a string. counting era ๐-doielement โ slaps thehttps://doi.org/prefix on there and URL encodes it. iconic.-accessionelement โ lets you index the fullaccession.version. no cap.-numericelement โ only accepts items that are entirely digits. nothing else gets in, periodt.
๐ธ Value Transformation ๐ธ
-translateelement โ swaps values out using the-transformtable.-classifyelement โ matches substrings (word or phrase) against the-aliasestable.
๐ Regular Expression ๐
-replaceโ substitutes text using regular expressions. regex girlies rise ๐ซถ-regtarget โ the target expression.-exppattern โ the replacement pattern.
๐ฆ Sequence Processing ๐ฆ
-fastaโ splits the sequence into blocks of 70 uppercase letters. seventy. exactly.
๐ Nucleotide Processing ๐
-revcompโ reverse complements the nucleotide sequence.-nucleicโ the subrange decides whether it goes forward or revcomp.-ncbi2naโ expandsncbi2nato IUPAC. (You may need to truncate the result to the actual sequence length.) โ ๏ธ don't forget the truncate bestie-ncbi4naโ expandsncbi4nato IUPAC. (Same deal โ you may need to truncate the result to the actual sequence length.) โ ๏ธ-cds2prot[-gcode N][-frame N]โ translates the coding region using-gcodeand the (1-based)-frame. both default to 1.
๐ง Protein Processing ๐ง
-molwtโ calculates the molecular weight of the peptide.-molwt-mโ molecular weight, but keeping the initial methionine.-molwt-fโ keeps the initialMresidue as formyl-methionine.-peptโ splits amino acid runs at*,-,x, orX. yes, both cases, she's thorough ๐
โญ Sequence Coordinates โญ
-0-basedelement โ zero-based.-1-basedelement โ one-based.-ucsc-basedelement โ half-open.
๐ Command Generator ๐
-insdarg ... โ generates INSDSeq extraction commands. If you invoke it standalone, it prints them; if you invoke it as part of a pipeline, it runs them. It requires one or more arguments, and those arguments may appear in this order:- Descriptor(s) โ
INSDSeq_sequence/INSDSeq_definition/INSDSeq_division/...[...] - Completeness โ
complete/partial - Feature(s) โ
CDS/mRNA/...[,...] - Qualifier(s) โ
INSDFeature_key/"#INSDInterval"/gene/product/feat_location/sub_sequence/...[...]
- Descriptor(s) โ
-insdxโ processes the-insdoutput table into XML.
๐ Frequency Table ๐
-histogramโ collects data forsort-uniq-count(1)across the entire set of records. gathering the receipts fr fr
๐ Entrez Indexing ๐
-indexerelement โ positional index using-wrpfor the field name.
๐ Output Organization ๐
-headstr โ prints before everything else.-tailstr โ prints after everything else.-hdstr โ prints before each record.-tlstr โ prints after each record.
๐ Record Selection ๐
-selectcondition โ selects a subset of records by conditions.-infilename โ a file of identifiers to use for selection.
๐ฅ Record Rearrangement ๐ฅ
-sort[-fwd]element โ the element to use as the sort key.-sort-revelement โ sorts records in reverse order.
โจ Reformatting โจ
-formatfmtcopyโ fast block copy (it still applies the processing flags).compactโ compresses runs of spaces.flushโ suppresses line indentation.indentโ indents according to nesting depth.expandโ places each attribute on a separate line.
๐ฆ Validation ๐ฆ
-verifyโ reports XML data integrity problems.-testโ checks a field for visible combining accents and invisible Unicode. sneaky little characters ๐
๐ Summary ๐
-outlineโ displays an outline of the XML structure.-synopsisโ displays individual XML paths.-contour[delimiter]โ displays XML paths to leaf nodes (delimited by/by default).
๐ Full Exploration Command Precedence ๐
-pattern-path-division-group-branch-block-section-subset-unit
๐ Documentation ๐
-helpโ prints usage information and some example argument combinations.-examplesโ complete usage examples, involving additional Entrez Direct tools.-unixโ illustrates common Unix command arguments.-versionโ prints the version number.
๐ NOTES ๐
String constraints use case-insensitive comparisons. so don't stress about the caps bestie ๐ซถ
Numeric constraints and selection arguments use integer values.
-num and -len selections are synonyms for Object Count (#) and Item Length (%).
-words, -pairs, and -indices convert to lower case.
๐ SEE ALSO ๐
align-columns(1), archive-nihocc(1), archive-nlmnlp(1), archive-nmcds(1), archive-pids(1), archive-pmc(1), archive-pubmed(1), archive-taxonomy(1), asn2ref(1), between-two-genes(1), bsmp2info(1), csv2xml(1), custom-index(1), disambiguate-nucleotides(1), download-flatfile(1), download-ncbi-data(1), ds2pme(1), efetch(1), esample(1), filter-columns(1), find-in-gene(1), fuse-ranges(1), fuse-segments(1), gbf2facds(1), gbf2fsa(1), gbf2info(1), gbf2tbl(1), gene2range(1), gff2xml(1), gff-sort(1), gm2segs(1), hgvs2spdi(1), nquire(1), pm-collect(1), pm-refresh(1), pma2apa(1), pma2pme(1), pmc2bioc(1), pmc2info(1), print-columns(1), rchive(1), refseq-nm-cds(1), reorder-columns(1), snp2hgvs(1), snp2tbl(1), sort-table(1), sort-uniq-count(1), spdi2tbl(1), tbl2prod(1), transmute(1), uniq-table(1), xfetch(1), xfilter(1), xinfo(1), xlink(1), xml2fsa(1), xml2tbl(1), xsearch(1), xy-plot(1).
and that's the whole page bestie, you made it ๐ฅน๐ซถ this one's from NCBI, dated 2025-05-26 โ go be the main character of your own data pipeline, mwah ๐โจ
๐ฆ where this page comes from
- debian trixie: ncbi-entrez-direct 24.0.20250523+dfsg-1+b1 ยท PD
- ubuntu questing: ncbi-entrez-direct 24.0.20250523+dfsg-1
- ubuntu resolute: ncbi-entrez-direct 24.0.20250523+dfsg-2 ยท PD
- ubuntu stonking: ncbi-entrez-direct 24.0.20250523+dfsg-2 ยท PD
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms