<jupyter_start><jupyter_text>Align contigsWe can use SECAPR to produce Multiple Sequence Alignments (MSAs) from the contig data. The alignment function `align_sequences` looks as follows:<jupyter_code>%%bash
source activate secapr_env
secapr align_sequences -h<jupyter_output>usage: secapr align_sequences [-h] --sequences SEQUENCES --output OUTPUT
                              [--aligner {muscle,mafft}]
                              [--output-format {fasta,nexus,phylip,clustal,emboss,stockholm}]
                              [--no-trim] [--window WINDOW]
                              [--proportion PROPORTION]
                              [--threshold THRESHOLD]
                              [--max-divergence MAX_DIVERGENCE]
                              [--min-length MIN_LENGTH] [--exclude_ambiguous]
                              [--cores CORES]

Align sequences and produce separate alignment file for each locus, containing
the seqeunces of all taxa.

optional arguments:
  -h, --help            show this help message and exit
  --sequences SEQUENCES
                        The fasta file containing individual sequences for
                        several samples and loci
  --output OUTPUT       The directory in which to store the resulting
                [...]<jupyter_text>Let's now create alignment from our contig data. In the example command below we added the flag `--no-trim`, which avoids the algorithm to cut the alignment at the ends (= full contig sequence length is being preserved) and the flag `--ambiguous`, which allows sequences with ambiguous bases ('N') to be included into the alignments. You can decide to not use the `--no-trim` flag if you want all sequences in the alignments to be of the same length. In that case there are a bunch of additional flags (see above) that you can use to adjust the trimming process.`secapr align_sequences --sequences ../../data/processed/target_contigs/extracted_target_contigs_all_samples.fasta --output ../../data/processed/alignments/contig_alignments/ --aligner mafft --output-format fasta --no-trim` The align_sequences function by default creates multiple sequence alignments (MSAs) for **all loci that are present in at least 3 samples**. This leads to alignments for most of the targeted exons. We can use the SECAPR plotting function from the previous step again to create an overview showing which loci we have MSAs for. Therefore we need to provide the function the path to the target contigs as well as the path to the alignment folder. We can provide the same output folder as before, since the function will automatically name this plot differently than the previous one, so that it's not being overwritten.`secapr plot_sequence_yield --extracted_contigs ../../data/processed/target_contigs --alignments ../../data/processed/alignments/contig_alignments/ --output ../../data/processed/plots`<jupyter_code>from IPython.display import Image, display
img1 = Image("../../data/processed/plots/contig_alignment_yield_overview.png",width=1000)

display(img1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07682291666666667, 'fraction_numerical': 0.0022786458333333335, 'mean_word_length': 2.8751576292559897, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '162075', 'license': 'MIT', 'n_tokens_mistral': 815, 'n_tokens_neox': 753, 'n_words': 327, 'path': 'docs/notebook/subdocs/align_contigs.ipynb', 'repo_name': 'mftorres/seqcap_processor', 'size': '3072'}