From 6cafb1a0e3974d406e158fcea8ed9ee4f3ec92c3 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sun, 16 Feb 2025 04:51:03 +0000 Subject: [PATCH] style: format code with Autopep8 and Google Java Format This commit fixes the style issues introduced in 54c8306 according to the output from Autopep8 and Google Java Format. Details: None --- .../java/DNAnalyzer/core/DNAMutation.java | 47 +++++++++---------- src/main/java/DNAnalyzer/ui/cli/CmdArgs.java | 17 ++++--- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/DNAnalyzer/core/DNAMutation.java b/src/main/java/DNAnalyzer/core/DNAMutation.java index ca4f1fa1..ac823e74 100644 --- a/src/main/java/DNAnalyzer/core/DNAMutation.java +++ b/src/main/java/DNAnalyzer/core/DNAMutation.java @@ -1,35 +1,30 @@ package DNAnalyzer.core; -import java.util.Random; - import DNAnalyzer.utils.core.DNATools; - +import java.io.FileWriter; import java.io.IOException; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.List; -import java.io.FileWriter; import java.util.Date; +import java.util.List; +import java.util.Random; -/** - * This class provides provides functionality for generating mutated DNA - * sequences. - */ +/** This class provides provides functionality for generating mutated DNA sequences. */ public class DNAMutation { - private static final char[] BASES = { 'A', 'T', 'C', 'G', 'N' }; + private static final char[] BASES = {'A', 'T', 'C', 'G', 'N'}; private static Random random = new Random(); /** - * Generates a list of 10 mutated DNA sequences based on the specified number of - * base mutations and prints them to the console. - * - * @param dnaString Original DNA sequence to mutate - * @param numMutations The number of base mutations to apply to each mutated - * sequence + * Generates a list of 10 mutated DNA sequences based on the specified number of base mutations + * and prints them to the console. + * + * @param dnaString Original DNA sequence to mutate + * @param numMutations The number of base mutations to apply to each mutated sequence */ - public static void generateAndWriteMutatedSequences(String dnaString, int numMutations, PrintStream out) { + public static void generateAndWriteMutatedSequences( + String dnaString, int numMutations, PrintStream out) { List mutatedSequences = new ArrayList<>(); out.println("\nMutating DNA sequence..."); @@ -47,12 +42,13 @@ public static void generateAndWriteMutatedSequences(String dnaString, int numMut // Write the mutated sequences to a file try (FileWriter writer = new FileWriter(fileName)) { for (int i = 0; i < mutatedSequences.size(); i++) { - writer.write(">mutation_" + (i + 1) + "\n"); // Write a header for each mutated sequence + writer.write(">mutation_" + (i + 1) + "\n"); // Write a header for each mutated sequence String mutatedSequence = mutatedSequences.get(i); - + // Write the sequence over multiple lines (e.g., 80 characters per line) for (int j = 0; j < mutatedSequence.length(); j += 80) { - writer.write(mutatedSequence.substring(j, Math.min(j + 80, mutatedSequence.length())) + "\n"); + writer.write( + mutatedSequence.substring(j, Math.min(j + 80, mutatedSequence.length())) + "\n"); } } out.println("Mutated DNA sequences have been written to: " + fileName + "\n"); @@ -64,16 +60,17 @@ public static void generateAndWriteMutatedSequences(String dnaString, int numMut /** * Mutates a DNA sequence with a specified number of random base mutations. * - * @param dnaString Original DNA sequence to mutate - * @param numMutations The number of mutations (substitutions) to apply to the - * sequence + * @param dnaString Original DNA sequence to mutate + * @param numMutations The number of mutations (substitutions) to apply to the sequence * @return A new mutated DNA sequence */ private static String mutate(String dnaString, int numMutations) { StringBuilder mutatedDna = new StringBuilder(dnaString); if (numMutations > mutatedDna.length()) { - System.out.println("Warning: Number of requested mutations exceeds DNA length. Limiting to " + mutatedDna.length()); + System.out.println( + "Warning: Number of requested mutations exceeds DNA length. Limiting to " + + mutatedDna.length()); numMutations = mutatedDna.length(); } @@ -108,7 +105,7 @@ private static char getDifferentBase(char originalBase) { int index = new String(BASES).indexOf(originalBase); // Pick a random index that isn’t the same as the original - int newIndex = (index + 1 + random.nextInt(BASES.length - 1)) % BASES.length; + int newIndex = (index + 1 + random.nextInt(BASES.length - 1)) % BASES.length; return BASES[newIndex]; } diff --git a/src/main/java/DNAnalyzer/ui/cli/CmdArgs.java b/src/main/java/DNAnalyzer/ui/cli/CmdArgs.java index bfbcbf7a..e30e3630 100644 --- a/src/main/java/DNAnalyzer/ui/cli/CmdArgs.java +++ b/src/main/java/DNAnalyzer/ui/cli/CmdArgs.java @@ -11,17 +11,17 @@ package DNAnalyzer.ui.cli; -import java.io.File; -import java.io.IOException; -import java.util.Objects; +import static DNAnalyzer.data.Parser.parseFile; import DNAnalyzer.core.DNAAnalysis; -import DNAnalyzer.core.Properties; import DNAnalyzer.core.DNAMutation; -import static DNAnalyzer.data.Parser.parseFile; +import DNAnalyzer.core.Properties; import DNAnalyzer.ui.gui.DNAnalyzerGUI; import DNAnalyzer.utils.core.DNATools; import DNAnalyzer.utils.core.Utils; +import java.io.File; +import java.io.IOException; +import java.util.Objects; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.Parameters; @@ -92,7 +92,9 @@ public class CmdArgs implements Runnable { @Option( names = {"--mutate"}, - description = "Generates 10 mutations of the DNA sequence, each with the specified number of mutations, and saves them to a file.") + description = + "Generates 10 mutations of the DNA sequence, each with the specified number of mutations," + + " and saves them to a file.") int mutationCount = 0; @Option( @@ -134,7 +136,8 @@ public void run() { DNAAnalysis dnaAnalyzer = dnaAnalyzer(aminoAcid).isValidDna().replaceDNA("u", "t"); if (mutationCount > 0) { - DNAMutation.generateAndWriteMutatedSequences(dnaAnalyzer.dna().getDna(), mutationCount, System.out); + DNAMutation.generateAndWriteMutatedSequences( + dnaAnalyzer.dna().getDna(), mutationCount, System.out); } if (reverse) {