[med-svn] [Git][med-team/logol][upstream] New upstream version 1.7.8

Olivier Sallou gitlab at salsa.debian.org
Wed Apr 4 14:43:15 BST 2018


Olivier Sallou pushed to branch upstream at Debian Med / logol


Commits:
50db23f5 by Olivier Sallou at 2018-04-04T13:32:58+00:00
New upstream version 1.7.8
- - - - -


7 changed files:

- CHANGELOG.txt
- build.xml
- prolog/logol.pl
- src/org/irisa/genouest/logol/SequenceAnalyser.java
- src/org/irisa/genouest/logol/test/GrammarTest.java
- + test/end_of_stream1.logol
- + test/end_of_stream2.logol


Changes:

=====================================
CHANGELOG.txt
=====================================
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,6 @@
 History:
+1.7.8: 03/04/18 O. Sallou - Detect process execution failure (out of memory, etc.) and display error message
+1.7.7: 08/12/17 O. Sallou - Fix *not* and *spacer* contraints when reaching end of sequence (last characters)
 1.7.6: 07/12/17 O. Sallou - Fix endConstraint, was comparing end position + 1 instead of end position
 1.7.5: 09/09/16 O. Sallou - Fix way to load characters from sequence file to increase performance
 1.7.4: 08/01/16 O. Sallou - Fix multiexec error message display


=====================================
build.xml
=====================================
--- a/build.xml
+++ b/build.xml
@@ -10,7 +10,7 @@
             target.dir=/path_where_files_should_be_installed
 	 -->
 
-	<property name="version" value="1.7.6" />
+	<property name="version" value="1.7.8" />
 
 	<condition property="ruby_path" value="${env.RUBY_PATH}"
 		else="">


=====================================
prolog/logol.pl
=====================================
--- a/prolog/logol.pl
+++ b/prolog/logol.pl
@@ -1013,7 +1013,8 @@ spacer_withresult([X|Y],Min, Max, Word, Z) :- (((Min=0,NewX=[X|Y]);(Min>0,cut_se
 %spacer_withresult([X|Y],Min, Max, Z, Word) :- N is 0,((Min=0,Z=[X | Y]);(spacer_withresult([X|Y],N,Min,Max,Z,[], Word))).
 
 % sub predicate, do not call directly
-spacer_withresult([], N, Min, Max, Z, Spacer, Word) :- fail.
+%spacer_withresult([], N, Min, Max, Z, Spacer, Word) :- fail.
+spacer_withresult([], N, Min, Max, Z, Spacer, Word) :- Word=Spacer.
 % sub predicate, do not call directly
 %spacer_withresult([X|Y],N, Min, Max, Z, Spacer, Word) :- Ninc is N+1,append(Spacer, [X], IncWord),((Ninc<Max,isalphabet(X), spacer_withresult(Y,Ninc,Min,Max,Z,IncWord, Word));(Ninc>=Min,Z = Y, Word=IncWord)).
 spacer_withresult([X|Y],N, Min, Max, Z, Spacer, Word) :-  (Z = [X |Y], Word=Spacer); (Ninc is N+1,append(Spacer, [X], IncWord),Ninc=<Max, spacer_withresult(Y,Ninc,Min,Max,Z,IncWord, Word)).
@@ -2459,7 +2460,7 @@ between(Min,Cur,Max,Value):-Cur=<Max,(Value=Cur;Next is Cur + 1,between(Min,Next
 % Fix 1406
 % Call predicate. If match, return last argument e.g. position, else return 0.
 callpred(Pred,OutPos,Pos):- (Pred ,(Pred=..VarDef,nth0(OutPos,VarDef,Pos)));(Pos=0).
-notpred_pos(VarId,StartPos,Pred,Min,Max,Value):-random(Id),retractall(hasmatch(Id,_)),Pred=..VarDef,length(VarDef,Predlength),OutPos is Predlength - 1,PosMin is StartPos + Min, PosMax is StartPos + Max,!,between(StartPos,PosMax,Value),(callpred(Pred,OutPos,Pos) , ((\+hasmatch(Id,Pos) -> (assert(hasmatch(Id,Pos)));1=1),\+hasmatch(Id,Value),assert(hasmatch(Id,Value)))),Value>=PosMin.
+notpred_pos(VarId,StartPos,Pred,Min,Max,OutputPos):-random(Id),retractall(hasmatch(Id,_)),Pred=..VarDef,length(VarDef,Predlength),OutPos is Predlength - 1,PosMin is StartPos + Min, PosMax is StartPos + Max,!,between(StartPos,PosMax,Value),(callpred(Pred,OutPos,Pos) , ((\+hasmatch(Id,Pos) -> (assert(hasmatch(Id,Pos)));1=1),\+hasmatch(Id,Value),assert(hasmatch(Id,Value)))),Value>=PosMin,ValueLength is Value - StartPos,getCharsFromPosition(StartPos,ValueLength,FoundWord),length(FoundWord,FoundLength),FoundLength >= Min, FoundLength=<Max, OutputPos is StartPos+FoundLength.
 
 
 % Test predicate to use with predicate requiring a position relative predicate as parameter.


=====================================
src/org/irisa/genouest/logol/SequenceAnalyser.java
=====================================
--- a/src/org/irisa/genouest/logol/SequenceAnalyser.java
+++ b/src/org/irisa/genouest/logol/SequenceAnalyser.java
@@ -22,7 +22,7 @@ import org.irisa.genouest.logol.utils.MySequence;
 public class SequenceAnalyser extends Thread {
 
 	private static final Logger logger = Logger.getLogger(org.irisa.genouest.logol.SequenceAnalyser.class);
-	
+
 	String executable=null;
 	String prologFile=null;
 	String savFile=null;
@@ -35,12 +35,12 @@ public class SequenceAnalyser extends Thread {
     long sequenceId;
     int status=0;
     String msg=null;
-    
+
     String resultFileName=null;
     String maxSolutions=null;
-    
+
     int minTreeIndex=2;
-    
+
     Sequence sequence=null;
 
 
@@ -54,18 +54,18 @@ public class SequenceAnalyser extends Thread {
     	endOffset=end;
     	sequenceId=0;
     	sequenceOffset=offset;
-    	
+
     	outputFile=output+".fasta";
     	logger.debug("output file = "+outputFile);
 
     	maxSolutions=max;
-    	
-    	
-    	
+
+
+
     }
-	  
-    
-    
+
+
+
     SequenceAnalyser(String exec,String proFile,String savFilePath,String sequence,String header,long start,long end,String output, String max,int offset) {
     	executable = exec;
     	prologFile=proFile;
@@ -77,7 +77,7 @@ public class SequenceAnalyser extends Thread {
     	endOffset=end;
     	sequenceId=0;
     	sequenceOffset=offset;
-    	
+
     	outputFile=output+".fasta";
     	logger.debug("output file = "+outputFile);
 
@@ -87,9 +87,9 @@ public class SequenceAnalyser extends Thread {
     public void run() {
     	logger.debug("Start thread for file sequence "+sequenceId);
     	// read and save partial file
-    	
-    	long lv_startTime = System.currentTimeMillis(); 
-    	
+
+    	long lv_startTime = System.currentTimeMillis();
+
     	try {
 			//rewriteSequence(sequenceFileName,outputFile,startOffset,endOffset);
       	  	File outFile = new File(outputFile);
@@ -101,7 +101,7 @@ public class SequenceAnalyser extends Thread {
     		BufferedReader br = new BufferedReader(new FileReader(outputFile));
     		headerFile = br.readLine();
     		br.close();
-    		
+
     		// Create a file if type is RNA or DNA so that external scripts know the type of sequence
     		if(Treatment.dataType==Constants.DNA || Treatment.dataType==Constants.RNA) {
     			FileWriter typeFile = new FileWriter(outputFile+".index.dna");
@@ -109,11 +109,11 @@ public class SequenceAnalyser extends Thread {
     			dnaos.write("dna/rna");
     			dnaos.close();
     		}
-    		
+
 		} catch (IOException e1) {
 			logger.error("Error while rewriting sequence file "+e1.getMessage());
 		}
-    	
+
     	//create tree
         try {
 			createTree();
@@ -122,7 +122,7 @@ public class SequenceAnalyser extends Thread {
 			msg="Coudld not make tree for suffix array: "+e.getMessage();
 			return;
 		}
-		
+
         try {
 			callProgram();
 		} catch (IOException e) {
@@ -130,66 +130,66 @@ public class SequenceAnalyser extends Thread {
 			msg="Coudld not execute program: "+e.getMessage();
 			return;
 		}
-		
+
 		long lv_endTime = System.currentTimeMillis();
-		
+
 		logger.debug("Thread for "+outputFile+" terminated in "+(lv_endTime-lv_startTime));
-		
+
     }
 
-    
+
     @Deprecated
     private void rewriteSequence(String sequenceFileName,String outputFile,long startOffset, long endOffset) throws IOException {
-	
-    
+
+
         FileWriter out = new FileWriter(outputFile);
         BufferedWriter bw = new BufferedWriter(out);
         int record;
-       
+
         File wholeSequence = new File(sequenceFileName);
         RandomAccessFile input = new RandomAccessFile(wholeSequence,"r");
-		
-		
-		
+
+
+
 		long size=0;
-		
+
 		bw.write(headerFile+"\n");
-		
+
 		if(endOffset>startOffset) {
 		// reading in left to right
-		input.seek(startOffset);			
-			
-		while((size<(endOffset-startOffset)) && (record = input.read())!=-1) {				
+		input.seek(startOffset);
+
+		while((size<(endOffset-startOffset)) && (record = input.read())!=-1) {
 			size++;
 	     	if(Character.isLetter(record)) {
-	     		
+
 	         	   bw.write(Character.toLowerCase(record));
 	         	  }
-		}      
-		
+		}
+
 		}
 		else {
-			input.seek(startOffset-1);	
+			input.seek(startOffset-1);
 			long pos=startOffset-1;
-			while((size<(startOffset-endOffset)) && (record = input.read())!=-1) {				
+			while((size<(startOffset-endOffset)) && (record = input.read())!=-1) {
 				size++;
 				pos--;
 		     	if(Character.isLetter(record)) {
 		         	   bw.write(Character.toLowerCase(record));
 		         	  }
 		     	input.seek(pos);
-			} 
-			
-			
+			}
+
+
 		}
-       
+
         bw.close();
         input.close();
     }
-    
-    
+
+
 	private void callProgram() throws IOException {
-		Runtime runtime = Runtime.getRuntime(); 
+		Runtime runtime = Runtime.getRuntime();
 		long fileOffset= startOffset;
 		if(endOffset<startOffset) {
 			fileOffset = endOffset;
@@ -197,33 +197,38 @@ public class SequenceAnalyser extends Thread {
 		//long offset = sequenceOffset + fileOffset - headerFile.length();
 		//TODO CHECK offset is ok
 		long offset = sequenceOffset + fileOffset;
-				
+
 		String parameters = " "+outputFile+" "+resultFileName+" "+maxSolutions+" "+offset+" "+headerFile.getBytes().length;
 		//FIXME to use global exe, add logol generated file as parameter and call logol.exe in prolog dir
 		parameters+=" "+prologFile+" "+savFile;
-		
+
 		logger.debug("Call program with params: "+parameters);
-		
+
 		Process logol = runtime.exec(executable+parameters);
         try {
         	PrintStream os = new PrintStream(logol.getOutputStream());
         	os.println("");
         	os.flush();
-        	        	
+
         	StreamGobbler s1 = new StreamGobbler ("stdin", logol.getInputStream ());
         	StreamGobbler s2 = new StreamGobbler ("stderr", logol.getErrorStream ());
         	s1.start ();
         	s2.start ();
         	logger.debug("start program execution ");
         	logol.waitFor();
-        	
+			int status_code = logol.exitValue();
+			if(status_code != 0){
+				logger.error("Program exited with wrong status code: " + status_code);
+				throw new IOException("Program exited with wrong status code");
+			}
+
 			logger.debug("program is over, results are available in file "+resultFileName);
 			os.close();
 
 		} catch (InterruptedException e) {
 			logger.error("Error during execution "+ e.getMessage());
-		} 		
-		
+		}
+
 	}
 
 	private void createTree() throws IOException {
@@ -234,17 +239,17 @@ public class SequenceAnalyser extends Thread {
 		case 2: { lv_type="protein"; break; }
 		}
 	 	logger.debug("Create tree for "+outputFile);
-		
+
 	 	String suffixPath="";
-	 	if(Logol.getSuffixPath()!=null) {	 		
+	 	if(Logol.getSuffixPath()!=null) {
 	 		suffixPath=Logol.getSuffixPath()+System.getProperty(Constants.FILESEPARATORPROPERTY);
 	 		logger.debug("Create tree with path: "+suffixPath);
 	 	}
 	 	else {
 	 		logger.warn("Path to suffix search tool is not set in system environment. Will try to execute directly but may fail if not in PATH of current user");
 	 	}
-	 	
-	 	Runtime runtime = Runtime.getRuntime();      
+
+	 	Runtime runtime = Runtime.getRuntime();
 	 	String command = null;
 	 	switch(Logol.getSuffixTool()) {
 	 	case 0:
@@ -276,7 +281,7 @@ public class SequenceAnalyser extends Thread {
 	 			PrintStream os = new PrintStream(mkvtree.getOutputStream());
 	 			os.println("");
 	 			os.flush();
-        	        	
+
 	 			StreamGobbler s1 = new StreamGobbler ("stdin", mkvtree.getInputStream ());
 	 			StreamGobbler s2 = new StreamGobbler ("stderr", mkvtree.getErrorStream ());
 	 			s1.start ();
@@ -294,7 +299,7 @@ public class SequenceAnalyser extends Thread {
 	 			logger.error("could not create Tree "+ e.getMessage());
 	 		}
 	 	}
-		
+
 	}
 
 }


=====================================
src/org/irisa/genouest/logol/test/GrammarTest.java
=====================================
--- a/src/org/irisa/genouest/logol/test/GrammarTest.java
+++ b/src/org/irisa/genouest/logol/test/GrammarTest.java
@@ -2350,6 +2350,52 @@ public class GrammarTest {
             }
         }
 
+		@Test
+        public void testEndOfStream1() {
+
+            init();
+
+            Vector<String[]> result = new Vector<String[]>();
+            result.add(new String[] {"LogolVAR_1","32","38"});
+			result.add(new String[] {"LogolVAR_2","39","40"});
+            execute("test.fasta","end_of_stream1.logol");
+
+            try {
+                checkResult(result,0);
+            } catch (ParserConfigurationException e) {
+                fail(e.getMessage());
+            } catch (SAXException e) {
+                fail(e.getMessage());
+            } catch (IOException e) {
+                fail(e.getMessage());
+            } catch (TransformerException e) {
+                fail(e.getMessage());
+            }
+        }
+
+		@Test
+        public void testEndOfStream2() {
+
+            init();
+
+            Vector<String[]> result = new Vector<String[]>();
+            result.add(new String[] {"LogolVAR_1","32","38"});
+			result.add(new String[] {"LogolVAR_2","39","40"});
+            execute("test.fasta","end_of_stream2.logol");
+
+            try {
+                checkNoMatch(result,0);
+            } catch (ParserConfigurationException e) {
+                fail(e.getMessage());
+            } catch (SAXException e) {
+                fail(e.getMessage());
+            } catch (IOException e) {
+                fail(e.getMessage());
+            } catch (TransformerException e) {
+                fail(e.getMessage());
+            }
+        }
+
    	 @Test
    	 public void testRubyCassiopee() {
 		try {


=====================================
test/end_of_stream1.logol
=====================================
--- /dev/null
+++ b/test/end_of_stream1.logol
@@ -0,0 +1,6 @@
+def:{
+morphism(foo,a,g)
+}
+mod1()==>"ccaccat",!("taa"|"tga"|"tag"):{#[2,2]}
+
+mod1()==*>SEQ1


=====================================
test/end_of_stream2.logol
=====================================
--- /dev/null
+++ b/test/end_of_stream2.logol
@@ -0,0 +1,6 @@
+def:{
+morphism(foo,a,g)
+}
+mod1()==>"ccaccat",!("taa"|"tga"|"tag"):{#[3,3]}
+
+mod1()==*>SEQ1



View it on GitLab: https://salsa.debian.org/med-team/logol/commit/50db23f56adec027e18a7e8afea362305dfe1703

---
View it on GitLab: https://salsa.debian.org/med-team/logol/commit/50db23f56adec027e18a7e8afea362305dfe1703
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debian-med-commit/attachments/20180404/f9a31c90/attachment-0001.html>


More information about the debian-med-commit mailing list