@@ -147,4 +147,45 @@ class CollectAlternateContigNamesTest extends UnitSpec {
147
147
dict.last.name shouldBe " NC_012920.1"
148
148
dict.last.aliases should contain theSameElementsInOrderAs Seq (" J01415.2" , " chrM" )
149
149
}
150
+
151
+ it should " sort by sequencing roles when they all are defined" in {
152
+ val output = makeTempFile(" test." , " .dict" )
153
+ val tool = new CollectAlternateContigNames (
154
+ input = reportHg19,
155
+ output = output,
156
+ primary = Column .RefSeqAccession ,
157
+ alternates = Seq (Column .UcscName ),
158
+ sequenceRoles = Seq (UnplacedScaffold , UnlocalizedScaffold , AssembledMolecule ),
159
+ sortBySequencingRole = true
160
+ )
161
+ executeFgbioTool(tool)
162
+
163
+ val dict = SequenceDictionary (output)
164
+ dict should have length 84
165
+ dict.head.name shouldBe " NT_113961.1"
166
+ dict.head.aliases should contain theSameElementsInOrderAs Seq (" chrUn_gl000211" )
167
+ dict.last.name shouldBe " NC_012920.1"
168
+ dict.last.aliases should contain theSameElementsInOrderAs Seq (" chrM" )
169
+ dict.map(m => m(Column .SequenceRole .tag)).toIndexedSeq.distinct should contain theSameElementsInOrderAs Seq (UnplacedScaffold , UnlocalizedScaffold , AssembledMolecule ).map(_.key)
170
+ }
171
+
172
+ it should " sort by sequencing roles when no roles are defined" in {
173
+ val output = makeTempFile(" test." , " .dict" )
174
+ val tool = new CollectAlternateContigNames (
175
+ input = reportHg19,
176
+ output = output,
177
+ primary = Column .RefSeqAccession ,
178
+ alternates = Seq (Column .UcscName ),
179
+ sortBySequencingRole = true
180
+ )
181
+ executeFgbioTool(tool)
182
+
183
+ val dict = SequenceDictionary (output)
184
+ dict should have length 93
185
+ dict.head.name shouldBe " NC_000001.10"
186
+ dict.head.aliases should contain theSameElementsInOrderAs Seq (" chr1" )
187
+ dict.last.name shouldBe " NT_167243.1"
188
+ dict.last.aliases should contain theSameElementsInOrderAs Seq (" chrUn_gl000249" )
189
+ dict.map(m => m(Column .SequenceRole .tag)).toIndexedSeq.distinct should contain theSameElementsInOrderAs Seq (AssembledMolecule , AltScaffold , UnlocalizedScaffold , UnplacedScaffold ).map(_.key)
190
+ }
150
191
}
0 commit comments