use of io.repseq.core.VDJCLibrary in project mixcr by milaboratory.
the class TargetBuilderTest method testGenerate1.
@Test
public void testGenerate1() throws Exception {
VDJCLibrary library = VDJCLibraryRegistry.getDefault().getLibrary("default", "hs");
TargetBuilder.VDJCGenes genes = new TargetBuilder.VDJCGenes(library, "TRBV12-1*00", "TRBD1*00", "TRBJ1-3*00", "TRBC2*00");
String model = "{CDR3Begin(-20)}VVVVVVVVVVVvVVVvVVVVVVVVVVVVVNNNNNNN{DBegin(0)}DDDDDDDDDDNN{CDR3End(-10)}JJJJJJJJJJJJJJJJJJJJ";
NucleotideSequence nucleotideSequence = TargetBuilder.generateSequence(genes, model, new Well44497b());
Assert.assertEquals(36 + 12 + 20, nucleotideSequence.size());
}
use of io.repseq.core.VDJCLibrary in project mixcr by milaboratory.
the class ActionListLibraries method go.
@Override
public void go(ActionHelper helper) {
VDJCLibraryRegistry.getDefault().loadAllLibraries();
System.out.println("Available libraries:");
List<VDJCLibrary> loadedLibraries = new ArrayList<>(VDJCLibraryRegistry.getDefault().getLoadedLibraries());
Collections.sort(loadedLibraries);
for (VDJCLibrary library : loadedLibraries) {
System.out.println(library.getLibraryId());
System.out.println(VDJCLibraryRegistry.getDefault().getSpeciesNames(library.getTaxonId()));
}
}
use of io.repseq.core.VDJCLibrary in project repseqio by repseqio.
the class GenerateClonesAction method go.
@Override
public void go(ActionHelper helper) throws Exception {
GCloneModel model = GModels.getGCloneModelByName(params.getModelName());
GCloneGenerator generator = model.create(new Well19937c(params.getSeed()), VDJCLibraryRegistry.getDefault());
VDJCLibrary library = VDJCLibraryRegistry.getDefault().getLibrary(model.libraryId());
try (BufferedOutputStream s = new BufferedOutputStream(params.getOutput().equals(".") ? System.out : new FileOutputStream(params.getOutput()), 128 * 1024)) {
s.write(GlobalObjectMappers.toOneLine(model.libraryId()).getBytes());
s.write('\n');
ObjectWriter writer = GlobalObjectMappers.ONE_LINE.writerFor(new TypeReference<GClone>() {
}).withAttribute(VDJCGene.JSON_CURRENT_LIBRARY_ATTRIBUTE_KEY, library);
OUTER: for (int i = 0; i < params.numberOfClones; i++) {
GClone clone = generator.sample();
for (GGene g : clone.genes.values()) {
NucleotideSequence cdr3 = g.getFeature(GeneFeature.CDR3);
if (params.isInFrame())
if (cdr3.size() % 3 != 0) {
--i;
continue OUTER;
}
if (params.isNoStops())
if (AminoAcidSequence.translateFromCenter(cdr3).containStops()) {
--i;
continue OUTER;
}
}
writer.writeValue(new CloseShieldOutputStream(s), clone);
s.write('\n');
}
}
}
use of io.repseq.core.VDJCLibrary in project repseqio by repseqio.
the class Main method main.
public static void main(String[] args) throws Exception {
Signal.handle(new Signal("PIPE"), new SignalHandler() {
@Override
public void handle(Signal signal) {
System.exit(0);
}
});
if (System.getProperty("localOnly") == null) {
Path cachePath = Paths.get(System.getProperty("user.home"), ".repseqio", "cache");
SequenceResolvers.initDefaultResolver(cachePath);
}
// Setting up main helper
JCommanderBasedMain main = new JCommanderBasedMain("repseqio", new ListAction(), new FilterAction(), new MergeAction(), new CompileAction(), new GenerateClonesAction(), new NormalizeCloneAbundancesAction(), new ExportCloneSequencesAction(), new FastaAction(), new TsvAction(), new InferAnchorPointsAction(), new DebugAction(), new FormatAction(), new StatAction(), new FromFastaAction(), new FromPaddedFastaAction());
main.setVersionInfoCallback(new Runnable() {
@Override
public void run() {
VersionInfo milib = VersionInfo.getVersionInfoForArtifact("milib");
VersionInfo repseqio = VersionInfo.getVersionInfoForArtifact("repseqio");
StringBuilder builder = new StringBuilder();
builder.append("RepSeq.IO.CLI v").append(repseqio.getVersion()).append(" (built ").append(repseqio.getTimestamp()).append("; rev=").append(repseqio.getRevision()).append("; branch=").append(repseqio.getBranch()).append("; host=").append(repseqio.getHost()).append(")").append("\n");
builder.append("MiLib v").append(milib.getVersion()).append(" (rev=").append(milib.getRevision()).append("; branch=").append(milib.getBranch()).append(")").append("\n");
builder.append("Built-in libraries:\n");
VDJCLibraryRegistry reg = VDJCLibraryRegistry.createDefaultRegistry();
reg.loadAllLibraries("default");
for (VDJCLibrary lib : reg.getLoadedLibraries()) builder.append(lib.getLibraryId()).append("\n");
System.out.print(builder.toString());
}
});
main.main(args);
}
use of io.repseq.core.VDJCLibrary in project repseqio by repseqio.
the class TsvAction method go.
@Override
public void go(ActionHelper helper) throws Exception {
VDJCLibraryRegistry reg = VDJCLibraryRegistry.getDefault();
if (!"default".equals(params.getInput()))
reg.registerLibraries(params.getInput());
else
reg.loadAllLibraries("default");
Pattern chainPattern = params.chain == null ? null : Pattern.compile(params.chain);
Pattern namePattern = params.name == null ? null : Pattern.compile(params.name);
Long taxonFilter = params.taxonId;
if (taxonFilter == null && params.species != null)
taxonFilter = reg.resolveSpecies(params.species);
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(params.getOutputStream(), StandardCharsets.UTF_8))) {
writer.write("Gene\tChains\tFeature\tStart\tStop\tSource\tSequence\n");
for (VDJCLibrary lib : reg.getLoadedLibraries()) {
if (taxonFilter != null && taxonFilter != lib.getTaxonId())
continue;
for (VDJCGene gene : lib.getGenes()) {
if (chainPattern != null) {
boolean y = false;
for (String s : gene.getChains()) if (y |= chainPattern.matcher(s).matches())
break;
if (!y)
continue;
}
if (namePattern != null && !namePattern.matcher(gene.getName()).matches())
continue;
for (GeneFeatureWithOriginalName feature : params.features) {
GeneFeature geneFeature = feature.feature;
NucleotideSequence featureSequence = gene.getFeature(geneFeature);
if (featureSequence == null)
continue;
// Don't output start and end positions for composite gene features
Long start = geneFeature.isComposite() ? null : gene.getData().getAnchorPoints().get(geneFeature.getFirstPoint());
Long end = geneFeature.isComposite() ? null : gene.getData().getAnchorPoints().get(geneFeature.getLastPoint());
NucleotideSequence nSequence = gene.getFeature(geneFeature);
List<String> tokens = Arrays.asList(gene.getGeneName(), gene.getChains().toString(), feature.originalName, // (so essentially 1-based inclusive). Report both as 1-based.
(start == null ? "" : params.isOneBased() ? String.valueOf(start + 1) : String.valueOf(start)), (end == null ? "" : String.valueOf(end)), gene.getData().getBaseSequence().getOrigin().toString(), nSequence.toString());
String delim = "";
for (String t : tokens) {
writer.write(delim);
writer.write(t);
delim = "\t";
}
writer.write('\n');
}
}
}
}
}
Aggregations