Skip to content
Snippets Groups Projects
Commit f3ca193d authored by valot's avatar valot
Browse files

Add remove contaminants database by reading fasta file and compared accession

Add compattibility of contaminants selection for Mascot

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@205 b8ef2a07-7df7-436f-90b9-41648038564b
parent 19317184
No related branches found
No related tags found
No related merge requests found
......@@ -178,7 +178,7 @@ public class config {
}
public void set_database_filter(File F) {
properties.setProperty(database_filter, F.getName());
properties.setProperty(database_filter, F.getPath());
}
public void set_protein_evalue(float F) {
......
package fr.inra.pappso.xtandempipeline.grouping;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
......@@ -90,23 +93,61 @@ public class GroupSet {
}
public void removeGroupFromDatabase(File database) {
// TODO Remove Group from this database
logger.info("Remove Group from Database: " + database.getName());
for (Group group : this.getGroupList()) {
boolean isconta = false;
for (SubGroup sg : group.getSubGroupSet()) {
for (HashSampleScanSetProt hashProt : sg
.getHashSampleScanSetProtSet()) {
if (hashProt.getMatch().get_protein_match().getDatabase().getDatabasePath()
.contains(database.getName())) {
isconta = true;
//Read fasta file to get accession list
if(database.exists()){
logger.info("Read fasta file : "+database.getName());
HashSet<String> access = new HashSet<String>();
try{
FileInputStream is = new FileInputStream(database);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while((line= br.readLine())!=null){
line.trim();
if(line.length()>0){
if(line.startsWith(">")){
access.add(line.split(" ")[0].replaceFirst(">", ""));
}
}
}
}catch (Exception e) {
logger.error(e);
}
//Search contaminants proteins
logger.info("Remove Group from Database in new mode: " + database.getName());
for (Group group : this.getGroupList()) {
boolean isconta = false;
for (SubGroup sg : group.getSubGroupSet()) {
for (HashSampleScanSetProt hashProt : sg
.getHashSampleScanSetProtSet()) {
if (access.contains(hashProt.getMatch().get_protein_match().get_cle_accession())) {
isconta = true;
}
}
}
if (isconta)
this.groupList.remove(group);
}
}else{
logger.error("fasta file doesnt not exist: " + database.getAbsolutePath());
logger.info("Remove Group from Database in old mode: " + database.getName());
for (Group group : this.getGroupList()) {
boolean isconta = false;
for (SubGroup sg : group.getSubGroupSet()) {
for (HashSampleScanSetProt hashProt : sg
.getHashSampleScanSetProtSet()) {
if (hashProt.getMatch().get_protein_match().getDatabase().getDatabasePath()
.contains(database.getName())) {
isconta = true;
}
}
}
if (isconta)
this.groupList.remove(group);
}
if (isconta)
this.groupList.remove(group);
}
//On renummerote après avoir modifier les groupes
//Numbering after contaminant removing
this.numbering();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment