### Conda Installation for Jasmine Source: https://github.com/mkirsche/jasmine/blob/master/README.md Installs the Jasmine tool and its dependencies using the bioconda package manager. This is the recommended and quickest installation method. ```bash conda config --add channels bioconda conda config --add channels conda-forge conda install jasminesv ``` -------------------------------- ### Setup Pipeline Files with Symlinks Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command creates symbolic links to all snakefile and Python files from the Jasmine pipeline directory into the current experiment directory. This is a prerequisite for running the Snakemake pipeline. ```bash ln -s /path/to/pipelines/Jasmine/pipeline/*snakefile . ln -s /path/to/pipelines/Jasmine/pipeline/*py . ``` -------------------------------- ### Downloading Demo Dataset for Jasmine Source: https://github.com/mkirsche/jasmine/blob/master/README.md Downloads VCF files for the HG002 trio dataset to demonstrate Jasmine's functionality. These files contain unmerged structural variants for multiple samples. ```bash wget http://data.schatz-lab.org/jasmine/HG002Trio/UnmergedVCFs/HG002vGRCh38_wm_50md_PBCCS_sniffles.s2l20.refined.nSVtypes.ism.vcf.gz wget http://data.schatz-lab.org/jasmine/HG002Trio/UnmergedVCFs/HG003vGRCh38_wm_50md_PBCCS_sniffles.s2l20.refined.nSVtypes.ism.vcf.gz wget http://data.schatz-lab.org/jasmine/HG002Trio/UnmergedVCFs/HG004vGRCh38_wm_50md_PBCCS_sniffles.s2l20.refined.nSVtypes.ism.vcf.gz wget http://data.schatz-lab.org/jasmine/HG002Trio/HG002Trio_HiFi.merged.vcf.gz gunzip * ls *vGRCh38_wm_50md_PBCCS_sniffles.s2l20.refined.nSVtypes.ism.vcf > filelist.txt ``` -------------------------------- ### Main Entry Point and Program Flow - Java Source: https://context7.com/mkirsche/jasmine/llms.txt This Java code defines the main entry point for the Jasmine program. It handles command-line argument parsing, orchestrates preprocessing, core merging, and postprocessing stages, and manages input/output files. It relies on the 'Settings' class for configuration and other internal classes for specific operations. ```java // Main.java - Entry point with preprocessing, merging, and postprocessing public static void main(String[] args) throws Exception { // Parse command-line arguments Settings.parseArgs(args); String currentInputFile = Settings.FILE_LIST; // Preprocessing: convert duplications, mark specific calls, run Iris, normalize types if(!Settings.POSTPROCESS_ONLY) { currentInputFile = preprocess(currentInputFile); } // Core merging algorithm if(!Settings.PREPROCESS_ONLY && !Settings.POSTPROCESS_ONLY) { runJasmine(currentInputFile); } // Postprocessing: revert duplications, add genotypes if(!Settings.PREPROCESS_ONLY) { postprocess(currentInputFile); } } // Core merging logic static void runJasmine(String currentInputFile) throws Exception { // Read all variants from VCF files and bin by chromosome/type/strand TreeMap> allVariants = VariantInput.readAllFiles(currentInputFile); // Initialize output data structure VariantOutput output = new VariantOutput(); // Count samples for support vector int sampleCount = VariantInput.countFiles(currentInputFile); // Merge each graph in parallel ParallelMerger pm = new ParallelMerger(allVariants, output, sampleCount); pm.run(); // Output merged variants with sufficient support output.writeMergedVariants(currentInputFile, Settings.OUT_FILE); System.out.println("Number of sets with multiple variants: " + pm.totalMerged.get()); } ``` -------------------------------- ### Building Jasmine JAR from Source Source: https://github.com/mkirsche/jasmine/blob/master/README.md Builds the Jasmine Java Archive (JAR) file from the source code. This method requires dependencies like samtools, minimap2, and racon if Iris preprocessing is used. ```bash path_to_jasmine_repo/build_jar.sh ``` -------------------------------- ### Running Jasmine with Demo Data Source: https://github.com/mkirsche/jasmine/blob/master/README.md Executes Jasmine to merge structural variants from the provided VCF files. It takes a file list as input and outputs a merged VCF file. A second command demonstrates postprocessing options. ```bash jasmine file_list=filelist.txt out_file=merged.vcf jasmine --dup_to_ins --postprocess_only out_file=merged.vcf ``` -------------------------------- ### Copy Configuration Files Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command copies all YAML configuration files from the Jasmine pipeline directory to the current experiment directory. These files are essential for configuring the pipeline's behavior. ```bash cp /path/to/pipelines/Jasmine/pipeline/*yaml . ``` -------------------------------- ### Basic Jasmine Merging Commands Source: https://context7.com/mkirsche/jasmine/llms.txt These bash commands demonstrate the basic usage of the Jasmine tool for merging VCF files. They cover essential operations like specifying input files, output files, and setting distance thresholds for merging. ```bash # Merge VCF files listed in filelist.txt jasmine file_list=filelist.txt out_file=merged.vcf # With custom distance threshold (1000bp maximum) jasmine file_list=filelist.txt out_file=merged.vcf max_dist=1000 # Length-proportional distance (50% of variant length) jasmine file_list=filelist.txt out_file=merged.vcf max_dist_linear=0.5 min_dist=100 # Require variants in at least 2 samples jasmine file_list=filelist.txt out_file=merged.vcf min_support=2 # Use multiple threads for parallel processing jasmine file_list=filelist.txt out_file=merged.vcf threads=8 ``` -------------------------------- ### Jasmine: Convert Duplications to Insertions Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command uses the Jasmine tool to preprocess VCF files by converting duplications to insertions. This step is temporary and aids in breakpoint refinement and cross-sample comparison. It requires a list of VCF files and operates in a preprocess-only mode. ```bash jasmine --dup_to_ins --preprocess_only vcf_filelist= --comma_filelist ``` -------------------------------- ### Jasmine Preprocessing and Postprocessing Commands Source: https://context7.com/mkirsche/jasmine/llms.txt This set of bash commands illustrates Jasmine's capabilities for preprocessing and postprocessing structural variant data before or after merging. Options include converting duplications, running Iris refinement, normalizing variant types, and adding genotypes. ```bash # Convert duplications to insertions before merging jasmine file_list=filelist.txt out_file=merged.vcf --dup_to_ins genome_file=ref.fa # Run Iris refinement before merging jasmine file_list=filelist.txt out_file=merged.vcf --run_iris \ genome_file=ref.fa bam_list=bams.txt # Add genotypes to merged output jasmine file_list=filelist.txt out_file=merged.vcf --output_genotypes # Normalize variant types before merging jasmine file_list=filelist.txt out_file=merged.vcf --pre_normalize # Postprocess only (e.g., convert insertions back to duplications) jasmine --dup_to_ins --postprocess_only out_file=merged.vcf ``` -------------------------------- ### Jasmine: Convert Insertions Back to Duplications Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command uses the Jasmine tool in postprocess mode to convert insertions back into duplications after SV merging. This step reverses a previous preprocessing step and outputs the final merged VCF. ```bash jasmine --dup_to_ins --postprocess_only out_file= ``` -------------------------------- ### Jasmine: Merge SVs Across Samples Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command merges structural variant (SV) calls from multiple samples into a single VCF file. It takes a list of VCF files (provided as a text file with one VCF per line) and outputs the merged VCF. ```bash jasmine file_list= out_file= ``` -------------------------------- ### Run Snakemake Pipeline with SLURM Cluster Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command runs the Snakemake pipeline with production settings, including cluster job submission for SLURM. It specifies a maximum of 20 parallel jobs, reruns incomplete jobs, and configures SLURM parameters like account, partition, job name, nodes, CPUs, time limit, and memory. ```bash snakemake -s pipeline.snakefile --latency-wait 200 -pr -j 20 --rerun-incomplete --cluster "sbatch --account={cluster.account} --partition={cluster.partition} --job-name={cluster.name} --nodes={cluster.nodes} --cpus-per-task={cluster.nCPUs} --time={cluster.time} --out={cluster.out} --err={cluster.err} --mem={cluster.mem_mb}M" ``` -------------------------------- ### Advanced Jasmine Merging Options Commands Source: https://context7.com/mkirsche/jasmine/llms.txt These bash commands showcase advanced merging strategies available in Jasmine. They cover fine-tuning the merging process by ignoring strand or type information, specifying sequence similarity thresholds, and choosing different merging algorithms like centroid or clique-based. ```bash # Ignore strand information during merging jasmine file_list=filelist.txt out_file=merged.vcf --ignore_strand # Ignore type information during merging jasmine file_list=filelist.txt out_file=merged.vcf --ignore_type # Require sequence identity for insertions (80%) jasmine file_list=filelist.txt out_file=merged.vcf min_seq_id=0.8 # Use edit distance instead of Jaccard for sequence comparison jasmine file_list=filelist.txt out_file=merged.vcf min_seq_id=0.8 --use_edit_dist # Centroid-based merging (all variants within distance of centroid) jasmine file_list=filelist.txt out_file=merged.vcf --centroid_merging # Clique-based merging (all pairs within distance threshold) jasmine file_list=filelist.txt out_file=merged.vcf --clique_merging # Allow merging variants within the same sample jasmine file_list=filelist.txt out_file=merged.vcf --allow_intrasample # Require reciprocal overlap for DEL/INV/DUP (50%) jasmine file_list=filelist.txt out_file=merged.vcf min_overlap=0.5 ``` -------------------------------- ### Sniffles SV Calling Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command invokes the Sniffles tool to call structural variants (SVs) from alignment files. It uses sensitive parameters and reports all supporting reads. Key parameters include input alignments, output VCF file, thread count, minimum support, maximum distance, and reporting all supporting reads. ```bash sniffles -m -v --threads --min_support 2 --max_distance 50 --min_length 20 --num_reads_report -1 ``` -------------------------------- ### Jasmine: Mark High-Confidence SVs Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command uses Jasmine to mark high-confidence structural variants (SVs) within each sample, creating a high-specificity callset. It requires a list of VCF files and specifies parameters for marking specific reads and their lengths. This function operates in preprocess-only mode. ```bash jasmine file_list= --comma_filelist --preprocess_only --mark_specific spec_reads= spec_len=30 ``` -------------------------------- ### Dry Run Snakemake Pipeline Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md Executes a dry run of the Snakemake pipeline using 'pipeline.snakefile'. The '-npr' flags indicate a dry-run (no execution), print of the execution plan, and recursive execution of all targets. This is used to preview the pipeline's steps without actually running them. ```bash snakemake -s pipeline.snakefile -npr ``` -------------------------------- ### Jasmine: Normalize SV Types Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command utilizes the Jasmine tool to normalize structural variant (SV) types across samples. It operates in a preprocess-only mode and requires a comma-separated list of VCF files. ```bash jasmine --preprocess_only --pre_normalize --comma_filelist file_list= ``` -------------------------------- ### Java: Read and Parse VCF Files with VariantInput Source: https://context7.com/mkirsche/jasmine/llms.txt This Java code defines the `VariantInput` class responsible for reading and parsing VCF files. It includes functionality to read multiple files, merge variants based on a graph ID, and parse individual VCF entries into a `Variant` object, handling duplicate IDs and configurable distance thresholds. ```java // VariantInput.java - Read and parse VCF files public class VariantInput { // Read all VCF files and bin variants by graphID (chr+type+strand) public static TreeMap> readAllFiles(String fileList) throws Exception { ArrayList fileNames = PipelineManager.getFilesFromList(fileList); TreeMap>[] variantsPerFile = new TreeMap[fileNames.size()]; for(int i = 0; i < fileNames.size(); i++) { variantsPerFile[i] = getSingleList(fileNames.get(i), i); } // Merge all variants into single map by graphID TreeMap> res = new TreeMap>(); for(int i = 0; i < fileNames.size(); i++) { for(String graphID : variantsPerFile[i].keySet()) { if(!res.containsKey(graphID)) { res.put(graphID, new ArrayList()); } for(Variant v : variantsPerFile[i].get(graphID)) { res.get(graphID).add(v); } } } return res; } // Parse single VCF file private static TreeMap> getSingleList(String filename, int sample) throws Exception { if(filename.endsWith(".gz")) { System.err.println("Warning: " + filename + " ends with .gz, but (b)gzipped VCFs are not accepted"); } Scanner input = new Scanner(new FileInputStream(new File(filename))); ArrayList allVariants = new ArrayList(); HashSet ids = new HashSet(); while(input.hasNext()) { String line = input.nextLine(); if(line.length() == 0 || line.startsWith("#")) continue; VcfEntry entry = VcfEntry.fromLine(line); // Handle duplicate IDs if(ids.contains(entry.getId())) { String oldId = entry.getId(); int index = 1; while(ids.contains(oldId + "_duplicate" + index)) index++; entry.setId(oldId + "_duplicate" + index); System.err.println("Warning: Duplicate variant ID " + oldId + " in " + filename + "; Replacing with " + entry.getId()); } ids.add(entry.getId()); allVariants.add(fromVcfEntry(entry, sample)); } System.out.println(filename + " has " + allVariants.size() + " variants"); input.close(); return divideIntoGraphs(allVariants); } // Convert VCF entry to Variant object public static Variant fromVcfEntry(VcfEntry entry, int sample) throws Exception { double start = entry.getFirstCoord(); double end = entry.getSecondCoord(); entry.setId(sample + "_" + entry.getId()); String id = entry.getGraphID(); // Extract sequence for insertions String seq = null; if(entry.getType().equals("INS")) { String entrySeq = entry.getSeq(); if(entrySeq.length() > 0) seq = entrySeq; } // Determine distance threshold int maxDist = Settings.MAX_DIST; String maxDistInfo = entry.getInfo("JASMINE_DIST"); if(maxDistInfo.length() > 0) { maxDist = Integer.parseInt(maxDistInfo); } else if(Settings.PER_SAMPLE_DISTS != null && Settings.PER_SAMPLE_DISTS.length > sample) { maxDist = Settings.PER_SAMPLE_DISTS[sample]; } else if(Settings.USE_LINEAR_THRESHOLD && Settings.MAX_DIST_LINEAR > 0) { maxDist = (int)(Settings.MAX_DIST_LINEAR * Math.abs(entry.getLength()) + 0.5); if(Settings.MAX_DIST_SET) maxDist = Math.min(maxDist, Settings.MAX_DIST); if(Settings.MIN_DIST != -1) maxDist = Math.max(maxDist, Settings.MIN_DIST); } // Check for per-variant sequence ID thresholds double minSeqId = Settings.MIN_SEQUENCE_SIMILARITY; String minIdInfo = entry.getInfo("JASMINE_ID"); if(minIdInfo.length() > 0) { minSeqId = Double.parseDouble(minIdInfo); } Variant res = new Variant(sample, entry.getId(), start, end, id, seq, maxDist, minSeqId); if(Settings.OVERLAP_REQUIRED > 0 && (entry.getType().equals("DEL") || entry.getType().equals("INV") || entry.getType().equals("DUP"))) { res.interval = new double[] {entry.getPos(), entry.getEnd()}; } return res; } } ``` -------------------------------- ### Java - Generate Merged VCF Output Source: https://context7.com/mkirsche/jasmine/llms.txt This Java code generates a merged VCF output file from a list of input VCF files. It handles VCF headers, adds Jasmine-specific INFO fields, and processes variants to create a consensus output. Dependencies include standard Java I/O, collections, and potentially custom VCF parsing classes (VcfHeader, VcfEntry). ```java public class VariantOutput { ConcurrentSkipListMap groups; // Write merged variants to VCF file public void writeMergedVariants(String fileList, String outFile) throws Exception { PrintWriter out = new PrintWriter(new File(outFile)); int sample = 0; VcfHeader header = new VcfHeader(); boolean printedHeader = false; ArrayList filenames = PipelineManager.getFilesFromList(fileList); for(String filename : filenames) { Scanner input = new Scanner(new FileInputStream(new File(filename))); while(input.hasNext()) { String line = input.nextLine(); if(line.length() == 0) continue; // Collect header from first file if(line.startsWith("#")) { if(sample == 0) header.addLine(line); continue; } // Add Jasmine-specific INFO fields on first variant if(sample == 0 && !printedHeader) { printedHeader = true; header.addInfoField("SUPP_VEC", "1", "String", "Vector of supporting samples"); header.addInfoField("SUPP", "1", "Integer", "Number of samples supporting the variant"); header.addInfoField("IDLIST", ".", "String", "Variant IDs merged to make this call"); header.addInfoField("STARTVARIANCE", "1", "String", "Variance of start position"); header.addInfoField("ENDVARIANCE", "1", "String", "Variance of end position"); header.addInfoField("AVG_START", "1", "String", "Average start position"); header.addInfoField("AVG_END", "1", "String", "Average end position"); header.addInfoField("AVG_LEN", "1", "String", "Average length"); header.print(out); } VcfEntry entry = VcfEntry.fromLine(line); String graphID = entry.getGraphID(); groups.get(graphID).processVariant(entry, sample, out); } input.close(); sample++; } out.close(); } // Process single variant and update consensus void processVariant(VcfEntry entry, int sample, PrintWriter out) throws Exception { String fullId = VariantInput.fromVcfEntry(entry, sample).id; if(!varToGroup.containsKey(fullId)) return; int groupNumber = varToGroup.get(fullId); // Skip if insufficient support if(supportCounts[groupNumber] < Settings.MIN_SUPPORT) return; // Initialize consensus on first variant if(used[groupNumber] == 0) { if(Settings.REQUIRE_FIRST_SAMPLE && sample != 0) return; initializeOutputVariant(sample, fullId, groupNumber, entry); } else { updateOutputVariant(sample, entry, groupNumber); } used[groupNumber]++; // Finalize and output when all variants processed if(used[groupNumber] == sizes[groupNumber]) { finalizeOutputVariant(sample, groupNumber); if(supportCounts[groupNumber] >= Settings.MIN_SUPPORT) { out.println(consensus[groupNumber]); } } } // Finalize consensus variant statistics void finalizeOutputVariant(int sample, int groupNumber) throws Exception { int groupSize = sizes[groupNumber]; long totalStart = Long.parseLong(consensus[groupNumber].getInfo("AVG_START")); long totalEnd = Long.parseLong(consensus[groupNumber].getInfo("AVG_END")); long totalSquaredStart = Long.parseLong(consensus[groupNumber].getInfo("STARTVARIANCE")); long totalSquaredEnd = Long.parseLong(consensus[groupNumber].getInfo("ENDVARIANCE")); // Compute variances double varStart = (totalSquaredStart * 1.0 / groupSize) - (totalStart * totalStart * 1.0 / groupSize / groupSize); double varEnd = (totalSquaredEnd * 1.0 / groupSize) - (totalEnd * totalEnd * 1.0 / groupSize / groupSize); consensus[groupNumber].setInfo("STARTVARIANCE", String.format("%.6f", varStart)); consensus[groupNumber].setInfo("ENDVARIANCE", String.format("%.6f", varEnd)); consensus[groupNumber].setInfo("AVG_START", String.format("%.6f", totalStart * 1.0 / groupSize)); consensus[groupNumber].setInfo("AVG_END", String.format("%.6f", totalEnd * 1.0 / groupSize)); // Set support fields consensus[groupNumber].setInfo("SUPP_VEC", supportVectors[groupNumber]); consensus[groupNumber].setInfo("SUPP", supportCounts[groupNumber] + ""); consensus[groupNumber].setInfo("SVMETHOD", "JASMINE"); consensus[groupNumber].setInfo("IDLIST", idLists[groupNumber].toString()); ``` -------------------------------- ### Variant Merging Core Algorithm in Java Source: https://context7.com/mkirsche/jasmine/llms.txt This snippet implements the main variant merging logic. It uses a priority queue to process edges between variants in ascending order of distance. The union-find data structure tracks connected components, and KD-trees are used for finding nearest neighbors. Dependencies include custom classes like Variant, Forest, KDTree, Edge, and Settings. ```java // VariantMerger.java - Core merging algorithm using KD-trees and union-find public class VariantMerger { Variant[] data; // All variants Forest forest; // Union-find for connected components KDTree knn; // KD-tree for nearest neighbor queries public VariantMerger(Variant[] data) { n = data.length; forest = new Forest(data); knn = new KDTree(data, false); for(int i = 0; i < n; i++) data[i].index = i; this.data = data; } // Modified minimum spanning forest algorithm void runMerging() { if(n == 1) return; int[] countEdgesProcessed = new int[n]; Variant[][] nearestNeighbors = new Variant[n][]; PriorityQueue toProcess = new PriorityQueue(); // Initialize with 4 nearest neighbors per variant for(int i = 0; i < n; i++) { nearestNeighbors[i] = knn.kNearestNeighbor(data[i], 4); int maxDistAllowed = Settings.REQUIRE_MUTUAL_DISTANCE ? Math.min(data[i].maxDist, nearestNeighbors[i][0].maxDist) : Math.max(data[i].maxDist, nearestNeighbors[i][0].maxDist); if(data[i].distance(nearestNeighbors[i][0]) < maxDistAllowed + 1e-9) { toProcess.add(new Edge(i, nearestNeighbors[i][0].index, data[i].distance(nearestNeighbors[i][0]))); } countEdgesProcessed[i]++; } // Process edges in non-decreasing order of distance while(!toProcess.isEmpty()) { Edge e = toProcess.poll(); boolean valid = forest.canUnion(e.from, e.to); if(valid) { int fromRoot = forest.find(e.from); int toRoot = forest.find(e.to); // For centroid/clique merging, verify all pairwise distances if(Settings.CLIQUE_MERGE) { for(int i = 0; i < merged[fromRoot].size() && valid; i++) { for(int j = 0; j < merged[toRoot].size() && valid; j++) { Variant candidateFrom = data[merged[fromRoot].get(i)]; Variant candidateTo = data[merged[toRoot].get(j)]; int maxDist = Settings.REQUIRE_MUTUAL_DISTANCE ? Math.min(candidateFrom.maxDist, candidateTo.maxDist) : Math.max(candidateFrom.maxDist, candidateTo.maxDist); if(candidateFrom.distance(candidateTo) > maxDist + 1e-9) { valid = false; } } } } if(valid) forest.union(fromRoot, toRoot); } // Query for more neighbors if needed while(true) { if(countEdgesProcessed[e.from] >= nearestNeighbors[e.from].length) { nearestNeighbors[e.from] = knn.kNearestNeighbor(data[e.from], 2 * nearestNeighbors[e.from].length); } if(countEdgesProcessed[e.from] >= nearestNeighbors[e.from].length) break; Variant candidateTo = nearestNeighbors[e.from][countEdgesProcessed[e.from]]; int maxDistAllowed = Settings.REQUIRE_MUTUAL_DISTANCE ? Math.min(data[e.from].maxDist, candidateTo.maxDist) : Math.max(data[e.from].maxDist, candidateTo.maxDist); // Stop if too far if(data[e.from].distance(candidateTo) > data[e.from].maxDist + 1e-9) break; // Skip if exceeds mutual distance threshold if(data[e.from].distance(candidateTo) > maxDistAllowed + 1e-9) { countEdgesProcessed[e.from]++; continue; } // Skip if same sample (unless allowed) if(!Settings.ALLOW_INTRASAMPLE && data[e.from].sample == candidateTo.sample) { toProcess.add(new Edge(e.from, candidateTo.index, data[e.from].distance(candidateTo))); countEdgesProcessed[e.from]++; break; } // Skip if sequences not similar enough if(!data[e.from].passesStringSimilarity(candidateTo)) { countEdgesProcessed[e.from]++; continue; } // Skip if insufficient overlap if(!data[e.from].passesOverlap(candidateTo)) { countEdgesProcessed[e.from]++; continue; } // Valid edge - add to queue toProcess.add(new Edge(e.from, candidateTo.index, data[e.from].distance(candidateTo))); ``` -------------------------------- ### Variant Data Structure and Comparison Logic - Java Source: https://context7.com/mkirsche/jasmine/llms.txt This Java code defines the `Variant` class, which is the core data structure for representing genetic variants. It includes fields for sample information, variant identifiers, genomic coordinates, sequence data, and merging parameters. It also provides methods for calculating distances, assessing string similarity for insertions, and checking overlap for structural variants, all influenced by settings defined in the `Settings` class. ```java // Variant.java - Core variant data structure public class Variant implements Comparable { int sample; // Sample ID String id; // Unique variant ID double start, end; // Genomic coordinates String graphID; // Chr + type + strand concatenation String seq; // Insertion sequence (if applicable) int maxDist; // Maximum merge distance double minSeqId; // Minimum sequence identity threshold // Constructor with custom thresholds Variant(int sample, String id, double start, double end, String graphID, String seq, int maxDist, double minSeqId) { this.sample = sample; this.id = id; this.start = start; this.end = end; this.graphID = graphID; if(minSeqId > 0) this.seq = seq; this.maxDist = maxDist; this.minSeqId = minSeqId; } // Distance between variants (generalized Euclidean) double distance(Variant v) { return distFromPoint(v.start, v.end); } double distFromPoint(double x, double y) { double dStart = start - x; double dEnd = end - y; int norm = Settings.KD_TREE_NORM; if(norm == 2) { return Math.sqrt(dStart * dStart + dEnd * dEnd); } else { double powSum = Math.abs(Math.pow(dStart, norm)) + Math.abs(Math.pow(dEnd, norm)); return Math.pow(powSum, 1.0 / norm); } } // Sequence similarity for insertions double stringSimilarity(Variant v) { if(seq == null || v.seq == null) return 1.0; if(Settings.USE_EDIT_DISTANCE) { return StringUtils.editDistanceSimilarity(seq, v.seq); } else { return StringUtils.jaccardSimilarity(seq, v.seq); } } // Check if sequences are similar enough to merge boolean passesStringSimilarity(Variant v) { if(seq == null || v.seq == null) return true; double similarityNeeded = Math.min(minSeqId, v.minSeqId); if(similarityNeeded <= 0) return true; // Quick length filter int minLength = Math.min(seq.length(), v.seq.length()); int maxLength = seq.length() + v.seq.length() - minLength; if(minLength < maxLength * similarityNeeded - 1e-9) return false; return stringSimilarity(v) >= similarityNeeded - 1e-9; } // Check reciprocal overlap for DEL/INV/DUP boolean passesOverlap(Variant v) { if(interval == null || v.interval == null) return true; double maxStart = Math.max(interval[0], v.interval[0]); double minEnd = Math.min(interval[1], v.interval[1]); if(minEnd <= maxStart + 1E-9) return false; double maxIntervalSize = Math.max(interval[1] - interval[0], v.interval[1] - v.interval[0]); return minEnd - maxStart + 1e-9 >= maxIntervalSize * Settings.OVERLAP_REQUIRED; } } ``` -------------------------------- ### Jasmine: Remove Intra-sample Duplicates Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command uses Jasmine to remove duplicate structural variant (SV) calls within each sample. It allows for a specified maximum distance between potential duplicates and operates with non-linear distance calculations, outputting to a specified VCF file. ```bash jasmine file_list= max_dist=200 --allow_intrasample out_file= --comma_filelist --nonlinear_dist ``` -------------------------------- ### Jasmine Configuration Check Source: https://context7.com/mkirsche/jasmine/llms.txt This code snippet checks if the 'FIX_ENDS' setting is enabled in the Settings object. If true, it calls the 'fixImprecision' method on the consensus object for a given group number. This likely relates to an internal Jasmine configuration for handling variant imprecision. ```Java if(Settings.FIX_ENDS) { consensus[groupNumber].fixImprecision(); } ``` -------------------------------- ### Filter Low-Confidence SV Calls Source: https://github.com/mkirsche/jasmine/blob/master/pipeline/README.md This command filters a merged VCF file to remove low-confidence or imprecise structural variant (SV) calls. It uses `grep` to exclude lines containing 'IMPRECISE;' or 'IS_SPECIFIC=0'. ```bash cat | grep -v 'IMPRECISE;' | grep -v 'IS_SPECIFIC=0' ``` -------------------------------- ### Extract Merged Groups in Java Source: https://context7.com/mkirsche/jasmine/llms.txt Extracts and returns merged groups of 'Variant' objects. It utilizes a forest data structure to determine group affiliation. Assumes 'n' is the total number of elements and 'forest' is a Disjoint Set Union (DSU) data structure. ```java ArrayList[] getGroups() { ArrayList[] res = new ArrayList[n]; for(int i = 0; i < n; i++) res[i] = new ArrayList(); for(int i = 0; i < n; i++) { if(forest.map[i] < 0) { res[i].add(data[i]); } else { res[forest.find(i)].add(data[i]); } } return res; } } ``` -------------------------------- ### Increment Edge Count in Java Source: https://context7.com/mkirsche/jasmine/llms.txt Increments the count of processed edges originating from a specific node 'e.from'. This snippet appears to be part of a graph traversal or processing algorithm. ```java countEdgesProcessed[e.from]++; break; } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.