File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed
main/java/org/biojava/nbio/genome/io/fastq
test/java/org/biojava/nbio/genome/io/fastq Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change @@ -145,4 +145,19 @@ public static final FastqBuilder builder()
145145 {
146146 return new FastqBuilder ();
147147 }
148+
149+ /**
150+ * Create and return a new FastqBuilder configured from the
151+ * specified FASTQ formatted sequence.
152+ * The FastqBuilder will not be null.
153+ *
154+ * @since 6.0.0
155+ * @param fastq FASTQ formatted sequence, must not be null
156+ * @return a new FastqBuilder configured from the specified FASTQ
157+ * formatted sequence
158+ */
159+ public static final FastqBuilder builder (final Fastq fastq )
160+ {
161+ return new FastqBuilder (fastq );
162+ }
148163}
Original file line number Diff line number Diff line change @@ -51,6 +51,25 @@ public FastqBuilder()
5151 // empty
5252 }
5353
54+ /**
55+ * Create a new FASTQ formatted sequence builder configured
56+ * from the specified FASTQ formatted sequence.
57+ *
58+ * @since 6.0.0
59+ * @param fastq FASTQ formatted sequence, must not be null
60+ */
61+ public FastqBuilder (final Fastq fastq )
62+ {
63+ if (fastq == null )
64+ {
65+ throw new IllegalArgumentException ("fastq must not be null" );
66+ }
67+ withDescription (fastq .getDescription ());
68+ withSequence (fastq .getSequence ());
69+ withQuality (fastq .getQuality ());
70+ withVariant (fastq .getVariant ());
71+ }
72+
5473
5574 /**
5675 * Return the description for this FASTQ formatted sequence builder.
Original file line number Diff line number Diff line change @@ -36,6 +36,41 @@ public void testConstructor()
3636 Assert .assertNotNull (fastqBuilder );
3737 }
3838
39+ @ Test
40+ public void testConstructorFastq ()
41+ {
42+ FastqBuilder fastqBuilder = new FastqBuilder ()
43+ .withDescription ("description" )
44+ .withSequence ("sequence" )
45+ .withQuality ("quality_" )
46+ .withVariant (FastqVariant .FASTQ_SOLEXA );
47+
48+ Fastq fastq = fastqBuilder .build ();
49+
50+ FastqBuilder fastqBuilder2 = new FastqBuilder (fastq );
51+ Assert .assertNotNull (fastqBuilder2 );
52+
53+ Fastq fastq2 = fastqBuilder2 .build ();
54+ Assert .assertEquals ("description" , fastq2 .getDescription ());
55+ Assert .assertEquals ("sequence" , fastq2 .getSequence ());
56+ Assert .assertEquals ("quality_" , fastq2 .getQuality ());
57+ Assert .assertEquals (FastqVariant .FASTQ_SOLEXA , fastq2 .getVariant ());
58+ }
59+
60+ @ Test
61+ public void testConstructorNullFastq ()
62+ {
63+ try
64+ {
65+ new FastqBuilder (null );
66+ Assert .fail ("builder(null) expected IllegalArgumentException" );
67+ }
68+ catch (IllegalArgumentException e )
69+ {
70+ // expected
71+ }
72+ }
73+
3974 @ Test
4075 public void testBuildDefault ()
4176 {
Original file line number Diff line number Diff line change @@ -111,6 +111,20 @@ public void testBuilder()
111111 Assert .assertNotNull (Fastq .builder ());
112112 }
113113
114+ @ Test
115+ public void testBuilderNullFastq ()
116+ {
117+ try
118+ {
119+ Fastq .builder (null );
120+ Assert .fail ("builder(null) expected IllegalArgumentException" );
121+ }
122+ catch (IllegalArgumentException e )
123+ {
124+ // expected
125+ }
126+ }
127+
114128 @ Test
115129 public void testEquals ()
116130 {
You can’t perform that action at this time.
0 commit comments