### Example DeepCoil Output File Format Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Illustrates the tab-separated format of the output files generated by DeepCoil, including columns for amino acid, coiled-coil scores, and probabilities. ```text # Example output file (results/3WPA_1.out): # aa cc raw_cc prob_a prob_d # M 0.000 0.012 0.003 0.002 # K 0.000 0.018 0.004 0.002 # ... # E 0.823 0.791 0.612 0.071 ← inside coiled-coil ``` -------------------------------- ### Install DeepCoil using pip Source: https://github.com/labstructbioinf/deepcoil/blob/master/README.md Install the DeepCoil package using pip. Ensure you have python>=3.7,<3.9 and pip>=19.0. ```bash pip3 install deepcoil ``` -------------------------------- ### Run DeepCoil Standalone Source: https://github.com/labstructbioinf/deepcoil/blob/master/README.md Command-line interface for running DeepCoil. Use -i for input FASTA file and -out_path for output directory. Optional arguments include -n_cpu for number of CPUs, --gpu for GPU usage, and --plot for visual output. ```bash deepcoil [-h] -i FILE [-out_path DIR] [-n_cpu NCPU] [--gpu] [--plot] [--dpi DPI] ``` -------------------------------- ### Run DeepCoil Prediction via Command-Line (GPU with Plots) Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Command-line usage for GPU prediction, including generating plots at a specified DPI. ```bash # GPU prediction with plots at 150 DPI deepcoil -i sequences.fasta -out_path results/ --gpu --plot --dpi 150 ``` -------------------------------- ### DeepCoil.__init__ Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Initializes the DeepCoil predictor by loading SeqVec language model weights and Keras CNN weights. Weights are downloaded and cached automatically on first run. Supports CPU-only or GPU-enabled environments. ```APIDOC ## DeepCoil.__init__ Loads the SeqVec language model weights and the five-fold ensemble of Keras CNN weights. On first run the SeqVec weights (~1 GB) are downloaded automatically and cached. Pass `use_gpu=False` and an explicit `n_cpu` count for CPU-only environments. ```python from deepcoil import DeepCoil # CPU-only, use 4 threads dc = DeepCoil(use_gpu=False, n_cpu=4) # GPU-enabled (requires a CUDA device; uses at most 1024 MB of GPU memory for Keras) dc_gpu = DeepCoil(use_gpu=True) ``` ``` -------------------------------- ### Run DeepCoil Prediction via Command-Line (CPU) Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Basic command-line usage for CPU prediction. Specify input FASTA file, output directory, and number of CPUs. ```bash # Basic CPU prediction deepcoil -i sequences.fasta -out_path results/ -n_cpu 8 ``` -------------------------------- ### Initialize DeepCoil Predictor Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Loads SeqVec and Keras CNN weights. Downloads SeqVec weights automatically on first run. Use `use_gpu=False` and `n_cpu` for CPU-only environments. ```python from deepcoil import DeepCoil # CPU-only, use 4 threads dc = DeepCoil(use_gpu=False, n_cpu=4) # GPU-enabled (requires a CUDA device; uses at most 1024 MB of GPU memory for Keras) dc_gpu = DeepCoil(use_gpu=True) ``` -------------------------------- ### Full DeepCoil Pipeline with BioPython and Pandas Source: https://context7.com/labstructbioinf/deepcoil/llms.txt End-to-end Python script demonstrating loading FASTA, predicting coiled-coil content, post-processing with `sharpen_preds`, and exporting results to a pandas DataFrame. ```python import pandas as pd import numpy as np from Bio import SeqIO from deepcoil import DeepCoil from deepcoil.utils import sharpen_preds # 1. Load sequences seq_dict = {str(r.id): str(r.seq) for r in SeqIO.parse("proteome.fasta", "fasta")} # 2. Predict (CPU, 8 threads) dc = DeepCoil(use_gpu=False, n_cpu=8) results = dc.predict(seq_dict) # 3. Build per-residue DataFrame rows = [] for seq_id, preds in results.items(): seq = seq_dict[seq_id] sharp = sharpen_preds(preds["cc"]) for i, (aa, raw, shp, hept) in enumerate(zip(seq, preds["cc"], sharp, preds["hept"])): rows.append({ "id": seq_id, "pos": i + 1, "aa": aa, "raw_cc": float(raw), "cc": float(shp), "prob_a": float(hept[1]), "prob_d": float(hept[2]), "in_cc": float(shp) > 0, }) df = pd.DataFrame(rows) # 4. Summarize coiled-coil content per protein summary = (df.groupby("id") .agg(length=("aa", "count"), cc_residues=("in_cc", "sum"), max_cc_prob=("cc", "max")) .assign(cc_fraction=lambda d: d["cc_residues"] / d["length"]) .sort_values("cc_fraction", ascending=False)) print(summary.head(10)) df.to_csv("predictions.csv", index=False) ``` -------------------------------- ### Display Predictions Interactively with Matplotlib Source: https://context7.com/labstructbioinf/deepcoil/llms.txt This snippet shows how to display predictions using matplotlib. Ensure `plt.show()` is called manually if `out_file` is omitted. ```python import matplotlib.pyplot as plt plot_preds(results["3WPA_1"]) plt.show() ``` -------------------------------- ### Sharpen Raw Coiled-Coil Predictions Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Applies peak detection to raw coiled-coil probabilities to identify domain boundaries. Retains peak regions (width >= 7, relative height >= 0.6, peak max >= 0.1) at their maximum value. Useful for identifying coiled-coil segments. ```python import numpy as np from deepcoil import DeepCoil from deepcoil.utils import sharpen_preds dc = DeepCoil(use_gpu=False, n_cpu=4) results = dc.predict({"GCN4": "MKQLEDKVEELLSKNYHLENEVARLKKLVGER"}) raw_cc = results["GCN4"]["cc"] # shape (N,) sharp_cc = sharpen_preds(raw_cc) # shape (N,), zero outside peak regions # Identify coiled-coil segments segments = [] in_cc = False for i, prob in enumerate(sharp_cc): if prob > 0 and not in_cc: start = i; in_cc = True elif prob == 0 and in_cc: segments.append((start, i - 1, float(sharp_cc[start:i].max()))) in_cc = False if in_cc: segments.append((start, len(sharp_cc) - 1, float(sharp_cc[start:].max()))) for seg in segments: print(f"CC segment: residues {seg[0]+1}-{seg[1]+1}, max prob={seg[2]:.3f}") ``` -------------------------------- ### Run Coiled-Coil Prediction with DeepCoil Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Accepts a dictionary of sequence identifiers and amino acid sequences. Filters sequences shorter than 20 residues and maps non-standard codes to 'X'. Returns raw CC probabilities and heptad register probabilities. ```python from deepcoil import DeepCoil from Bio import SeqIO dc = DeepCoil(use_gpu=False, n_cpu=4) # Build input dict from a multi-sequence FASTA file inp = {str(r.id): str(r.seq) for r in SeqIO.parse("example/example.fasta", "fasta")} # Also works with a plain Python dict inp["MY_SEQ"] = "MASMTGGQQMGRDLYDDDDKDHPFATQCVNSTFDSPAHWAQKSVTCGPASENLYFQGAMG" results = dc.predict(inp) # results["3WPA_1"]["cc"] -> np.ndarray shape (N,) raw CC probabilities # results["3WPA_1"]["hept"] -> np.ndarray shape (N,3) heptad register probs # hept[:,0] = no/other position # hept[:,1] = 'a' core position probability # hept[:,2] = 'd' core position probability entry = "3WPA_1" for i, (cc, a, d) in enumerate(zip(results[entry]["cc"], results[entry]["hept"][:, 1], results[entry]["hept"][:, 2])): print(f"Residue {i+1:4d} CC={cc:.3f} a={a:.3f} d={d:.3f}") ``` -------------------------------- ### Use DeepCoil within a Python Script Source: https://github.com/labstructbioinf/deepcoil/blob/master/README.md Programmatic usage of DeepCoil in Python. Initialize DeepCoil, parse FASTA input, predict coiled coil domains, and plot results. Requires BioPython for sequence parsing. ```python from deepcoil import DeepCoil from deepcoil.utils import plot_preds from Bio import SeqIO dc = DeepCoil(use_gpu=True) inp = {str(entry.id): str(entry.seq) for entry in SeqIO.parse('example/example.fas', 'fasta')} results = dc.predict(inp) plot_preds(results['3WPA_1'], out_file='example/example.png') ``` -------------------------------- ### Visualize DeepCoil Predictions Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Generates a matplotlib figure showing raw and sharpened CC probabilities, and heptad register probabilities. Supports zooming into specific residue ranges. Saves plots to PNG files. ```python from deepcoil import DeepCoil from deepcoil.utils import plot_preds dc = DeepCoil(use_gpu=False, n_cpu=4) results = dc.predict({"3WPA_1": "MKQIEDKIEEILSKIYHIENEIARIKKLIKAVGNQVVTTQTTLVNSLGG..."}) # Save full-sequence plot to PNG plot_preds(results["3WPA_1"], out_file="output/3WPA_1.png", dpi=300) # Zoom into residues 50-150 only plot_preds(results["3WPA_1"], beg=50, end=150, out_file="output/3WPA_1_zoom.png", dpi=150) ``` -------------------------------- ### DeepCoil.predict Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Runs coiled-coil prediction on a dictionary of protein sequences. Filters out sequences shorter than 20 residues and maps non-standard residues to 'X'. Returns raw and heptad probabilities for each input sequence. ```APIDOC ## DeepCoil.predict Accepts a `dict` mapping sequence identifiers (`str`) to amino acid sequences (`str`). Sequences shorter than 20 residues are filtered out with a warning. Non-standard residue codes are silently mapped to `X`. Returns a `dict` with one entry per input sequence; each entry contains `'cc'` (raw per-residue probabilities, shape `[N, 1]`) and `'hept'` (per-residue heptad probabilities, shape `[N, 3]`). ```python from deepcoil import DeepCoil from Bio import SeqIO dc = DeepCoil(use_gpu=False, n_cpu=4) # Build input dict from a multi-sequence FASTA file inp = {str(r.id): str(r.seq) for r in SeqIO.parse("example/example.fasta", "fasta")} # Also works with a plain Python dict inp["MY_SEQ"] = "MASMTGGQQMGRDLYDDDDKDHPFATQCVNSTFDSPAHWAQKSVTCGPASENLYFQGAMG" results = dc.predict(inp) # results["3WPA_1"]["cc"] -> np.ndarray shape (N,) raw CC probabilities # results["3WPA_1"]["hept"] -> np.ndarray shape (N,3) heptad register probs # hept[:,0] = no/other position # hept[:,1] = 'a' core position probability # hept[:,2] = 'd' core position probability entry = "3WPA_1" for i, (cc, a, d) in enumerate(zip(results[entry]["cc"], results[entry]["hept"][:, 1], results[entry]["hept"][:, 2])): print(f"Residue {i+1:4d} CC={cc:.3f} a={a:.3f} d={d:.3f}") ``` ``` -------------------------------- ### Validate FASTA File with deepcoil.utils.is_fasta Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Use `is_fasta` to check if a file is a valid FASTA format using BioPython. This is useful for validating input before processing. ```python from deepcoil.utils import is_fasta for path in ["sequences.fasta", "data.txt", "empty.fa"]: if is_fasta(path): print(f"{path}: valid FASTA") else: print(f"{path}: NOT a valid FASTA file — skipping") ``` -------------------------------- ### deepcoil.utils.sharpen_preds Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Applies peak detection to raw coiled-coil probabilities to identify and retain only significant peak regions. This function helps in identifying domain boundaries more clearly. ```APIDOC ## deepcoil.utils.sharpen_preds Applies `scipy.signal.find_peaks` to the raw coiled-coil probability vector and returns a "sharpened" array in which only peak regions (width ≥ 7 residues, relative height ≥ 0.6, peak max ≥ 0.1) are retained at their maximum value, making domain boundaries easier to identify visually and programmatically. ```python import numpy as np from deepcoil import DeepCoil from deepcoil.utils import sharpen_preds dc = DeepCoil(use_gpu=False, n_cpu=4) results = dc.predict({"GCN4": "MKQLEDKVEELLSKNYHLENEVARLKKLVGER"}) raw_cc = results["GCN4"]["cc"] # shape (N,) sharp_cc = sharpen_preds(raw_cc) # shape (N,), zero outside peak regions # Identify coiled-coil segments segments = [] in_cc = False for i, prob in enumerate(sharp_cc): if prob > 0 and not in_cc: start = i; in_cc = True elif prob == 0 and in_cc: segments.append((start, i - 1, float(sharp_cc[start:i].max()))) in_cc = False if in_cc: segments.append((start, len(sharp_cc) - 1, float(sharp_cc[start:].max()))) for seg in segments: print(f"CC segment: residues {seg[0]+1}-{seg[1]+1}, max prob={seg[2]:.3f}") ``` ``` -------------------------------- ### deepcoil.utils.plot_preds Source: https://context7.com/labstructbioinf/deepcoil/llms.txt Generates a visualization of coiled-coil predictions, including raw and sharpened probabilities, and a heptad register heatmap. Supports zooming into specific residue ranges. ```APIDOC ## deepcoil.utils.plot_preds Generates a two-panel matplotlib figure: the lower panel shows raw (dashed) and sharpened (solid) coiled-coil probabilities; the upper heatmap panel shows per-residue heptad register (*a* in red, *d* in blue). An optional `beg`/`end` range allows zooming into a subsequence of long proteins. ```python from deepcoil import DeepCoil from deepcoil.utils import plot_preds dc = DeepCoil(use_gpu=False, n_cpu=4) results = dc.predict({"3WPA_1": "MKQIEDKIEEILSKIYHIENEIARIKKLIKAVGNQVVTTQTTLVNSLGG..."}) # Save full-sequence plot to PNG plot_preds(results["3WPA_1"], out_file="output/3WPA_1.png", dpi=300) # Zoom into residues 50-150 only plot_preds(results["3WPA_1"], beg=50, end=150, out_file="output/3WPA_1_zoom.png", dpi=150) ``` ``` -------------------------------- ### Correct Non-Standard Residue Codes with deepcoil.utils.corr_seq Source: https://context7.com/labstructbioinf/deepcoil/llms.txt The `corr_seq` function maps non-standard amino acid codes to 'X'. This is automatically applied during prediction but can be used for manual preprocessing. ```python from deepcoil.utils import corr_seq raw = "ACDE-FGHIKLMNPQRSTVWYU*Z" cleaned = corr_seq(raw) # 'ACDEFGHIKLMNPQRSTVWXYXXX' (-, U, *, Z → X) print(cleaned) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.