Sample Rules

Execute Configuration Manager | Metadata | Sample Tracker Metadata. On the Receipt File Formats | Sample Rules tab of the Sample Tracker Metadata dialog, define the rules that will be used to identify and automatically resolve the sample tags used by a lab.

Click the Add icon to add a new rule. The QC types you can select are the system QC types configured in the Sample Tracker database. Note that a Blank is a type of Standard.

To create a rule relating to Blanks select “Standard” as the QC type. See: QC Types

The symbols and wildcard characters you can use to define a rule are shown in a legend on the Sample Rules page. If it is not already visible, click the down arrow to expand it:

While REPEATS are referred to in the following examples, they will also work for other QC types.

Wildcard *

The first rule in the example above has been defined to identify and resolve repeat samples, for which the lab has added an ‘A’ suffix to the sample ID.

For example: SMP1024A is a repeat of sample SMP1024. A rule is set to look for *A, where * is a wildcard character that will map to any number of characters that precede ‘A’. Each matched string is a sample ID that is matched to a repeat.

To apply multiple rules for the same QC type (for example, to add another rule to look for repeats with an “R:” prefix), use a comma as a separator:

Handling spaces in strings

When setting rules, take care to accurately capture the syntax the laboratory use to label QC samples. For example:

If the laboratory uses "CHK Y107107" as the label for a lab check of sample "Y107107", then the rule should have "CHK " in the 'Look For' column and "*" in the Map To column, in order to map the check to its corresponding sample. Using "CHK*" without the space, will not automatically resolve check samples because the process will look for, but fail to find, samples with a leading space.

Numeric Wildcard #

Works in the same way as the * wildcard; however in this case the wildcard must match to a numeric value.

Literals

In addition to the wildcards described above, the rules use the “Regular Expression” (Regex) syntax to provide the ability to define more complex matching criteria. With regex, certain symbols, such as the three types of brackets “( ) { } [ ]” have special meaning so if the rule being defined needs to “literally” match to one of these regex characters or a wildcard character then the syntax for literal must be used.

To define literals, use the backslash “\” in front of each special character you want to look for.

For example: If you want to look for occurrences of **, the Look For value should be \*\*, to look for (R), “\(R\)” is needed.

Further details on the regex syntax can be found on: https://regex101.com/. This site can also be used to identify which characters within a string are ‘special’ and thus need to be use the literal syntax.

Apply rules across rows and columns

The rules you define on the Sample Rules page are applied to the column headers and the sample tags column in the file:

Several columns in the above file are repeats from the lab. To avoid confusion, the elements have been given an “-Rp1” suffix. Different laboratories will handle the data for repeats differently. Another laboratory might use “-1” as a suffix, for example:

  Ag Ag-1
  FA001 FA001
SampleID ppm ppm
ST0001 10 11
ST0002 15 16

In this case, a *-1 rule for repeats can be defined. Whenever a string that matches *-1 is encountered, the element that prefixes the -1 part of the wildcard string is identified, and the data is processed as a repeat for that element.

Apply rules to elements only @

In the example above, the rule *-1 rule will be applied wherever a match for the wildcard string is encountered in the file. This assumes that the string will only be matched to element names in the column headers, but suppose sample ids in the file also contain matches for the wildcard string:

  Ag Ag-1
  FA001 FA001
SampleID ppm ppm
ST-1101 10 11
ST-1102 15 16

To ensure that the rule is applied only to the element columns in the file, you can add @ at the front of the string, for example: @*-1

Apply rules to rows by region $

Text rules can also be applied across rows of data.

In the above file, $CHECKS, $STANDARDS and $BLANKS rules can be defined. The $ symbol introduces a marker which identifies a group of data (or region) in the file:

For example, when the marker CHECKS is encountered in the SampleID column, any samples that follow are treated as checks (until either another rule is encountered, or the end of the file is reached). In this case, the * wildcard is redundant.

Flag for Standard ID

For rules relating to standards, there is a special flag [STANDARD_ID] which is used to map to any of the standards or blanks defined in the metadata.

Suppose for example, we want to map the sample tags in the lab file to a known standard ID and a lab has suffixed the standard id with a suffix to make the tags unique, e.g. STD104QZ005 is mapped to STD104QZ: A rule is set to look for [STANDARD_ID]* and map this to [STANDARD_ID].

As another example, suppose we want to map the sample tags in a lab file to a known standard ID and the lab prefixes standard ids with ‘S-‘ , e.g. S-STD104QZ is mapped to STD104QZ:

A rule is set to look for S-[STANDARD_ID] and map this to [STANDARD_ID].

Result Rules