use of io.repseq.core.GeneFeature in project repseqio by repseqio.
the class GeneFeatureTest method test3.
@Test
public void test3() throws Exception {
GeneFeature f1, f2, f3, expected, actual;
f1 = createWithOffsets(1, 3, -2, 0);
f2 = createWithOffsets(3, 5, 1, 1);
f3 = createWithOffsets(5, 7, 1, 5);
expected = create(new int[] { 1, 3, 3, 7 }, new int[] { -2, 0, 1, 5 });
actual = new GeneFeature(f2, f1, f3);
assertEquals(expected, actual);
f1 = createWithOffsets(1, 3, -2, 0);
f2 = createWithOffsets(3, 5, 1, -1);
f3 = createWithOffsets(5, 7, -1, 5);
expected = create(new int[] { 1, 3, 3, 7 }, new int[] { -2, 0, 1, 5 });
actual = new GeneFeature(f2, f1, f3);
assertEquals(expected, actual);
f1 = createWithOffsets(1, 3, -2, 0);
f2 = createWithOffsets(3, 5, 1, -3);
f3 = createWithOffsets(5, 7, -2, 5);
expected = create(new int[] { 1, 3, 3, 5, 5, 7 }, new int[] { -2, 0, 1, -3, -2, 5 });
actual = new GeneFeature(f2, f1, f3);
assertEquals(expected, actual);
assertEquals(3, actual.regions.length);
}
use of io.repseq.core.GeneFeature in project repseqio by repseqio.
the class GeneFeatureTest method create.
static final GeneFeature create(int... indexes) {
assert indexes.length % 2 == 0;
GeneFeature[] res = new GeneFeature[indexes.length / 2];
for (int i = 0; i < indexes.length; ) {
res[i / 2] = new GeneFeature(new ReferencePoint(BasicReferencePoint.getByIndex(indexes[i])), new ReferencePoint(BasicReferencePoint.getByIndex(indexes[i + 1])));
i += 2;
}
return new GeneFeature(res);
}
use of io.repseq.core.GeneFeature in project mixcr by milaboratory.
the class VDJCAlignmentsWriter method header.
@Override
public void header(VDJCAlignerParameters parameters, List<VDJCGene> genes) {
if (parameters == null || genes == null)
throw new IllegalArgumentException();
if (header)
throw new IllegalStateException();
// Writing magic bytes
assert MAGIC_BYTES.length == MAGIC_LENGTH;
output.write(MAGIC_BYTES);
// Writing version information
output.writeUTF(MiXCRVersionInfo.get().getVersionString(MiXCRVersionInfo.OutputType.ToFile));
// Writing parameters
output.writeObject(parameters);
IOUtil.writeAndRegisterGeneReferences(output, genes, parameters);
// Registering links to features to align
for (GeneType gt : GeneType.VDJC_REFERENCE) {
GeneFeature feature = parameters.getFeatureToAlign(gt);
output.writeObject(feature);
if (feature != null)
output.putKnownReference(feature);
}
header = true;
}
use of io.repseq.core.GeneFeature in project mixcr by milaboratory.
the class VDJCAlignmentsReader method init.
void init(Map<GeneFeature, GeneFeature> geneFeatureRefs) {
if (usedGenes != null)
return;
assert MAGIC_BYTES.length == MAGIC_LENGTH;
byte[] magic = new byte[MAGIC_LENGTH];
input.readFully(magic);
String magicString = new String(magic);
this.magic = magicString;
SerializersManager serializersManager = input.getSerializersManager();
switch(magicString) {
case MAGIC_V9:
serializersManager.registerCustomSerializer(VDJCAlignments.class, new IO.VDJCAlignmentsSerializer21());
case MAGIC:
break;
default:
throw new RuntimeException("Unsupported file format; .vdjca file of version " + new String(magic) + " while you are running MiXCR " + MAGIC);
}
versionInfo = input.readUTF();
parameters = input.readObject(VDJCAlignerParameters.class);
this.usedGenes = IOUtil.readAndRegisterGeneReferences(input, vdjcRegistry, parameters);
// Registering links to features to align
for (GeneType gt : GeneType.VDJC_REFERENCE) {
GeneFeature featureParams = parameters.getFeatureToAlign(gt);
GeneFeature featureDeserialized = input.readObject(GeneFeature.class);
if (!Objects.equals(featureDeserialized, featureParams))
throw new RuntimeException("Wrong format.");
// Find corresponding reference
if (geneFeatureRefs != null) {
featureParams = geneFeatureRefs.get(featureParams);
if (featureParams == null)
throw new RuntimeException("Absent record for " + featureDeserialized + " in geneFeatureRefs map.");
}
if (featureDeserialized != null)
input.putKnownReference(featureParams);
}
}
use of io.repseq.core.GeneFeature in project mixcr by milaboratory.
the class IO method readGF2GTMap.
public static EnumMap<GeneType, GeneFeature> readGF2GTMap(PrimitivI input) {
int count = input.readInt();
EnumMap<GeneType, GeneFeature> map = new EnumMap<GeneType, GeneFeature>(GeneType.class);
for (int i = 0; i < count; i++) {
GeneType gt = input.readObject(GeneType.class);
GeneFeature gf = input.readObject(GeneFeature.class);
map.put(gt, gf);
}
return map;
}
Aggregations