Skip to content

Fix/tissue in files#99

Open
juanNH wants to merge 6 commits into
devfrom
fix/tissueInFiles
Open

Fix/tissue in files#99
juanNH wants to merge 6 commits into
devfrom
fix/tissueInFiles

Conversation

@juanNH

@juanNH juanNH commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

No description provided.

TheSinnerAR and others added 6 commits June 23, 2026 13:43
Convert various models' tissues from ManyToMany to a nullable ForeignKey (Experiment, Biomarker, CGDSStudy, DifferentialExpressionExperiment, UserFile) and add the corresponding Django migrations. Update admin classes to surface tissues in list_filter/list_display and remove M2M helper UI code. Add lightweight SimpleTissueSerializer and include tissues in multiple serializers' representations and fields. Adjust CGDSStudy serializer create/update logic to handle FK instead of M2M. Update DifferentialExpression API to accept and persist tissues and return tissues in the response. Also add a ChatWidget import/use in the frontend Base component.
Rename model field `tissues` to singular `tissue` in api_service, biomarkers, datasets_synchronization, differential_expression and user_files. Updated models, admin list_filters, serializers and views to use `tissue` and added corresponding Django rename migrations (api_service/migrations/0064_..., biomarkers/migrations/0024_..., datasets_synchronization/migrations/0040_..., differential_expression/migrations/0003_..., user_files/migrations/0019_...). Note: this changes API payloads/serializers (clients should use `tissue` now). Run `python manage.py migrate` to apply DB migrations.
fields = ['id', 'username']


class SimpleTissueSerializer(serializers.Serializer):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Mover este serializer a serializers.py dentro de la app tissues
  2. Ya que no hay comportamiento customizado ni nada, que herede de serializers.ModelSerializer y definir los campos como se hizo en la clase ExperimentSerializerDetail

exclude = ['biomarker']


class SimpleTissueSerializer(serializers.Serializer):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usar el mismo serializer que está tissues/serializers.py. Ya que es el mismo

model = Biomarker
fields = '__all__'

def to_representation(self, instance):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hace fatla esto, poner tissue = SimpleTissueSerializer(read_only=True), como se hace en ExperimentSerializer y borrar este to_representation. Si es null en la DB el serializer de Django REST Framework ya sabe que tiene que devolver None

model = Biomarker
exclude = ['user']

def to_representation(self, instance):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem comentario anterior

@property
def file_type(self) -> FileType:
if hasattr(self, 'mrna_dataset'):
study = self.study

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nono, deshacer todos los cambios hecho en file_type y __get_reverse_study. Estaban andando bien. Acá explotaría en caso de que no exista un relacionado. Si se necesita otra cosa, armar otra función que haga lo requerido

props.newCGDSStudy.clinical_patient_dataset === null &&
props.newCGDSStudy.clinical_sample_dataset === null
props.newCGDSStudy.clinical_sample_dataset === null &&
tissues.length === 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tissues no debería ser obligatorio, sacar esta última condición

selection
clearable
name='tissue'
value={typeof tissues[0] === 'number'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por qué podrían venir un ID o un objeto? En caso de que esto sea correcto y no se pueda estandarizar a un solo tipo, agregar un comentario arriba explicando por qué es así (en inglés!)

const datasetRowDescriptionInPlural = getFileRowDescriptionInPlural(datasetObj.file_type)

const tissue = normalizeTissues(datasetObj.tissue)[0]
const tissueName = typeof tissue === 'number' ? undefined : tissue?.name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me preocupa que siempre esté apareciendo este chequeo, desde el backend no siempre se retorna un objeto? Estandarizar el tipo y sacar estos chequeos

instance.institutions.set(validated_data.get('institutions', []))
instance.is_cpg_site_id = validated_data.get('is_cpg_site_id')
instance.platform = validated_data.get('platform')
if 'tag' in validated_data:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dejar el código anterior que era más limpio. Si no está en validated_data está perfecto que se setee en None, que es el valor por defecto que se retorna en el .get()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminar este archivo, se pusheó por equivocación

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants