Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xtpcpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PAPPSO
xtpcpp
Commits
f707d4dc
Commit
f707d4dc
authored
6 years ago
by
Langella Olivier
Browse files
Options
Downloads
Patches
Plain Diff
fasta files can be writed by groups or subgroups
parent
a8382d19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/output/exportfastafile.cpp
+67
-22
67 additions, 22 deletions
src/output/exportfastafile.cpp
src/output/exportfastafile.h
+6
-1
6 additions, 1 deletion
src/output/exportfastafile.h
with
73 additions
and
23 deletions
src/output/exportfastafile.cpp
+
67
−
22
View file @
f707d4dc
...
...
@@ -26,19 +26,19 @@
******************************************************************************/
#include
"exportfastafile.h"
#include
<pappsomspp/fasta/fastaoutputstream.h>
ExportFastaFile
::
ExportFastaFile
(
QString
filename
,
ExportFastaType
type
)
{
p_outputFastaFile
=
new
QFile
(
filename
);
mp_outputFastaFile
=
new
QFile
(
filename
);
m_exportType
=
type
;
}
void
ExportFastaFile
::
write
(
ProjectSp
project_sp
)
{
p_outputFastaFile
->
open
(
QIODevice
::
WriteOnly
);
QTextStream
*
p_outputStream
=
new
QTextStream
(
p_outputFastaFile
);
m
p_outputFastaFile
->
open
(
QIODevice
::
WriteOnly
);
QTextStream
*
p_outputStream
=
new
QTextStream
(
m
p_outputFastaFile
);
pappso
::
FastaOutputStream
fasta_output
(
*
p_outputStream
);
...
...
@@ -46,29 +46,74 @@ ExportFastaFile::write(ProjectSp project_sp)
for
(
IdentificationGroup
*
identification
:
project_sp
.
get
()
->
getIdentificationGroupList
())
{
for
(
ProteinMatch
*
protein_match
:
identification
->
getProteinMatchList
())
{
if
(
protein_match
->
getValidationState
()
>=
ValidationState
::
grouped
)
{
pappso
::
Protein
protein
(
QString
(
"%1 %2"
)
.
arg
(
protein_match
->
getProteinXtpSp
().
get
()
->
getAccession
())
.
arg
(
protein_match
->
getProteinXtpSp
().
get
()
->
getDescription
()),
protein_match
->
getProteinXtpSp
().
get
()
->
getSequence
());
fasta_output
.
writeProtein
(
protein
);
}
}
writeIdentificationGroup
(
fasta_output
,
identification
);
}
p_output
Stream
->
flush
();
delete
p_output
Stream
;
p_outputFastaFile
->
close
();
m
p_output
FastaFile
->
flush
();
delete
m
p_output
FastaFile
;
m
p_outputFastaFile
->
close
();
}
void
ExportFastaFile
::
close
()
{
delete
p_outputFastaFile
;
p_outputFastaFile
=
nullptr
;
delete
mp_outputFastaFile
;
mp_outputFastaFile
=
nullptr
;
}
void
ExportFastaFile
::
writeIdentificationGroup
(
pappso
::
FastaOutputStream
&
fasta_output
,
IdentificationGroup
*
p_ident
)
{
for
(
const
std
::
pair
<
unsigned
int
,
GroupingGroupSp
>
&
group_pair
:
p_ident
->
getGroupStore
().
getGroupMap
())
{
unsigned
int
protein_rank
=
0
;
unsigned
int
group_number
=
0
;
unsigned
int
subgroup_number
=
0
;
unsigned
int
old_group_number
=
0
;
unsigned
int
old_subgroup_number
=
0
;
std
::
vector
<
const
ProteinMatch
*>
protein_match_list
=
group_pair
.
second
.
get
()
->
getProteinMatchList
();
std
::
sort
(
protein_match_list
.
begin
(),
protein_match_list
.
end
(),
[](
const
ProteinMatch
*
a
,
const
ProteinMatch
*
b
)
{
return
a
->
getGrpProteinSp
().
get
()
->
getGroupingId
()
<
b
->
getGrpProteinSp
().
get
()
->
getGroupingId
();
});
for
(
auto
&
protein_match
:
protein_match_list
)
{
pappso
::
GrpProtein
*
p_grp_protein
=
protein_match
->
getGrpProteinSp
().
get
();
ProteinXtp
*
p_protein
=
protein_match
->
getProteinXtpSp
().
get
();
group_number
=
p_grp_protein
->
getGroupNumber
();
subgroup_number
=
p_grp_protein
->
getSubGroupNumber
();
if
((
m_exportType
==
ExportFastaType
::
oneBySubgroup
)
&&
(
group_number
==
old_group_number
)
&&
(
subgroup_number
==
old_subgroup_number
)
&&
(
p_grp_protein
->
getRank
()
>
1
))
continue
;
if
((
m_exportType
==
ExportFastaType
::
oneByGroup
)
&&
(
group_number
==
old_group_number
)
&&
(
subgroup_number
>
1
))
continue
;
old_group_number
=
group_number
;
old_subgroup_number
=
subgroup_number
;
pappso
::
Protein
protein
(
QString
(
"%1|%2 %3"
)
.
arg
(
p_grp_protein
->
getGroupingId
())
.
arg
(
p_protein
->
getAccession
())
.
arg
(
p_protein
->
getDescription
()),
p_protein
->
getSequence
());
fasta_output
.
writeProtein
(
protein
);
}
}
}
This diff is collapsed.
Click to expand it.
src/output/exportfastafile.h
+
6
−
1
View file @
f707d4dc
...
...
@@ -30,11 +30,16 @@
#include
<QString>
#include
"../utils/types.h"
#include
"../core/project.h"
#include
<pappsomspp/fasta/fastaoutputstream.h>
class
ExportFastaFile
{
private:
QFile
*
p_outputFastaFile
=
nullptr
;
QFile
*
mp_outputFastaFile
=
nullptr
;
ExportFastaType
m_exportType
;
private:
void
writeIdentificationGroup
(
pappso
::
FastaOutputStream
&
fasta_output
,
IdentificationGroup
*
p_ident
);
public:
ExportFastaFile
(
QString
filename
,
ExportFastaType
type
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment