ur_rna.StructureEditor.services.fileIO

## Class RnaFileIO

- java.lang.Object
- - ur_rna.StructureEditor.services.fileIO.RnaFileIO

-     public class RnaFileIO
      extends java.lang.Object

  RnaFileIO is used to load and save RNA files (CT, SEQ etc)

  This is a further abstraction of the RNA Backend class. It is a mixture of backend (c++) and Java-based functions. Ideally, we would go the opposite route--integrate the backend classes into the java program to make the distinction as seamless as possible, but unfortunately the backend c++ is too brittle, and adding the necessary features to the c++ classes might have a performance impact for the command-line interfaces.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `RnaFileIO.AsyncTask<TResult>`
    `static class` | `RnaFileIO.BackendCalc<TResult>` A task that is run in the RNAstructure Backend (JNI).
    `static class` | `RnaFileIO.BackgroundWork<TResult>`
    `(package private) static class` | `RnaFileIO.NucIndexConverter` The backend uses "III" (or some other character in extended nucleobase alphabets) to indicate an inter-molecular linker.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ALPHABET_RNA`
    `private static java.lang.String` | `DATA_PATH`
    `static char` | `InterMolecularBreakChar`
    `static int` | `InterMolecularBreakLength`
    `static java.lang.String` | `InterMolecularBreakStr`
    `private static AppLog` | `log`
    `static int` | `MAX_SEQUENCE_LENGTH`
    `static int` | `SEQUENCE_FMT_FASTA`
    `static int` | `SEQUENCE_FMT_SEQ`
    `static int` | `SEQUENCE_FMT_TEXT`
    `(package private) static java.util.regex.Pattern` | `stripEnergyTitleRegex`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RnaFileIO()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static int` | `backendPairIndex(Nuc n)`
    `static void` | `breakBackendPseudoknots(RnaScene scene, RNA rna, int structureNumber)`
    `static double` | `calculateEnergy(RnaScene scene)` Calculates the free energy of the structure in kcal/mol
    `private static void` | `checkErrors(RNA rna, java.lang.String operation)`
    `static void` | `checkForErrors(RNA rna)`
    `static RNA` | `createRNAfromScene(RnaScene scene, boolean includePairs, boolean allowUnknownBases, boolean skipThermo)`
    `static RnaScene` | `createSceneFromRNA(RNA rna, int structureIndex, boolean includeBonds)` Create new RnaScene from an RNA structure.
    `private static int` | `defaultWindowSize(RNA rna)`
    `static RnaFileIO.BackendCalc<RnaSceneGroup>` | `foldSeq(java.lang.String sequence, int maxStructures)`
    `static boolean` | `getBestOrientation(double[] oldVals, double[] newVals, double[] params, double allowedError)`
    `private static java.lang.String` | `getDataPath()`
    `static java.lang.String` | `getInterStrandLinker()`
    `static java.lang.String` | `getRNASequence(RnaScene scene)`
    `static RnaSceneGroup` | `getRNAstructureGroup(RNA rna)`
    `static int` | `getRNAType(FileType type)`
    `static java.lang.String` | `getStructureTitle(RNA rna, int structureIndex)`
    `static void` | `identifyPseudoKnotsBackend(RnaScene scene)`
    `static boolean` | `isInterStrandLinker(char c)`
    `static RnaSceneGroup` | `readFileAsScene(java.lang.String path, FileType type)`
    `static void` | `setStructureTitle(RNA rna, int structureIndex, java.lang.String title)`
    `static void` | `splitStrandsAtLinkers(RnaScene scene)`
    `static java.lang.String` | `stripEnergyTitle(java.lang.String title)`
    `protected static void` | `updateBackendBonds(RnaScene scene, RNA rna, int structureIndex)` Clear the RNA structure's bonds and re-read them from the RnaScene.
    `protected static void` | `updateSceneBonds(RnaScene scene, RNA rna, int structureIndex)` Clear the RnaScene's bonds and re-write them from the RNA structure.
    `private static boolean` | `verifyDataFiles(java.lang.String path)`
    `private static void` | `verifyDataPath()`
    `static RNA` | `writeRNAstructureGroup(RnaSceneGroup scenes, boolean allowUnknownBases, boolean skipThermo)`
    `static boolean` | `writeSequenceFile(RnaScene scene, java.lang.String path, FileType type, boolean append)`
    `static boolean` | `writeStructureFile(RnaSceneGroup scenes, java.lang.String path, FileType type, boolean append)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ALPHABET_RNA

          public static final java.lang.String ALPHABET_RNA

      See Also:
        Constant Field Values

    - #### DATA_PATH

          private static java.lang.String DATA_PATH

    - #### InterMolecularBreakChar

          public static final char InterMolecularBreakChar

      See Also:
        Constant Field Values

    - #### InterMolecularBreakLength

          public static final int InterMolecularBreakLength

    - #### InterMolecularBreakStr

          public static final java.lang.String InterMolecularBreakStr

      See Also:
        Constant Field Values

    - #### log

          private static final AppLog log

    - #### MAX_SEQUENCE_LENGTH

          public static final int MAX_SEQUENCE_LENGTH

      See Also:
        Constant Field Values

    - #### SEQUENCE_FMT_FASTA

          public static final int SEQUENCE_FMT_FASTA

      See Also:
        Constant Field Values

    - #### SEQUENCE_FMT_SEQ

          public static final int SEQUENCE_FMT_SEQ

      See Also:
        Constant Field Values

    - #### SEQUENCE_FMT_TEXT

          public static final int SEQUENCE_FMT_TEXT

      See Also:
        Constant Field Values

    - #### stripEnergyTitleRegex

          static java.util.regex.Pattern stripEnergyTitleRegex

  - ### Constructor Detail

    - #### RnaFileIO

          public RnaFileIO()

  - ### Method Detail

    - #### backendPairIndex

          private static int backendPairIndex(Nuc n)

    - #### breakBackendPseudoknots

          public static void breakBackendPseudoknots(RnaScene scene,
                                                     RNA rna,
                                                     int structureNumber)

    - #### calculateEnergy

          public static double calculateEnergy(RnaScene scene)
                                        throws RnaBackendException

      Calculates the free energy of the structure in kcal/mol
      Throws:
        `RnaBackendException`

    - #### checkErrors

          private static void checkErrors(RNA rna,
                                          java.lang.String operation)
                                   throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### checkForErrors

          public static void checkForErrors(RNA rna)
                                     throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### createRNAfromScene

          public static RNA createRNAfromScene(RnaScene scene,
                                               boolean includePairs,
                                               boolean allowUnknownBases,
                                               boolean skipThermo)
                                        throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### createSceneFromRNA

          public static RnaScene createSceneFromRNA(RNA rna,
                                                    int structureIndex,
                                                    boolean includeBonds)
                                             throws RnaBackendException

      Create new RnaScene from an RNA structure.
      Throws:
        `RnaBackendException`

    - #### defaultWindowSize

          private static int defaultWindowSize(RNA rna)

    - #### foldSeq

          public static RnaFileIO.BackendCalc<RnaSceneGroup> foldSeq(java.lang.String sequence,
                                                                     int maxStructures)

    - #### getBestOrientation

          public static boolean getBestOrientation(double[] oldVals,
                                                   double[] newVals,
                                                   double[] params,
                                                   double allowedError)

    - #### getDataPath

          private static java.lang.String getDataPath()

    - #### getInterStrandLinker

          public static java.lang.String getInterStrandLinker()

    - #### getRNASequence

          public static java.lang.String getRNASequence(RnaScene scene)

    - #### getRNAstructureGroup

          public static RnaSceneGroup getRNAstructureGroup(RNA rna)
                                                    throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### getRNAType

          public static int getRNAType(FileType type)

    - #### getStructureTitle

          public static java.lang.String getStructureTitle(RNA rna,
                                                           int structureIndex)

    - #### identifyPseudoKnotsBackend

          public static void identifyPseudoKnotsBackend(RnaScene scene)
                                                 throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### isInterStrandLinker

          public static boolean isInterStrandLinker(char c)

    - #### readFileAsScene

          public static RnaSceneGroup readFileAsScene(java.lang.String path,
                                                      FileType type)
                                               throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### setStructureTitle

          public static void setStructureTitle(RNA rna,
                                               int structureIndex,
                                               java.lang.String title)

    - #### splitStrandsAtLinkers

          public static void splitStrandsAtLinkers(RnaScene scene)

    - #### stripEnergyTitle

          public static java.lang.String stripEnergyTitle(java.lang.String title)

    - #### updateBackendBonds

          protected static void updateBackendBonds(RnaScene scene,
                                                   RNA rna,
                                                   int structureIndex)

      Clear the RNA structure's bonds and re-read them from the RnaScene.

    - #### updateSceneBonds

          protected static void updateSceneBonds(RnaScene scene,
                                                 RNA rna,
                                                 int structureIndex)

      Clear the RnaScene's bonds and re-write them from the RNA structure.

    - #### verifyDataFiles

          private static boolean verifyDataFiles(java.lang.String path)

    - #### verifyDataPath

          private static void verifyDataPath()
                                      throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### writeRNAstructureGroup

          public static RNA writeRNAstructureGroup(RnaSceneGroup scenes,
                                                   boolean allowUnknownBases,
                                                   boolean skipThermo)
                                            throws RnaBackendException

      Throws:
        `RnaBackendException`

    - #### writeSequenceFile

          public static boolean writeSequenceFile(RnaScene scene,
                                                  java.lang.String path,
                                                  FileType type,
                                                  boolean append)
                                           throws RnaBackendException,
                                                  java.io.IOException

      Throws:
        `RnaBackendException`
        `java.io.IOException`

    - #### writeStructureFile

          public static boolean writeStructureFile(RnaSceneGroup scenes,
                                                   java.lang.String path,
                                                   FileType type,
                                                   boolean append)
                                            throws java.io.IOException,
                                                   RnaBackendException

      Throws:
        `java.io.IOException`
        `RnaBackendException`