Skip to content

Commit

Permalink
Merge pull request #109 from b-schubert/release_2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
b-schubert committed Nov 23, 2015
2 parents 2e3c627 + 8d7e402 commit 329160e
Show file tree
Hide file tree
Showing 16 changed files with 10 additions and 1,446 deletions.
102 changes: 0 additions & 102 deletions Fred2/Core/Generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,108 +366,6 @@ def _generate_combinations(tId, vs, seq, usedVs, offset, isReverse=False):
yield Transcript("".join(varSeq), geneid, tId, vars=varComb)


def generate_transcripts_from_tumor_variants(normal, tumor, dbadapter, id_type):
"""
Generates all possible :class:`~Fred2.Core.Transcript.Transcript` variations of the given
:class:`~Fred2.Core.Variant.Variant`.
The result is a generator.
:param normal: A list of variants of the normal tissue
:type normal: list(:class:`~Fred2.Core.Variant.Variant`)
:param tumor: A list of variant of the cancer tissue for which transcript should be generated
:type tumor: list(:class:`~Fred2.Core.Variant.Variant`)
:param dbadapter: a DBAdapter to fetch the transcript sequences
:type dbadapter: :class:`~Fred2.IO.ADBAdapter.ADBAdapter`
:param id_type: The type of the transcript IDs used in annotation of variants (e.g. REFSEQ, ENSAMBLE)
:type id_type: :func:`~Fred2.IO.ADBAdapter.EIdentifierTypes`
:return: A generator of transcripts with all possible variations determined by the given variant list
:rtype: Generator(:class:`~Fred2.Core.Transcript.Transcript`)
"""
def _generate_combinations(tId, vs, seq, usedVs, offset):
"""
recursive variant combination generator
"""
transOff = generate_transcripts_from_tumor_variants.transOff
#print "TransOffset ", transOff, tId,usedVs
if vs:
flag, v = vs.pop()

if v.isHomozygous:
pos = v.coding[tId].tranPos + offset
usedVs[pos] = v
offset = _incorp.get(v.type, lambda a, b, c, d, e: e)(seq, v, tId, pos, offset)
for s in _generate_combinations(tId, vs, seq, usedVs, offset):
yield s
else:
vs_tmp = vs[:]
tmp_seq = seq[:]
tmp_usedVs = usedVs.copy()

if flag:
for s in _generate_combinations(tId, vs_tmp, tmp_seq, tmp_usedVs, offset):
yield s

# update the transcript variant id
generate_transcripts_from_tumor_variants.transOff += 1
pos = v.coding[tId].tranPos + offset
usedVs[pos] = v

offset = _incorp.get(v.type, lambda a, b, c, d, e: e)(seq, v, tId, pos, offset)

for s in _generate_combinations(tId, vs, seq, usedVs, offset):
yield s
else:
yield tId+":FRED2_%i"%transOff, seq, usedVs

#1) get all transcripts and sort the variants to transcripts

#For a transcript do:
#A) get transcript sequences
#B) generate all possible combinations of variants
#C) apply variants to transcript and generate transcript object

if not isinstance(dbadapter, ADBAdapter):
raise TypeError("The given dbadapter is not of type ADBAdapter")

transToVar = {}
for v in tumor:
for trans_id in v.coding.iterkeys():
transToVar.setdefault(trans_id, []).append((False, v))

for v in normal:
for trans_id in v.coding.iterkeys():
if trans_id in transToVar:
transToVar.setdefault(trans_id, []).append((True, v))

for tId, vs in transToVar.iteritems():
query = dbadapter.get_transcript_information(tId, type=id_type)
if query is None:
warnings.warn("Transcript with ID %s not found in DB"%tId)
continue

tSeq = query[EAdapterFields.SEQ]
geneid = query[EAdapterFields.GENE]
strand = query[EAdapterFields.STRAND]

#if its a reverse transcript form the complement of the variants
if strand == REVERS:
for flag, v in transToVar[tId]:
v.ref = v.ref[::-1].translate(COMPLEMENT)
v.obs = v.obs[::-1].translate(COMPLEMENT)

vs.sort(key=lambda (isTumor, v): v.genomePos-1
if v.type in [VariationType.FSINS, VariationType.INS]
else v.genomePos, reverse=True)
if not _check_for_problematic_variants(map(lambda x: x[1],vs)):
warnings.warn("Intersecting variants found for Transcript %s"%tId)
continue

generate_transcripts_from_tumor_variants.transOff = 0
for tId, varSeq, varComb in _generate_combinations(tId, vs, list(tSeq), {}, 0):
yield Transcript("".join(varSeq), geneid, tId, vars=varComb)


################################################################################
# T R A N S C R I P T = = > P R O T E I N
################################################################################
Expand Down
70 changes: 0 additions & 70 deletions Fred2/Distance2Self/Distance2Self.py

This file was deleted.

52 changes: 0 additions & 52 deletions Fred2/Distance2Self/DistanceMatrix.py

This file was deleted.

1 change: 0 additions & 1 deletion Fred2/Distance2Self/__init__.py

This file was deleted.

18 changes: 0 additions & 18 deletions Fred2/Distance2Self/hw.cpp

This file was deleted.

70 changes: 0 additions & 70 deletions Fred2/Distance2Self/src/Matrix.hpp

This file was deleted.

Loading

0 comments on commit 329160e

Please sign in to comment.