omics.co.in logo omics.co.in

Tuples

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 6 of 6 0% Course Completed

Tuples

Tuple is an ordered, immutable collection of elements. Tuples are useful for storing data that should not be modified after it has been created, such as DNA sequences or gene expression data.

 

Here are some basic operations that can be performed on tuples in Python:

 

Creating a tuple:

You can create a tuple by enclosing a list of elements in parentheses (), like this:

Pyton
				# Create a tuple using parentheses
my_tuple = (1, 2, 3)

			

Accessing elements of a tuple:

You can access individual elements of a tuple using indexing, like this:

Pyton
				# Access the first element of the tuple
first_element = my_tuple[0]

			

In this example, we access the first element of the tuple my_tuple using indexing and assign it to the variable first_element.

 

Slicing a tuple:

You can extract a subset of elements from a tuple using slicing, like this:

Pyton
				# Create a tuple
my_tuple = (1, 2, 3, 4, 5)

# Extract a slice of the tuple
slice_tuple = my_tuple[1:4]

			

In this example, we extract a slice of the tuple my_tuple that includes elements 2, 3, and 4 and assign it to the variable slice_tuple.

 

Combining tuples:

You can combine two or more tuples using the + operator, like this:

Pyton
				# Create two tuples
tuple1 = (1, 2, 3)
tuple2 = (4, 5, 6)

# Combine the two tuples
combined_tuple = tuple1 + tuple2

			

In this example, we create two tuples tuple1 and tuple2 and then combine them using the + operator to create a new tuple combined_tuple that contains all the elements from both tuples.

 

Tuples are a useful tool for storing ordered, immutable collections of elements in Python. With tuples, you can create and access ordered collections of data, extract subsets of elements using slicing, and combine multiple tuples into a single collection.

⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗