Rename Sequences in Lists
Using Rename Sequences in Lists, you can add or remove characters from the names of sequences within sequence lists. You can also replace parts of sequence names, optionally using regular expressions to define the sections to replace.
Individual sequences in a sequence list can also be renamed manually. Open the sequence list, right-click on the sequence name to change, and select the "Rename Sequence..." option.
To launch the Rename Sequences in Lists tool, go to:
Toolbox | Utility Tools () | Renaming () | Rename Sequences in Lists ()
In the first wizard step, select a sequence list. To rename sequences in multiple sequence lists using the same renaming pattern, check the Batch checkbox (figure 35.22).
Figure 35.22: When the sequences in more than one list should be renamed, check the Batch checkbox.
The text "Renamed" is added within parentheses to the name of sequence lists output by this tool. E.g. with an input called "seqlist2", the sequence list containing the renamed sequences will be called "seqlist2 (Renamed)".
Renaming options
This wizard step presents various options for the renaming action (figure 35.23). The Rename Elements is used for illustration in this section, but the options are the same for the Rename Sequences in Lists tool.
Figure 35.23: Text can be added, removed or replaced in the existing names.
- Add text to name Select this option to add text at the beginning or the end of the existing name.
You can add text directly to these fields, and you can also include placeholders to indicate certain types of information should be added. Multiple placeholders can be used, in combination with other text if desired (figure 35.24). The available placeholders are:
{name}
The current name of the element. Usually used when defining a new naming pattern for replacing the full name of elements.{shortname}
Truncates the original name to 10 characters. Usually used when replacing the full names of elements.{Parent folder}
The name of the folder containing the element.{today}
Today's date in the form YYYY-MM-DD{enumeration}
Adds a number to the name. This is intended for use when multiple elements are selected as input. Each is assigned a number, starting with the number 1, (added as 0000001) for the first element that was selected, 2 (added as 0000002) for the second element selected, and so on.
Click in a field and use Shift + F1 (Shift + Fn + F1 on Mac) to show the list of available placeholders, as shown in figure 35.24. Click on a placeholder in that list to have it entered into the field.
Figure 35.24: Click on Shift+F1 (Shift + Fn + F1 on Mac) to reveal a drop-down list of placeholders that can be used. Here, today's date and a hypen would be prepended, and a hyphen and ascending numeric value appended, to the existing names. - Shorten name Select this option to shorten a name by removing a specified number of characters from the start and/or end of the name.
- Replace part of name Select this option to specify text or regular expressions to define parts of the element names to be replaced. By default, the text entered in the fields is interpreted literally. Check the "Interpret 'Replace' as regular expression" option to indicate that the terms provided in the "Replace" field should be treated as regular expressions. Information on regular expressions can be found at http://docs.oracle.com/javase/tutorial/essential/regex/.
By clicking in either the "Replace" or "with" field and pressing Shift + F1 (Shift + Fn + F1 on Mac), a drop down list of renaming possibilities is presented. The options listed for the Replace field are some commonly used regular expressions. Other standard regular expressions are also admissible in this field. The placeholders described above for adding text to names are available for use in the "with" field. Note: We recommend caution when using these placeholders in combination with regular expressions in the Replace field. Please run a small test to ensure it works as you intend.
- Replace full name Select this option to replace the full element name. Text and placeholders can be used in this field. The placeholders described above for adding text to names are available for use. Use Shift + F1 (Shift + Fn + F1 on Mac) to see a list.
Examples using regular expressions to replace parts of element names
The following are examples to illustrate using regular expressions for renaming. The same principles apply for renaming using the Rename Elements and Rename Sequences in Lists tools.
- Replacing part of an element's name with today's date and an underscore. Details are shown in figure 35.25.
Figure 35.25: Elements with names Seqlist1 and Seqlist2 each start with a capital letter, followed by 6 small letters. Using the settings shown, their names are updated to be the date the renaming was done, followed by a hypen, and the remaining parts of the original name, here, the integer at the end of each name. - Rename using the first 4 non-whitespace characters from names that start with 2 characters, then have a space, then have multiple characters following, such as
1N R1\_0001
.- Check the box beside "Interpret 'Replace' and 'with' as Java regular expressions".
- Enter
([\w]{2})\s([\w]{2}).*
into the "Replaces" field. - Enter
$1$2
into the "with" field.
- Keep only the last 4 characters of the name.
- Check the box beside "Interpret 'Replace' and 'with' as Java regular expressions".
- Enter
(.*)(.{4}$)
into the "Replaces" field. - Enter
$2
into the "with" field.
- Replace a set pattern of text with the name of the parent folder. Here, we start with the name
p140101034_1R_AMR
and replace the first letter and 9 numbers with the parent folder name.- Check the box beside "Interpret 'Replace' and 'with' as Java regular expressions".
- Enter
([a-z]\d{9})(.*)
into the "Replaces" field. - Enter
{parentfolder}$2
into the "with" field.
- Rename using just the text between the first and second underscores in
1234_sample-code_5678
.- Check the box beside "Interpret 'Replace' and 'with' as Java regular expressions".
- Enter
(^[^_]+)_([^_]+)_(.*)
into the "Replaces" field. - Enter
$2
into the "with" field.