Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vidjil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,688
Issues
1,688
List
Boards
Labels
Service Desk
Milestones
Merge Requests
84
Merge Requests
84
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
vidjil
Commits
feb4281d
Commit
feb4281d
authored
Oct 19, 2018
by
Mathieu Giraud
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-a/2828-output-airr' into 'dev'
Feature a/2828 output airr See merge request
!330
parents
e91de594
8e36164d
Pipeline
#44948
canceled with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
179 additions
and
20 deletions
+179
-20
algo/core/output.cpp
algo/core/output.cpp
+83
-1
algo/core/output.h
algo/core/output.h
+24
-17
algo/tests/should-get-tests/airr-S22.should-get
algo/tests/should-get-tests/airr-S22.should-get
+33
-0
algo/tests/should-get-tests/airr-X5.should-get
algo/tests/should-get-tests/airr-X5.should-get
+29
-0
algo/tests/should-get-tests/overlap-stdout.should-get
algo/tests/should-get-tests/overlap-stdout.should-get
+1
-1
algo/vidjil.cpp
algo/vidjil.cpp
+9
-1
No files found.
algo/core/output.cpp
View file @
feb4281d
#include "output.h"
#include "output.h"
#define NULL_VAL ""
string
getout
(
json
v
)
{
if
(
v
.
is_null
())
return
NULL_VAL
;
if
(
v
.
is_number
())
return
string_of_int
(
v
)
;
if
(
v
.
is_string
())
return
v
;
return
v
.
dump
();
}
string
Output
::
get
(
string
key
)
{
return
getout
(
j
[
key
]);
}
string
Output
::
get
(
string
key
,
string
subkey
)
{
return
getout
(
j
[
key
][
subkey
]);
}
string
Output
::
get
(
string
key
,
string
subkey
,
string
subsubkey
)
{
return
getout
(
j
[
key
][
subkey
][
subsubkey
]);
}
void
Output
::
set
(
string
key
,
json
val
)
void
Output
::
set
(
string
key
,
json
val
)
{
{
...
@@ -27,6 +50,17 @@ void Output::add_warning(string code, string msg, string level)
...
@@ -27,6 +50,17 @@ void Output::add_warning(string code, string msg, string level)
json_add_warning
(
j
,
code
,
msg
,
level
);
json_add_warning
(
j
,
code
,
msg
,
level
);
}
}
int
CloneOutput
::
reads
()
{
return
j
[
"reads"
][
0
];
}
CloneOutput
::~
CloneOutput
()
{
}
json
CloneOutput
::
toJson
()
json
CloneOutput
::
toJson
()
{
{
return
j
;
return
j
;
...
@@ -69,7 +103,7 @@ CloneOutput* SampleOutput::getClone(junction junction)
...
@@ -69,7 +103,7 @@ CloneOutput* SampleOutput::getClone(junction junction)
}
}
}
}
// .vidjil json output
void
SampleOutputVidjil
::
out
(
ostream
&
s
)
void
SampleOutputVidjil
::
out
(
ostream
&
s
)
{
{
...
@@ -82,3 +116,51 @@ void SampleOutputVidjil::out(ostream &s)
...
@@ -82,3 +116,51 @@ void SampleOutputVidjil::out(ostream &s)
s
<<
j
.
dump
(
2
);
s
<<
j
.
dump
(
2
);
}
}
// AIRR .tsv output
map
<
string
,
string
>
CloneOutputAIRR
::
fields
()
{
map
<
string
,
string
>
fields
;
fields
[
"locus"
]
=
get
(
"germline"
);
fields
[
"consensus_count"
]
=
string_of_int
(
reads
());
fields
[
"sequence_id"
]
=
get
(
"id"
);
fields
[
"clone_id"
]
=
get
(
"id"
);
fields
[
"sequence"
]
=
get
(
"sequence"
);
fields
[
"v_call"
]
=
get
(
KEY_SEG
,
"5"
,
"name"
);
fields
[
"d_call"
]
=
get
(
KEY_SEG
,
"4"
,
"name"
);
fields
[
"j_call"
]
=
get
(
KEY_SEG
,
"3"
,
"name"
);
return
fields
;
}
void
SampleOutputAIRR
::
out
(
ostream
&
s
)
{
vector
<
string
>
fields
=
{
"locus"
,
"consensus_count"
,
"v_call"
,
"d_call"
,
"j_call"
,
"sequence_id"
,
"sequence"
,
"sequence_alignment"
,
"germline_alignment"
,
"v_cigar"
,
"d_cigar"
,
"j_cigar"
,
"clone_id"
};
for
(
string
f
:
fields
)
s
<<
f
<<
"
\t
"
;
s
<<
endl
;
for
(
auto
it
:
clones
)
{
map
<
string
,
string
>
clone_fields
=
static_cast
<
CloneOutputAIRR
*>
(
it
.
second
)
->
fields
();
for
(
string
f
:
fields
)
s
<<
clone_fields
[
f
]
<<
"
\t
"
;
s
<<
endl
;
}
}
algo/core/output.h
View file @
feb4281d
...
@@ -18,16 +18,26 @@ protected:
...
@@ -18,16 +18,26 @@ protected:
json
j
;
json
j
;
public:
public:
string
get
(
string
key
);
string
get
(
string
key
,
string
subkey
);
string
get
(
string
key
,
string
subkey
,
string
subsubkey
);
void
set
(
string
key
,
json
val
);
void
set
(
string
key
,
json
val
);
void
set
(
string
key
,
string
subkey
,
json
val
);
void
set
(
string
key
,
string
subkey
,
json
val
);
void
set
(
string
key
,
string
subkey
,
string
subsubkey
,
json
val
);
void
set
(
string
key
,
string
subkey
,
string
subsubkey
,
json
val
);
void
add_warning
(
string
code
,
string
msg
,
string
level
);
void
add_warning
(
string
code
,
string
msg
,
string
level
);
};
};
class
CloneOutput
:
public
Output
class
CloneOutput
:
public
Output
{
{
public:
public:
virtual
~
CloneOutput
();
int
reads
();
void
setSeg
(
string
subkey
,
json
val
);
void
setSeg
(
string
subkey
,
json
val
);
json
toJson
();
json
toJson
();
...
@@ -53,27 +63,24 @@ public:
...
@@ -53,27 +63,24 @@ public:
};
};
/*
// Native Json .vidjil format
class CloneOutputFormatter
// See vidjil-format.md
{
class
SampleOutputVidjil
:
public
SampleOutput
}
class CloneOutputFormatterCSV(CloneOutputFormatter)
{
{
public:
void
out
(
ostream
&
s
);
};
}
// AIRR
// See http://docs.airr-community.org
class CloneOutput
FormatterJson(CloneOutputFormatter)
class
CloneOutput
AIRR
:
public
CloneOutput
{
{
public:
void
out
(
ostream
&
s
);
map
<
string
,
string
>
fields
();
};
}
class
SampleOutputAIRR
:
public
SampleOutput
*/
// Native Json .vidjil format
// See vidjil-format.md
class
SampleOutputVidjil
:
public
SampleOutput
{
{
public:
public:
void
out
(
ostream
&
s
);
void
out
(
ostream
&
s
);
...
...
algo/tests/should-get-tests/airr-S22.should-get
0 → 100644
View file @
feb4281d
!LAUNCH: $VIDJIL_DIR/$EXEC $VIDJIL_DEFAULT_OPTIONS -c clones -z 2 -3 -g $VIDJIL_DIR/germline/homo-sapiens.g:IGH $VIDJIL_DATA/Stanford_S22.fasta > /dev/null ; cat out/Stanford_S22.tsv
$ There are four lines, all with tabs
4:
4:\t
$ The required AIRR fields are present
:consensus_count
:v_call d_call j_call
:sequence_id
:sequence
:sequence_alignment
:germline_alignment
:v_cigar d_cigar j_cigar
$ Three clones on IGH
3:IGH
$ One clone has 8 reads, two clones have 5 reads
1:IGH 8
2:IGH 5
$ v_call for 2 clones (-z 2)
2:IGHV
$ First clone window appears third times (clone_id, sequence_id, sequence)
w3:TATTACTGTACCCGGGAGGAACAATATAGCAGCTGGTACTTTGACTTCTG
$ No spurious character
0:"
0:@
0:\\
algo/tests/should-get-tests/airr-X5.should-get
0 → 100644
View file @
feb4281d
!LAUNCH: $VIDJIL_DIR/$EXEC $VIDJIL_DEFAULT_OPTIONS -c clones -z 2 -2 -3 -r 1 -g $VIDJIL_DIR/germline/homo-sapiens.g ../should-vdj-tests/Demo-X5.should-vdj.fa > /dev/null ; cat out/Demo-X5.should-vdj.tsv
$ There are 15 = 1 + 14 lines, all with tabs
15:
15:\t
$ All clones have 1 reads
14: \t1\t
$ 8 clones with TR recombinations, some of them having special recombinations
2:TRA
1:TRA[+]D
2:TRB
1:TRB[+]
1:TRG
3:TRD
2:TRD[+]
$ One recombination with KDE
1:KDE
$ No spurious character
0:"
0:@
0:\\
algo/tests/should-get-tests/overlap-stdout.should-get
View file @
feb4281d
!LAUNCH: $VIDJIL_DIR/$EXEC $VIDJIL_DEFAULT_OPTIONS -c segment -g $VIDJIL_DIR/germline/homo-sapiens.g:IGH -A $VIDJIL_DATA/overlap-d-j.fa | grep -v
web
| tail -4 | tr -d '\n' | wc -c
!LAUNCH: $VIDJIL_DIR/$EXEC $VIDJIL_DEFAULT_OPTIONS -c segment -g $VIDJIL_DIR/germline/homo-sapiens.g:IGH -A $VIDJIL_DATA/overlap-d-j.fa | grep -v
out
| tail -4 | tr -d '\n' | wc -c
$ Exported sequence has all the bases
$ Exported sequence has all the bases
1:116
1:116
...
...
algo/vidjil.cpp
View file @
feb4281d
...
@@ -103,6 +103,7 @@ enum { CMD_WINDOWS, CMD_CLONES, CMD_SEGMENT, CMD_GERMLINES } ;
...
@@ -103,6 +103,7 @@ enum { CMD_WINDOWS, CMD_CLONES, CMD_SEGMENT, CMD_GERMLINES } ;
#define AFFECTS_FILENAME ".affects"
#define AFFECTS_FILENAME ".affects"
#define EDGES_FILENAME ".edges"
#define EDGES_FILENAME ".edges"
#define COMP_FILENAME "comp.vidjil"
#define COMP_FILENAME "comp.vidjil"
#define AIRR_SUFFIX ".tsv"
#define JSON_SUFFIX ".vidjil"
#define JSON_SUFFIX ".vidjil"
#define DEFAULT_K 0
#define DEFAULT_K 0
...
@@ -753,6 +754,7 @@ int main (int argc, char **argv)
...
@@ -753,6 +754,7 @@ int main (int argc, char **argv)
// JSON OUTPUT //
// JSON OUTPUT //
/////////////////////////////////////////
/////////////////////////////////////////
string
f_airr
=
out_dir
+
f_basename
+
AIRR_SUFFIX
;
string
f_json
=
out_dir
+
f_basename
+
JSON_SUFFIX
;
string
f_json
=
out_dir
+
f_basename
+
JSON_SUFFIX
;
ostringstream
stream_cmdline
;
ostringstream
stream_cmdline
;
...
@@ -1638,13 +1640,19 @@ int main (int argc, char **argv)
...
@@ -1638,13 +1640,19 @@ int main (int argc, char **argv)
cout
<<
endl
;
cout
<<
endl
;
}
}
//$ Output AIRR .tsv
cout
<<
" ==> "
<<
f_airr
<<
"
\t
(AIRR output)"
<<
endl
;
ofstream
out_airr
(
f_airr
.
c_str
());
static_cast
<
SampleOutputAIRR
*>
(
output
)
->
out
(
out_airr
);
//$ Output .vidjil json
//$ Output .vidjil json
cout
<<
" ==> "
<<
f_json
<<
"
\t
(data file for the web application)"
<<
endl
;
cout
<<
" ==> "
<<
f_json
<<
"
\t
(data file for the
Vidjil
web application)"
<<
endl
;
ofstream
out_json
(
f_json
.
c_str
())
;
ofstream
out_json
(
f_json
.
c_str
())
;
SampleOutputVidjil
*
outputVidjil
=
static_cast
<
SampleOutputVidjil
*>
(
output
);
SampleOutputVidjil
*
outputVidjil
=
static_cast
<
SampleOutputVidjil
*>
(
output
);
outputVidjil
->
out
(
out_json
);
outputVidjil
->
out
(
out_json
);
//$$ Clean
//$$ Clean
delete
multigermline
;
delete
multigermline
;
delete
reads
;
delete
reads
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment