omics.co.in logo omics.co.in

Boolean expressions

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 3 of 3 0% Course Completed

Boolean expressions play a crucial role in programming and are fundamental to decision-making in conditional statements. In Python, boolean expressions evaluate to either True or False. Understanding how to create and use boolean expressions is essential for next-generation biologists engaged in bioinformatics, where logical conditions often guide data analysis and interpretation.

Basic Boolean Expressions:
1. Comparison Operators:
Comparison operators are used to compare values and create boolean expressions.

Equal to (==):
Not equal to (!=):
Greater than (>):
Greater than or equal to (>=):
Less than (<):
Less than or equal to (<=):

Pyton
				x = 5
y = 10
print (x == y)  # False
print (x != y)  # True
print (x > y)  # False
print (x >= y)  # False
print (x < y)  # True
print (x <= y)  # True
			

2. Logical Operators:
Logical operators combine boolean expressions.

AND (and):
OR (or):
NOT (not):

Pyton
				age = 25
is_student = True
print(age > 18) and is_student  # True

temperature = 30
is_summer = True
result = (temperature > 25) or is_summer  # True
print(result)

is_raining = False
result = not is_raining  # True
print(result)
			

Some more examples

Pyton
				sequence_quality = 28

is_high_quality = sequence_quality >= 30
print("Is the sequence of high quality?", is_high_quality)
			
Pyton
				gene_variant = 'KRAS_G12C'

is_pathogenic = gene_variant.startswith('KRAS') and ('G12' in gene_variant or 'G13' in gene_variant)
print("Is the mutation pathogenic?", is_pathogenic)
			
Pyton
				cell_marker_expression = {
    'CD3': 0.8,
    'CD19': 0.1,
    'CD56': 0.5
}

is_t_cell = cell_marker_expression['CD3'] > 0.5
is_b_cell = cell_marker_expression['CD19'] > 0.5
is_nk_cell = cell_marker_expression['CD56'] > 0.5

print("Is it a T-cell?", is_t_cell)
print("Is it a B-cell?", is_b_cell)
print("Is it an NK cell?", is_nk_cell)
			
⚠️

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 ↗