XTRACT(1)

๐Ÿ“ฆ
version 24.0.20250523 ยท 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– 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 -classify operation. ๐Ÿ—‚๏ธ

๐Ÿงญ 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 -sep through -elg. ๐Ÿ”„
  • -clr โ€” Clear queued tab separator. ๐Ÿงฝ
  • -pfc str โ€” Preface combines -clr and -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 -with for 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/DD from -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. ๐Ÿ”ค
  • -trim element โ€” strips out the extra spaces and the leading zeros. glow-up for your strings โœจ
  • -wct element โ€” counts how many -words are in a string. counting era ๐Ÿ’…
  • -doi element โ€” slaps the https://doi.org/ prefix on there and URL encodes it. iconic.
  • -accession element โ€” lets you index the full accession.version. no cap.
  • -numeric element โ€” only accepts items that are entirely digits. nothing else gets in, periodt.

๐ŸŒธ Value Transformation ๐ŸŒธ

  • -translate element โ€” swaps values out using the -transform table.
  • -classify element โ€” matches substrings (word or phrase) against the -aliases table.

๐ŸŽ€ Regular Expression ๐ŸŽ€

  • -replace โ€” substitutes text using regular expressions. regex girlies rise ๐Ÿซถ
    • -reg target โ€” the target expression.
    • -exp pattern โ€” 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 โ€” expands ncbi2na to IUPAC. (You may need to truncate the result to the actual sequence length.) โš ๏ธ don't forget the truncate bestie
  • -ncbi4na โ€” expands ncbi4na to 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 -gcode and 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 initial M residue as formyl-methionine.
  • -pept โ€” splits amino acid runs at *, -, x, or X. yes, both cases, she's thorough ๐Ÿ’…

โญ Sequence Coordinates โญ

  • -0-based element โ€” zero-based.
  • -1-based element โ€” one-based.
  • -ucsc-based element โ€” half-open.

๐Ÿ‘‘ Command Generator ๐Ÿ‘‘

  • -insd arg ... โ€” 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/... [...]
  • -insdx โ€” processes the -insd output table into XML.

๐Ÿ“ Frequency Table ๐Ÿ“

  • -histogram โ€” collects data for sort-uniq-count(1) across the entire set of records. gathering the receipts fr fr

๐ŸŒˆ Entrez Indexing ๐ŸŒˆ

  • -indexer element โ€” positional index using -wrp for the field name.

๐ŸŽ€ Output Organization ๐ŸŽ€

  • -head str โ€” prints before everything else.
  • -tail str โ€” prints after everything else.
  • -hd str โ€” prints before each record.
  • -tl str โ€” prints after each record.

๐Ÿ’– Record Selection ๐Ÿ’–

  • -select condition โ€” selects a subset of records by conditions.
  • -in filename โ€” a file of identifiers to use for selection.

๐Ÿ”ฅ Record Rearrangement ๐Ÿ”ฅ

  • -sort[-fwd] element โ€” the element to use as the sort key.
  • -sort-rev element โ€” sorts records in reverse order.

โœจ Reformatting โœจ

  • -format fmt
    • copy โ€” 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