How to create a new duplex structure

1) Create a new package with the name of the structure.

2) Create a new instance variable private static HashMap<String, Class<? extends PatternComputationMethod» newStructureMethod of the class RegisterMethods in the melting.configuration package.

/**
* HasMap newStructureMethod : contains all the methods 
* for the new structure computation.
*/
	private static HashMap<String, Class<? extends 
	        PatternComputationMethod>> newStructureMethod = 
	new HashMap<String, Class<? extends PatternComputationMethod>>();

3) Create a new method in the RegisterMethod class to initialise the <String, Class<? extends PatternComputationMethod» newStructureMethod you created. It must contains all the relationships between the new model names and the matching implemented class:

private void initialisenewStructureMethods(){
		newStructureMethod.put("model1-Name", classModel1-Name.class);
		newStructureMethod.put("model2-Name", classModel2-Name.class);
		newStructureMethod.put("model3-Name", classModel3-Name.class);
		[...]
	}

4) Call this method in the constructor of RegisterMethod :

public RegisterMethods(){
		[...]
		
		initialisenewStructureMethods();
	}

5) Create a new public static final String as instance variable of the OptionManagement class in the melting.configuration package. This String represents the new option name you choose to change the default model used to compute the new structure.

/**
* Option name to choose another method to compute the 
* new structure.
*/
	public static final String newStructureOption-Name = 
	                                       "option-name";

6) Fix the default model name to use for each type of hybridization. You have to add the following lines into the following methods of OptionManagement :

/**
* initialises the DNADefaultOptions HashMap of the 
* OptionManagement object.
*/
	private void initialisesDNADefaultOptions() {
		[...]
		this.DNADefaultOptions.put(newStructureOption-Name, 
		                          "DNA-defaultModel-Name");

	}
	
/**
* initialises the RNADefaultOptions HashMap of the 
* OptionManagement object.
*/
	private void initialiseRNADefaultOptions() {
		[...]
		this.RNADefaultOptions.put(newStructureOption-Name, 
		                          "RNA-defaultModel-Name");

	}
	
/**
* initialises the hybridDefaultOptions HashMap of the 
* OptionManagement object.
*/
	private void initialiseHybridDefaultOptions() {
		[...]
		this.hybridDefaultOptions.put(newStructureOption-Name, 
		                         "DNA/RNA-defaultModel-Name");
		
	}
	
/**
* initialises the mRNADefaultOptions HashMap of the 
* OptionManagement object.
*/
	private void initialiseMRNADefaultOptions() {
		[...]
		this.mRNADefaultOptions.put(newStructureOption-Name, 
		                          "mRNA-defaultModel-Name");

	}

7) Register the new option in the HashMap registerPatternModels of OptionManagement. You just have to add this following line into the method private void initialiseRegisterPatternModels() of OptionManagement :

/**
* Initialises the registerPatternModels HashMap of the OptionManagement object.
*/
private void initialiseRegisterPatternModels(){
	[...]
		
registerPatternModels.add(newStructureOption-Name);
}

8) Add in the method private void initialisePatternModels() of RegsiterMethods the following line to register the new structure.

	private void initialisePatternModels(){
		[...]
		
		// It creates a relationship between the option name 
		// for the new structure and the HashMap containing 
		// the models and the class which can compute the new 
		// structure.
		PatternModel.put(OptionManagement.newStructureMethod, 
		                                 newStructureMethod);

9) Add a new method in the NucleotiSequences class in the melting.sequences package to be abble to recognize if a structure between two positions in the duplex matches the new structure you created.

// new method to recognize the new structure in the duplex
public boolean isNewStructure(int pos1, int pos2){

[if the subsequences between the positions pos1 and pos2
in the duplex match the new structure, you must return true.]

}

10) Create a new private PatternComputationMethod instance variable in the NearestNeighborMode class in the melting.nearestNeighborMode package. This new instance represents an object PatternComputationMethod which is a new instance of one of your implemented class which can compute the new structure.

/**
* PatternComputationMethod newStructureMethod : represents 
* the model for new structure computation.
*/
	private PatternComputationMethod newStructureMethod;

11) Create a new method in the NearestNeighborMode class to initialise the PatternComputationMethod newStructureMethod :

private void initialiseNewStructureMethod(){
		// Get the option name (public static final instance 
		// variable of OptionManagement) which allows to change 
		// the model to compute the new structure.
		String optionName = OptionManagement.newStructureOption-Name;
		
		// Get the model name (model name) which allows to change 
		// the model to compute the new structure and initialise the 
		// PatternComputationMethod newStructureMethod.
		String methodName = this.environment.getOptions().get(optionName);
		this.newStructureMethod = initialiseMethod(optionName, methodName);
	}

12) If the new structure you added contains perfectly matching base pairs, maybe you have to change the method private int [] getPositionsPattern(int pos1) of the NearestNeighborMode class.

This method defines the positions of a structure in the duplex (a perfectly matching structure or a structure composed of non perfectly matching base pairs or composed of modified nucleic acid(s)).

If you need the adjacent base pairs to the non perfectly matching base pair or the modified nucleic acid, you can add a method which corrects the positions of the structure in the duplex, in the class computing the new structure. (see the following example and the Javadoc)

private int[] correctPositions(int pos1, int pos2, 
                                int duplexLength){
		if (pos1 > 0){
			pos1 --;
		}
		if (pos2 < duplexLength - 1){
			pos2 ++;
		}
		int [] positions = {pos1, pos2};
		return positions;
	}

13) Change the method private PatternComputationMethod getAppropriatePatternModel(int [] positions) of NearestNeighborMode to add your new structure initialisation.

// Method to get the adapted PatternComputationMethod to 
// compute the structure defined at the positions int [] 
// positions.
private PatternComputationMethod getAppropriatePatternModel
                                        (int [] positions){

// if the new structure is always a terminal structure, you 
// can change the method here.
if (positions[0] == 0 || positions[1] == 
         environment.getSequences().getDuplexLength() - 1){

[...]
  // call the NucleotidSequences method to recognize the identity 
  // of the new structure
  else if (environment.getSequences().isNewStructure(positions[0], 
                                                   positions[1])){
  
    if (this.newStructureMethod == null){
		initialiseNewStructureMethod(); // initialise the 
		                                //PatternComputationMethod
		                                // newStructureMethod
	}
	return this.newStructureMethod;
  }
}

// if the structure is not always a terminal structure, you can 
// change the method here.
[...]

  // call the NucleotidSequences method to recognize the identity 
  // of the new structure
  else if (environment.getSequences().isNewStructure(positions[0], 
                                                   positions[1])){
  
    if (this.newStructureMethod == null){
		initialiseNewStructureMethod(); // initialise the 
		                                //PatternComputationMethod
		                                // newStructureMethod
	}
	return this.newStructureMethod;
  }
  [...]
}

14) Create the new class(es) representing your model(s) for the new structure as it is explained in the section How to add new thermodynamic model.

Computational Neurobiology 2009-08-24