Bonjour.
J'écris actuellement un code qui fouille dans un fichier texte et retourne des occurences associées au terme recherché.
Voici l'exemple d'une ligne d'intérêt :
Les éléments que je veux récupérer sont ceux que j'ai soulignés et mis en gras dans mon exemple.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 c004fnq.1 NM_005840 SPRY3 MIMAT0005873 hsa-miR-1208 aggcggACAGAC-UUGUCACu | || | ||||||| ccuaaaUUUCAGCAACAGUGa 145 0.59963 2 15 1649 1669 78 78 0 9606 2008-05-16
Pour les récupérer je n'ai pas de problèmes, j'effectue un SPLIT sur ma ligne, je teste ma ligne pour savoir si mon 5ème terme est celui recherché par l'utilisateur (ici cela serait donc hsa-miR-1208). Si cela est bien le cas, je récupère mes 2ème et 3ème termes (respectivement NM_005840 et SPRY3 dans mon exemple).
Mon problème est un peu délicat, lorsque j'effectue une recherche, cela fonctionne, sauf si le nombre de lignes trouvées correspondant à ma recherche est trop important.
Par exemple si je recherche hsa-miR-122, il y a 2095 lignes qui m'intéressent !
Et là j'ai ce message d'erreur qui s'affiche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space at java.lang.String.substring(Unknown Source) at java.lang.String.subSequence(Unknown Source) at java.util.regex.Pattern.split(Unknown Source) at java.lang.String.split(Unknown Source) at infosmiRNA.listegenescibles(infosmiRNA.java:840) at infosmiRNA.actionPerformed(infosmiRNA.java:715) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(Unknown Source) at javax.swing.SwingUtilities.notifyAction(Unknown Source) at javax.swing.JComponent.processKeyBinding(Unknown Source) at javax.swing.KeyboardManager.fireBinding(Unknown Source) at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source) at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source) at javax.swing.JComponent.processKeyBindings(Unknown Source) at javax.swing.JComponent.processKeyEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source)
Voici les lignes de code qui me permettent d'effectuer mes actions :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 while ((ligne2=kr.readLine())!=null) { String[] tabdonneespredictions = ligne2.split("\t", 0); tabdonneespredictions[4]=tabdonneespredictions[4].toLowerCase(); if (tabdonneespredictions[4].regionMatches(0, recherche, 0, longrecherche)) { indic=true; genelist.add(tabdonneespredictions[2] +" - - - "); mrnalist.add(tabdonneespredictions[1]); pospremiernommicro++; } if ((!tabdonneespredictions[4].regionMatches(0, recherche, 0, longrecherche)) && indic==true) {break;} pospremiernommicro++; } String[] tabgene = (String[])genelist.toArray(new String[genelist.size()]); String[] tabmrna = (String[])mrnalist.toArray(new String[mrnalist.size()]); for (int y=0; y<tabmrna.length-1; y++) {tabmrna[y] = tabmrna[y] +"\n";} int longtab = tabgene.length; String[] tabgenemrna = new String[longtab]; for (int u=0; u<longtab; u++) {tabgenemrna[u] = tabgene[u] +tabmrna[u];} String premligne = "Gène - - - mRNA" +"\n" +"----------------------------------------" +"\n"; for (int v=0; v<tabgenemrna.length; v++) {premligne = premligne +tabgenemrna[v];} genes.setText(premligne);
Ma ligne 840 précisée dans le message d'erreur est la ligne en gras.
Comment puis-je faire pour récupérer mes données quelque soit le nombre de lignes trouvées ?
Merci !
Partager