Repository navigation
attributes
Attributes are key-value annotations stored in the FASTA/FASTQ definition
line. They are added by using the -a option:
st . -a a=b input.faproduces something like:
>id1 a=b
SEQUENCE
>id2 a=b
SEQUENCE
(...)
Attributes become useful when using variables:
st . -a num={num} input.fa>id1 num=1
SEQUENCE
>id2 num=2
SEQUENCE
(...)
The -a option is available in any command that returns FASTA/FASTQ sequences,
not just in the pass (.) command. It can be used multiple times in the
same command if more than one attribute has to be added.
Attributes are easily accessed using variables using {a:name}.
They can be located at any place and will be recognized if preceded by a space.
This example creates new files named after the attribute values and saves
sequences with that value there:
st split -k {a:attribute}.fa seqs.faSee individual command descriptions for more examples (count, split, trim, mask).
It is also possible to use other delimiters by specifying --adelim. It will be used
for both setting attributes (-a) and parsing them by the use of a variable (a:name).
This is also useful for parsing attributes set by other tools like
usearch. To replace the = delimiter, use
the --aval-delim option. Alternatively, the delimiters can be changed more permanently
by setting the ST_ATTR_DELIM and ST_ATTRVAL_DELIM environment variables.
This example parses size annotations in files generated by usearch:
# cluster at 90% identity
usearch -cluster_fast seqs.fa -id 0.97 -sizeout -centroids clusters.faclusters.fa:
>seq_1;size=343;
SEQUENCE
(...)
Extract cluster ids and sizes into a tab delimited txt file:
st . --to-txt id,a:size --adelim ";" clusters.fa
# equivalent to:
ST_ATTR_DELIM=";"
st . --to-txt id,a:size clusters.faOutput:
seq1 343
(...)
Use the del command:
st del --attrs attr1,attr2 seqs.fa > clean.faIt is also possible to create transient attributes that are deleted when accessed
as variables by adding a - before the attribute name: {a:-attribute}.
The following command masks all occurrences of SUBSEQ by using a transient
property that will not be present in the final output.
st find SUBSEQ -a pos={f:drange} seqs.fa | st mask {a:-pos} > masked.fa